Compile scratch projects to WASM
- Rust (v1.65.0 or later)
- wasm-bindgen-cli (
cargo install -f wasm-bindgen-cli
) - wasm-opt (install binaryen using whatever package manager you use)
./build.sh -pVW # use -dVW for a debug build without optimisation
You may need to run chmod +x build.sh
if it says it doesn't have permission.
The build script has additonal configuration options; run ./build.sh -h
for info on these.
name | number of bytes | optional? | description |
---|---|---|---|
redraw_requested | 4 | no | if a redraw has been requested or not |
thread_num | 4 | no | the number of currently running threads |
vars | 12 * number of global & local variables | yes | see variables |
sprite_info | 56 * number of sprites (i.e. target num -1) | yes | see sprite info |
threads | 4 * thread_num | no | imdices of the next step funcs of currently running threads |
byte | type | name | description |
---|---|---|---|
0-7 | f64 | x | x pos |
8-15 | f64 | y | y pos |
16-19 | f32 | pen_color | hue of pen (0-100) |
20-23 | f32 | pen_saturation | saturation of pen (0-100) |
24-27 | f32 | pen_brightness | value of pen (0-100) |
28-31 | f32 | pen_transparency | transparency of pen (0-100) |
32-47 | f32(x4) | pen_color4f | rgba color of pen [(0-1)x4] |
48-55 | f64 | pen_size | pen radius |
56 | u8 | pen_down | whether the pen is down (1) or not (0) |
57-63 | ? | padding | padding |
byte | description |
---|---|
0-3 | identifies the type of the variable |
4-11 | identifies the value of the variable |
value | type | variable value type | value description |
---|---|---|---|
0x00 | float64 | f64 |
a float |
0x01 | bool64 | i64 |
an integer - the least significant bit is the one we actually care about for booleans |
0x02 | externref string (64 bit) | i64 |
wrapped to a 32 bit pointer to an externref value in the anyref table |
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.