/color-me-rusty

Interpolate document background color with Rust

Primary LanguageRust

Color Me Rusty

A demonstration in Rust + WebAssembly to set the background color of a webpage

Recurse Center pill

Files

.
├── src
│   └── lib.rs
│   └── colors.rs
├── target
│   └── wasm32-unknown-unknown
│       └── release
│           └── color-me-rusty.wasm
├── color-me-rusty.gc.wasm
├── Cargo.lock
├── Cargo.toml
├── index.html
├── index.js
└── README.md

Setup

Installing the Rustup toolchain

$ curl https://sh.rustup.rs -sSf | sh

See also: The Rust Programming Language Book

Installing Rust Nightly

$ rustup toolchain install nightly

Updating Rust Nightly

$ rustup update

Installing the WebAssembly target

$ rustup target add wasm32-unknown-unknown --toolchain nightly

Installing wasm-gc

$ cargo install --git https://github.com/alexcrichton/wasm-gc

Compilation

Compiling Rust to WebAssembly

$ cargo +nightly build --target wasm32-unknown-unknown --release

Creating a smaller binary with wasm-gc

$ wasm-gc target/wasm32-unknown-unknown/release/color-me-rusty.wasm -o color-me-rusty.gc.wasm

Resources

Acknowledgements

Thank you to the following people for contributing ideas and enthusiasm and/or pairing with me!