A GPU-native paint engine for Rust: brushes, layers, blend modes, masks, selections, and undo, on wgpu (WebGPU). Runs on the desktop or in the browser via WebAssembly.
darkly is the Rust core of Darkly, a GPU-native paint program for artists. It provides all the essential features: pressure-sensitive brush strokes, layers and groups, blend modes, masks, selections, and undo/redo, all on the GPU.
To render, it needs a wgpu surface (a native window or an HTML canvas). It then builds the layer tree and the GPU textures behind it, and composites frames on demand. The Darkly web app is this exact crate behind a thin WebAssembly bridge.
This crate can be used to power the backend for any drawing app, whiteboard, texture editor, etc. It includes only the engine: no frontend. The Darkly app is the reference frontend.
Features
- Node-graph brush engine. Every brush (round, watercolor, smudge, liquify, clone) compiles to a single GPU pipeline.
- Layers and groups. A real layer tree with blend modes and per-layer opacity.
- Masks and selections. Rectangle, ellipse, lasso, polygon, and magic-wand modifiers.
- First-class undo/redo. Every edit is an undoable, serializable document operation.
- GPU-native compositing. wgpu/WebGPU pipelines, with the document as the source of truth and the compositor derived from it.
- One engine, native or web. The same code drives desktop builds and the in-browser editor.
Example
Create a layer, paint a brush stroke across it, and composite a frame. The wgpu Instance and Surface come from a native window or an HTML canvas:
use ;
use GpuContext;
async
Pre-1.0: Darkly is in beta and this crate tracks the app's needs, so the API will change between releases. Pin an exact version if you depend on it.
Project
- Try it now: demo.darkly.art
- Documentation: darkly.art/docs
- Community: Discord
- Issues and source: github.com/darkly-art/darkly
Acknowledgements
A special thank you to Nick Cameron for graciously gifting us the darkly crate on crates.io. 💜