You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
440 B
Rust
17 lines
440 B
Rust
use std::f64;
|
|
|
|
pub struct Point(pub f64, pub f64);
|
|
|
|
pub fn draw_circle(center: Point, radius: f64, context: &web_sys::CanvasRenderingContext2d) {
|
|
context.move_to(center.0+radius, center.1);
|
|
context
|
|
.arc(center.0, center.1, radius, 0.0, f64::consts::PI * 2.0)
|
|
.unwrap();
|
|
}
|
|
|
|
pub fn draw_line(p1: Point, p2: Point, context: &web_sys::CanvasRenderingContext2d) {
|
|
context.move_to(p1.0, p1.1);
|
|
context
|
|
.line_to(p2.0, p2.1);
|
|
}
|