| Crates.io | plutovg-sys |
| lib.rs | plutovg-sys |
| version | 0.0.1 |
| created_at | 2025-07-28 21:02:13.508202+00 |
| updated_at | 2025-07-28 21:02:13.508202+00 |
| description | Low-level bindings to the PlutoVG vector graphics library |
| homepage | |
| repository | https://githbub.com/nickrobinson/plutovg-sys |
| max_upload_size | |
| id | 1771564 |
| size | 1,075,802 |
FFI bindings to PlutoVG, a 2D vector graphics library written in C.
PlutoVG is a standalone 2D vector graphics library that provides:
Add this to your Cargo.toml:
[dependencies]
plutovg-sys = "0.0.1"
This crate provides low-level FFI bindings. All functions are unsafe and require manual memory management.
use plutovg_sys::*;
use std::ffi::CString;
unsafe {
// Create a 400x400 surface
let surface = plutovg_surface_create(400, 400);
let canvas = plutovg_canvas_create(surface);
// Draw a red circle
plutovg_canvas_arc(canvas, 200.0, 200.0, 100.0, 0.0, PLUTOVG_TWO_PI, false);
plutovg_canvas_set_rgb(canvas, 1.0, 0.0, 0.0); // Red
plutovg_canvas_fill(canvas);
// Save to PNG
let filename = CString::new("circle.png").unwrap();
plutovg_surface_write_to_png(surface, filename.as_ptr());
// Clean up
plutovg_canvas_destroy(canvas);
plutovg_surface_destroy(surface);
}
Run the included example to generate a smiley face:
cargo run --example basic
This creates a smiley.png file with a yellow smiley face.
The crate provides mathematical constants as f32 values:
PLUTOVG_PI - π (3.141592...)PLUTOVG_TWO_PI - 2πPLUTOVG_HALF_PI - π/2PLUTOVG_SQRT2 - √2PLUTOVG_KAPPA - κ (0.552284...)This crate uses bindgen to generate Rust bindings and cc to compile the PlutoVG C library. The build process:
⚠️ All functions in this crate are unsafe
You must ensure:
This project is licensed under the MIT License - see the LICENSE file for details.
The bundled PlutoVG library is also MIT licensed.
Contributions are welcome! Please feel free to submit a Pull Request.