10 releases (6 breaking)
Uses new Rust 2024
| 0.6.2 | Oct 30, 2025 |
|---|---|
| 0.6.1 | Oct 9, 2025 |
| 0.5.0 | Jul 21, 2025 |
| 0.4.1 | Jul 4, 2025 |
| 0.0.0 | Nov 26, 2024 |
#134 in Graphics APIs
2,267 downloads per month
Used in 16 crates
(10 directly)
15KB
323 lines
AnyRender
A Rust 2D drawing abstraction.
AnyRender is a 2D drawing abstaction that allows applications/frameworks to support many rendering backends through a unified API.
Discussion of AnyRender development happens in the Linebender Zulip at https://xi.zulipchat.com/.
Crates
anyrender
The core anyrender crate is a lightweight type/trait-only crate that defines three abstractions:
- The PaintScene trait accepts drawing commands.
Applications and libraries draw by pushing commands into a
PaintScene. Backends generally execute those commands to produce an output (although they may do other things like store them for later use). - The WindowRenderer trait abstracts over types that can render to a window
- The ImageRenderer trait abstracts over types that can render to a
Vec<u8>image buffer
Backends
Currently existing backends are:
- anyrender_vello which draws using vello
- anyrender_vello_cpu which draws using vello_cpu
- anyrender_vello_hybrid ALPHA which draws using vello_hybrid
- anyrender_skia which draws using Skia (via the skia-safe crate)
Contributions for other backends (tiny-skia, femtovg, etc) would be very welcome.
Content renderers
These crates sit on top of the the AnyRender abstraction, and allow you render content through it:
- anyrender_svg allows you to render SVGs with AnyRender. usvg is used to parse the SVGs.
- blitz-paint can be used to HTML/CSS (and markdown) that has been parsed, styled, and layouted by blitz-dom using AnyRender.
- polymorpher implements Material Design 3 shape morphing, and can be used with AnyRender by enabling the
kurbofeature.
Utility crates
- wgpu_context is a utility for managing
Devices and other WGPU types - pixels_window_renderer implements an AnyRender
WindowRendererfor any AnyRendererImageRendererusing the pixels crate. - softbuffer_window_renderer implements an AnyRender
WindowRendererfor any AnyRendererImageRendererusing the softbuffer crate.
Minimum supported Rust Version (MSRV)
This version of AnyRender has been verified to compile with Rust 1.86 and later.
Future versions of AnyRender might increase the Rust version requirement. It will not be treated as a breaking change and as such can even happen with small patch releases.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Contributions are welcome by pull request. The Rust code of conduct applies.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
lib.rs:
2D drawing abstraction that allows applications/frameworks to support many rendering backends through a unified API.
Painting a scene
The core abstraction in AnyRender is the PaintScene trait.
PaintScene is a "sink" which accepts drawing commands:
- Applications and libraries draw by pushing commands into a
PaintScene - Backends execute those commands to produce an output
Rendering to surface or buffer
In addition to PaintScene, there is:
- The
ImageRenderertrait which provides an abstraction for rendering to aVec<u8>RGBA8 buffer. - The
WindowRenderertrait which provides an abstraction for rendering to a surface/window
SVG
The anyrender_svg crate allows SVGs to be rendered using AnyRender
Backends
Currently existing backends are:
Dependencies
~1MB
~22K SLoC