#rasterizer #svg #low-level #graphics #path #2d-graphics

no-std zeno

High performance, low level 2D path rasterization

9 releases

0.3.1 Jan 31, 2024
0.3.0 Nov 29, 2023
0.2.3 Sep 29, 2023
0.2.2 Jun 25, 2021
0.1.2 Oct 11, 2020

#29 in Graphics APIs

Download history 8902/week @ 2024-01-27 8554/week @ 2024-02-03 9797/week @ 2024-02-10 11458/week @ 2024-02-17 10008/week @ 2024-02-24 9677/week @ 2024-03-02 9223/week @ 2024-03-09 9717/week @ 2024-03-16 10319/week @ 2024-03-23 8756/week @ 2024-03-30 7445/week @ 2024-04-06 9800/week @ 2024-04-13 10716/week @ 2024-04-20 11892/week @ 2024-04-27 11271/week @ 2024-05-04 8637/week @ 2024-05-11

44,003 downloads per month
Used in 9 crates (5 directly)

MIT/Apache

195KB
5K SLoC

zeno

Zeno is a pure Rust crate that provides a high performance, low level 2D rasterization library with support for rendering paths of various styles into alpha or subpixel masks.

Crates.io Docs.rs MIT licensed Apache licensed

Features

  • 256x anti-aliased rasterization (8-bit alpha or 32-bit RGBA subpixel alpha)
  • Pixel perfect hit testing with customizable coverage threshold
  • Non-zero and even-odd fills
  • Stroking with the standard set of joins and caps (separate start and end caps are possible)
  • Numerically stable dashing for smooth dash offset animation
  • Vertex traversal for marker placement
  • Stepped distance traversal for animation or text-on-path support
  • Abstract representation of path data that imposes no policy on storage

Usage

Rendering a dashed stroke of a triangle:

use zeno::{Cap, Join, Mask, PathData, Stroke};

// Buffer to store the mask
let mut mask = [0u8; 64 * 64];

/// Create a mask builder with some path data
Mask::new("M 8,56 32,8 56,56 Z")
    .style(
        // Stroke style with a width of 4
        Stroke::new(4.0)
            // Round line joins
            .join(Join::Round)
            // And round line caps
            .cap(Cap::Round)
            // Dash pattern followed by a dash offset
            .dash(&[10.0, 12.0, 0.0], 0.0),
    )
    // Set the target dimensions
    .size(64, 64)
    // Render into the target buffer
    .render_into(&mut mask, None);

Resulting in the following mask:

Dashed Triangle

For detail on additional features and more advanced usage, see the full API documentation.

Dependencies

~105KB