blurhash-rust-wasm
A Rust implementation of the blurhash algorithm.
It is compiled to WebAssembly (WASM), and available on npm as blurhash-wasm
.
Usage in JS
import * as blurhash from "blurhash";
// Returned as Uint8Array
// You can use this to construct canvas-compatible resources
const pixels = blurhash.;
encode
Not yet implemented :)
Usage in Rust
decode
use blurhash_wasm;
// Result<Vec<u8>, blurhash::Error>
let res = decode;
encode
Not yet implemented :)
About the setup
Based on the rust wasm-pack template
This template is designed for compiling Rust libraries into WebAssembly and publishing the resulting package to NPM.
Be sure to check out other wasm-pack
tutorials online for other
templates and usages of wasm-pack
.
🚴 Usage
🛠️ Build with wasm-pack build
wasm-pack build
🔬 Test in Headless Browsers with wasm-pack test
wasm-pack test --headless --firefox
🎁 Publish to NPM with wasm-pack publish
wasm-pack publish
🔋 Batteries Included
wasm-bindgen
for communicating between WebAssembly and JavaScript.console_error_panic_hook
for logging panic messages to the developer console.wee_alloc
, an allocator optimized for small code size.