Draft web platform structure
This commit is contained in:
parent
eea9530f38
commit
c5703eb00a
26 changed files with 1171 additions and 153 deletions
20
src/platform_impl/web/stdweb/canvas.rs
Normal file
20
src/platform_impl/web/stdweb/canvas.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
pub struct Canvas;
|
||||
|
||||
impl Canvas {
|
||||
pub fn new() -> Self {
|
||||
let element = document()
|
||||
.create_element("canvas")
|
||||
.map_err(|_| os_error!(OsError("Failed to create canvas element".to_owned())))?;
|
||||
|
||||
let canvas: CanvasElement = element
|
||||
.try_into()
|
||||
.map_err(|_| os_error!(OsError("Failed to create canvas element".to_owned())))?;
|
||||
|
||||
document()
|
||||
.body()
|
||||
.ok_or_else(|| os_error!(OsError("Failed to find body node".to_owned())))?
|
||||
.append_child(&canvas);
|
||||
|
||||
Canvas(canvas)
|
||||
}
|
||||
}
|
||||
0
src/platform_impl/web/stdweb/mod.rs
Normal file
0
src/platform_impl/web/stdweb/mod.rs
Normal file
Loading…
Add table
Add a link
Reference in a new issue