8 个版本
新 0.2.6 | 2024 年 8 月 19 日 |
---|---|
0.2.5 | 2024 年 7 月 7 日 |
0.2.3 | 2024 年 6 月 27 日 |
0.2.2 | 2024 年 3 月 4 日 |
0.1.0 | 2023 年 12 月 9 日 |
在 图形 API 中排名第 138
每月下载量 133 次
580KB
2.5K SLoC
pnte
Windows 的 Rust 2D 图形库
pnte 是 Direct2D 和 DirectWrite 的包装器。
要求
使用此库,必须为每个线程调用 CoInitializeEx
。
简单使用方法
- 创建一个
pnte::Context
。
let ctx = pnte::Context::new(pnte::Direct2D::new()?)?;
- 创建一个渲染目标。
let render_target = ctx.create_render_target(&window, (size.width, size.height))?;
- 绘图。
ctx.draw(&render_target, |cmd| {
let white = pnte::SolidColorBrush::new(&ctx, (1.0, 1.0, 1.0, 1.0))?;
cmd.clear((0.0, 0.0, 0.0, 0.0));
cmd.draw_text("pnte", (10.0, 10.0), &white)?;
})?;
许可证
此库采用 MIT 许可证。
依赖关系
~128MB
~2M SLoC