56 个版本 (2 个稳定版)

1.0.1 2022年11月6日
1.0.0 2022年7月11日
0.17.10 2021年10月12日
0.17.5 2021年1月30日
0.1.1 2016年7月14日

#12 in 图形API

Download history 11150/week @ 2024-03-14 12998/week @ 2024-03-21 11440/week @ 2024-03-28 9981/week @ 2024-04-04 11482/week @ 2024-04-11 11137/week @ 2024-04-18 10478/week @ 2024-04-25 10237/week @ 2024-05-02 7737/week @ 2024-05-09 8570/week @ 2024-05-16 9119/week @ 2024-05-23 10465/week @ 2024-05-30 10238/week @ 2024-06-06 12294/week @ 2024-06-13 9453/week @ 2024-06-20 7088/week @ 2024-06-27

40,450 每月下载量
用于 144 个包 (42 个直接使用)

MIT/Apache

1MB
33K SLoC

Lyon

一个用于基于GPU的2D图形渲染的路径细分库。

Project logo

crates.io Build Status documentation Gitter Chat

示例

extern crate lyon;
use lyon::math::point;
use lyon::path::Path;
use lyon::tessellation::*;

fn main() {
    // Build a Path.
    let mut builder = Path::builder();
    builder.begin(point(0.0, 0.0));
    builder.line_to(point(1.0, 0.0));
    builder.quadratic_bezier_to(point(2.0, 0.0), point(2.0, 1.0));
    builder.cubic_bezier_to(point(1.0, 1.0), point(0.0, 1.0), point(0.0, 0.0));
    builder.end(true);
    let path = builder.build();
    // Let's use our own custom vertex type instead of the default one.
    #[derive(Copy, Clone, Debug)]
    struct MyVertex { position: [f32; 2] };
    // Will contain the result of the tessellation.
    let mut geometry: VertexBuffers<MyVertex, u16> = VertexBuffers::new();
    let mut tessellator = FillTessellator::new();
    {
        // Compute the tessellation.
        tessellator.tessellate_path(
            &path,
            &FillOptions::default(),
            &mut BuffersBuilder::new(&mut geometry, |vertex: FillVertex| {
                MyVertex {
                    position: vertex.position().to_array(),
                }
            }),
        ).unwrap();
    }
    // The tessellated geometry is ready to be uploaded to the GPU.
    println!(" -- {} vertices {} indices",
        geometry.vertices.len(),
        geometry.indices.len()
    );
}

依赖项

~2MB
~40K SLoC