GPU Antialiased 2D vector drawing library written in Rust.
Ported from https://github.com/memononen/nanovg
Most of the implementation is the same as the original C code with some bug fixes, some features added and several parts have been made more Rust-y. Rendering is done via one OpenGl (ES) 3.0+ backend.
Run with cargo run --example demo
Run with cargo run --example breakout
Run with cargo run --example svg
Run with cargo run --example text
- Anti-aliasing
- Bézier paths filling and stroking
- Solid color and image pattern fills and strokes
- Gradients - box, linear, radial (including two-point / focal), and conic, with multi-stop colors and gradient transforms
- Stroke width and miterlimit
- Stroke caps: butt, round and square
- Stroke joins: miter, round and bevel
- Stroke dashing with dash offset
- Fill rules - EvenOdd/NonZero
- Rectangle scissoring (with rounded corners) and arbitrary-path clipping (Canvas 2D clip / SVG clip-path, nonzero and evenodd)
- Composition modes (SourceOver, SourceIn, SourceOut, Atop, etc..)
- Image filters - gaussian blur, color matrices (the CSS filter functions), Perlin turbulence (SVG
feTurbulence) and the sRGB transfer curve, chained in a single call - Layers - group capture with declared opacity and layer filters (Canvas 2D beginLayer/endLayer, SVG group effects)
- Layer masks - luminance and alpha (SVG mask / mask-type)
- Global alpha
- Text filling and stroking
- Text shaping
- Text alignment: (left center right), (top, middle, alphabetic, bottom)
- Nearest font matching
- Path hit testing
- OpenGl ES2 backend
- WGPU backend
- Color fonts
- Custom shaders
- 3D transforms
FemtoVG is used by these projects:
- pn-editor https://gitlab.com/porky11/pn-editor: view, edit, and simulate petri nets
- Slint https://slint.dev: A declarative GUI toolkit to build native user interfaces for embedded, desktop, and mobile application
- inlottie https://github.com/mhfan/inlottie: lib/tool in Rust for Lottie (Bodymovin) Animation
- Mapvas https://github.com/UdHo/mapvas: A map canvas showing OSM tiles with drawing functionality
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.
Fonts used in examples:
- Roboto licensed under Apache license
- Entypo licensed under CC BY-SA 4.0.
- Amiri licensed under SIL Open Font License, Version 1.1