#2d-graphics #graphics #gui #windows

pnte

Windows 的 Rust 2D 图形库

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

Download history 1/week @ 2024-05-21 175/week @ 2024-06-25 224/week @ 2024-07-02 25/week @ 2024-07-09 133/week @ 2024-08-13

每月下载量 133

MIT 许可证 MIT

580KB
2.5K SLoC

pnte

Windows 的 Rust 2D 图形库

pnte 是 Direct2D 和 DirectWrite 的包装器。

要求

使用此库,必须为每个线程调用 CoInitializeEx

简单使用方法

  1. 创建一个 pnte::Context
let ctx = pnte::Context::new(pnte::Direct2D::new()?)?;
  1. 创建一个渲染目标。
let render_target = ctx.create_render_target(&window, (size.width, size.height))?;
  1. 绘图。
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