web-dom
DOM access for web assembly
- no magic
- no abstractions
- no code generation
- api generated from webidl
- can be used with many languages that compile to web assembly
= "0.0"
Documentation: https://docs.rs/web-dom/
Want to create web components? Check out https://github.com/web-dom/webcomponent
use *;
[]
= "helloworld"
= "0.0.1"
= "2018"
[]
=["cdylib"]
[]
= "0.0"
cargo build --target wasm32-unknown-unknown --release
See it working here
Alert
use *;
See it working here
Canvas
use *;
See it working here
Events
use *;
See it working here
Pong
https://github.com/richardanaya/pong/
See it working here
Don't like Rust?
web-dom can be used with any language that compiles to web assembly
extern int ;
extern void ;
int
(extern global_get_window [])
(extern window_get_document [window])
(extern document_query_selector [document query])
(extern htmlcanvas_get_context [element context])
(extern drawing_set_fill_style [canvas color])
(extern drawing_fill_rect [canvas x y w h])
(def colors ("black" "grey" "red"))
(pub defn main []
(let [window (global_get_window)
document (window_get_document window)
canvas (document_query_selector document "#screen")
ctx (htmlcanvas_get_context canvas "2d")]
(loop [x 0]
(if (< x 3)
(do (drawing_set_fill_style ctx (mem32 (+ colors (* 4 x))))
(drawing_fill_rect ctx (* x 10) (* x 10) 50 50 )
(recur [x (+ x 1)]))))))