add 'draw_line' method

This commit is contained in:
histausse 2022-01-16 10:13:14 +01:00
parent 45ad11a0db
commit 59cd9727a8
Signed by: histausse
GPG key ID: 67486F107F62E9E9
2 changed files with 6 additions and 2 deletions

View file

@ -9,7 +9,8 @@ pub fn draw_circle(center: Point, radius: f64, context: &web_sys::CanvasRenderin
.unwrap(); .unwrap();
} }
/*
pub fn draw_line(p1: Point, p2: Point, context: &web_sys::CanvasRenderingContext2d) { 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);
} }
*/

View file

@ -25,5 +25,8 @@ pub fn start() {
drawing::draw_circle(Point(75.0, 75.0), 35.0, &context); drawing::draw_circle(Point(75.0, 75.0), 35.0, &context);
drawing::draw_circle(Point(60.0, 65.0), 5.0, &context); drawing::draw_circle(Point(60.0, 65.0), 5.0, &context);
drawing::draw_line(Point(0.0, 0.0), Point(150.0, 150.0), &context);
drawing::draw_line(Point(0.0, 150.0), Point(150.0, 0.0), &context);
context.stroke(); context.stroke();
} }