9个版本

0.3.1 2024年1月31日
0.3.0 2023年11月29日
0.2.3 2023年9月29日
0.2.2 2021年6月25日
0.1.2 2020年10月11日

#23 in 图形API

Download history · Rust 包仓库 11892/week @ 2024-04-27 · Rust 包仓库 11271/week @ 2024-05-04 · Rust 包仓库 9958/week @ 2024-05-11 · Rust 包仓库 9136/week @ 2024-05-18 · Rust 包仓库 9648/week @ 2024-05-25 · Rust 包仓库 9772/week @ 2024-06-01 · Rust 包仓库 9916/week @ 2024-06-08 · Rust 包仓库 11305/week @ 2024-06-15 · Rust 包仓库 10995/week @ 2024-06-22 · Rust 包仓库 12050/week @ 2024-06-29 · Rust 包仓库 18892/week @ 2024-07-06 · Rust 包仓库 25265/week @ 2024-07-13 · Rust 包仓库 22206/week @ 2024-07-20 · Rust 包仓库 19792/week @ 2024-07-27 · Rust 包仓库 18686/week @ 2024-08-03 · Rust 包仓库 18175/week @ 2024-08-10 · Rust 包仓库

82,588 下载/月
9 个crate中使用 (5个直接使用)

MIT/Apache

195KB
5K SLoC

zeno

Zeno是一个纯Rust crate,它提供了一个高性能、低级的2D光栅化库,支持将各种样式的路径渲染到alpha或亚像素掩码。

Crates.io Docs.rs MIT licensed Apache licensed

功能

  • 256x抗锯齿光栅化(8位alpha或32位RGBA亚像素alpha)
  • 像素完美的命中测试,可自定义覆盖阈值
  • 非零和偶数填充
  • 使用标准连接和端盖集进行描边(可能使用单独的起始和结束端盖)
  • 用于平滑偏移动画的数值稳定的虚线
  • 顶点遍历用于标记放置
  • 步进距离遍历用于动画或路径上文本的支持
  • 路径数据的抽象表示,不强制存储策略

用法

渲染三角形的虚线描边

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);

生成以下掩码

Dashed Triangle

有关更多功能和高级使用的详细信息,请参阅完整的API 文档

依赖

~105KB