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.
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen::JsCast;
|
|
|
|
|
|
|
|
mod drawing;
|
|
|
|
mod shapes;
|
|
|
|
mod circle;
|
|
|
|
|
|
|
|
use shapes::*;
|
|
|
|
use circle::CircleShapes;
|
|
|
|
|
|
|
|
#[wasm_bindgen(start)]
|
|
|
|
pub fn start() {
|
|
|
|
let document = web_sys::window().unwrap().document().unwrap();
|
|
|
|
let canvas = document.get_element_by_id("canvas").unwrap();
|
|
|
|
let canvas: web_sys::HtmlCanvasElement = canvas
|
|
|
|
.dyn_into::<web_sys::HtmlCanvasElement>()
|
|
|
|
.map_err(|_| ())
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let context = canvas
|
|
|
|
.get_context("2d")
|
|
|
|
.unwrap()
|
|
|
|
.unwrap()
|
|
|
|
.dyn_into::<web_sys::CanvasRenderingContext2d>()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
context.begin_path();
|
|
|
|
|
|
|
|
let iter = CircleShapes::new(100, 13, Circle {center: Point {x: 75.0, y: 75.0}, radius: 70.0});
|
|
|
|
for shape in iter {
|
|
|
|
drawing::draw_shape(shape, &context);
|
|
|
|
}
|
|
|
|
context.stroke();
|
|
|
|
}
|