some html tweaking
This commit is contained in:
parent
22787184de
commit
a6f89ab707
2 changed files with 11 additions and 2 deletions
10
index.html
10
index.html
|
@ -12,7 +12,15 @@
|
||||||
|
|
||||||
run();
|
run();
|
||||||
</script>
|
</script>
|
||||||
<canvas id="canvas" height="150" width="150"></canvas>
|
<style>
|
||||||
|
#circle_canvas{
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<canvas id="circle_canvas" height="150" width="150"></canvas>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,9 @@ use circle::CircleShapes;
|
||||||
|
|
||||||
#[wasm_bindgen(start)]
|
#[wasm_bindgen(start)]
|
||||||
pub fn start() {
|
pub fn start() {
|
||||||
|
let canvas_id = "circle_canvas";
|
||||||
let document = web_sys::window().unwrap().document().unwrap();
|
let document = web_sys::window().unwrap().document().unwrap();
|
||||||
let canvas = document.get_element_by_id("canvas").unwrap();
|
let canvas = document.get_element_by_id(canvas_id).unwrap();
|
||||||
let canvas: web_sys::HtmlCanvasElement = canvas
|
let canvas: web_sys::HtmlCanvasElement = canvas
|
||||||
.dyn_into::<web_sys::HtmlCanvasElement>()
|
.dyn_into::<web_sys::HtmlCanvasElement>()
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
|
|
Loading…
Reference in a new issue