verdant
Verdant is a work-in-progress. The API may change at any time.
See boids.rs
See clock.rs
See paint.rs
What is Verdant?
Verdant is a rendering and windowing library for Rust, inspired by Processing, made to be accessible.
Built on top of wgpu and winit, Verdant focuses on a clean, expressive, and easy-to-use API that makes common rendering tasks easy and mistakes difficult.
Finally, a foundational rendering library that is easy to use.
use ;
Verdant aims to be performant and powerful, while still remaining lightweight and nice to use.
What Verdant is not
Verdant is a rendering/windowing library. It is not a game engine or a UI framework, it does not handle audio, it does not handle physics.
It is a foundation you can build those things on top of.
Why Verdant?
SDF-based rendering
Almost all Verdant primitives are rendered using SDFs (signed-distance-fields). This allows for your graphics to have perfect anti-aliasing and rounding, at any scale, while remaining efficient.
Multiple windows are first-class
Most graphics libraries start with a single window and treat additional windows as an advanced feature. Verdant easily and cleanly supports multiple windows, built into the API since day one.
See multi_window.rs
Scoped state
Most graphics libraries have functions like push_state and pop_state.
This is powerful, but it can lead to mistakes where state is leaked out of the context where you need it.
Verdant prevents this by providing scoped state through closures.
See scoped_state.rs
Pick your API
Verdant doesn't force you to stick to a state machine API or a more "retained" builder pattern API, instead allowing you to choose between either one.
// imperative, state-machine API
window.fill;
window.rect;
// more "declarative", builder pattern API
at
.size
.fill
.draw;
You can use the imperative, stateful API for quick prototyping or things that change every frame, or you can pick the declarative, builder API for things that hold state between frames.
See drawing.rs
Rich text
Verdant provides both a basic text API and a rich text API, allowing you to mix fonts, colors, sizes, and styles, all in a single function call.
See rich_text.rs
Canvases are first-class
Verdant allows you to render to off-screen surfaces just as easily as rendering to a window. It even lets you render a canvas to itself, allowing for recursive effects!
Views and coordinate systems
Verdant allows you to define a logical rendering space, independent of the physical window size. This allows you to create scalable applications without having to manually handle aspect-ratio math.
See views.rs
Configurable scaling
Verdant lets you choose how outlines and corner radii scale. They can behave like physical geometry, remain at a constant pixel size, or respond independently to transforms and view scaling. This makes it easy to build everything from scalable interfaces to interactive visualizations without sacrificing visual consistency.
See scaling_modes.rs
(The window has been resized to be much larger than the original size, on the left the outlines and corner radii scale with the window, and on the right they stay at a constant pixel size)
Installation
Add this to your Cargo.toml:
[]
= "0.5"
Currently, Verdant only supports desktop, though web/mobile support is planned soon.
Windows and Linux have been tested, and macOS is currently untested; if you are on macOS and try Verdant, please let us know how it works or open an issue if you encounter and platform-specific bugs.
Cargo Features
By default, Verdant includes granular features to control what gets built. If you don't need asset loading and/or text and want a lighter dependency tree, you can disable them:
[]
= { = "0.5", = false, = ["vulkan", "dx12", "metal"] }
If you want legacy OpenGL support:
[]
= { = "0.5", = false, = ["vulkan", "dx12", "metal", "gles"] }
It also has granular features for different image formats:
[]
= { = "0.5", = false, = ["vulkan", "dx12", "metal", "image-png", "image-jpeg", "image-webp"] }
By default, image-png and image-jpeg are enabled.
Running the Examples
To try out the examples locally, clone the repository and run them using Cargo:
Feedback
For any feedback on the API or for feature requests, please go to the issues page.
License
Verdant is licensed under MPL-2.0.
Applications built with Verdant may be distributed under any license. Only modifications to Verdant itself are required to remain MPL-licensed.