FragmentColor is a Creative Coding library written in Rust that provides a simple shader programming API for Javascript and Python, with more language bindings in the horizon.
This library uses wgpu as the hardware abstraction layer, which enables us to target a wide range of platforms and environments with near-native performance and small footprint:
Backend | WASM | Linux | MacOS | Windows | Android | iOS | CI / CD |
---|---|---|---|---|---|---|---|
Metal | no | no | Yes | no | no | Yes | no |
Vulkan | no | Yes | Yes1 | Yes | Yes | Yes | Yes |
OpenGL | no | Yes | Yes2 | Yes | Yes | Yes3 | no |
WebGL | Yes4 | no | no | no | no | no | no |
WebGPU | Yes | no | no | no | no | no | no |
Dx11/Dx12 | no | no | no | Yes | no | no | no |
Warning
This library is currently under heavy development, and the API is not yet stable, meaning
that while it is not tagged 1.0.0
, I might introduce breaking changes in minor versions.
You can use it and test it, and I would greatly appreciate any feedback you can provide.
If you use it in production, make sure you know what you are doing and lock the minor version.
Make sure you have wasm-pack installed.
cd crates/fragmentcolor-wasm
wasm-pack build --release --target web
The library will be available in pkg/
.
Check the usage example in index.html
.
Building all:
cargo task build all
Building:
cd crates/fragmentcolor
cargo build --release
The dynamic library will be available in target/release/
.
By default, the library will be built for the current platform. To build for a specific platform, use the --target
flag:
# MacOS (Intel)
cargo build --release --target x86_64-apple-darwin
# MacOS (Apple Silicon)
cargo build --release --target aarch64-apple-darwin
# Linux
cargo build --release --target x86_64-unknown-linux-gnu
# Windows
cargo build --release --target x86_64-pc-windows-msvc
You can check the list of all available targets with:
rustup target list
Platform support is divided in Tiers, check the Rust Platform Support page for more information.