| Crates.io | blinc_paint |
| lib.rs | blinc_paint |
| version | 0.1.12 |
| created_at | 2026-01-14 17:23:05.095084+00 |
| updated_at | 2026-01-19 01:05:29.923978+00 |
| description | Blinc Paint/Canvas API - 2D drawing primitives and path rendering |
| homepage | |
| repository | https://github.com/project-blinc/Blinc |
| max_upload_size | |
| id | 2043286 |
| size | 28,821 |
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
2D drawing primitives and path rendering for Blinc UI.
blinc_paint provides a Canvas-like API for 2D drawing, similar to HTML Canvas or Skia.
use blinc_paint::{PaintContext, Color, Brush};
fn draw(ctx: &mut PaintContext) {
// Draw a filled rectangle
ctx.fill_rect(0.0, 0.0, 100.0, 50.0, Color::BLUE);
// Draw a stroked circle
ctx.stroke_circle(50.0, 50.0, 25.0, Color::RED, 2.0);
// Draw a rounded rectangle
ctx.fill_rounded_rect(10.0, 10.0, 80.0, 40.0, 8.0, Color::GREEN);
}
use blinc_paint::{Path, PathCommand};
// Create a path
let mut path = Path::new();
path.move_to(0.0, 0.0);
path.line_to(100.0, 0.0);
path.line_to(100.0, 100.0);
path.quad_to(50.0, 150.0, 0.0, 100.0);
path.close();
// Draw the path
ctx.fill_path(&path, Color::BLUE);
ctx.stroke_path(&path, Color::BLACK, 2.0);
use blinc_paint::{LinearGradient, RadialGradient, GradientStop};
// Linear gradient
let linear = LinearGradient::new(0.0, 0.0, 100.0, 0.0)
.add_stop(0.0, Color::RED)
.add_stop(0.5, Color::YELLOW)
.add_stop(1.0, Color::GREEN);
ctx.fill_rect_gradient(0.0, 0.0, 100.0, 50.0, &linear);
// Radial gradient
let radial = RadialGradient::new(50.0, 50.0, 50.0)
.add_stop(0.0, Color::WHITE)
.add_stop(1.0, Color::BLUE);
ctx.fill_circle_gradient(50.0, 50.0, 50.0, &radial);
// Save current transform
ctx.save();
// Apply transforms
ctx.translate(50.0, 50.0);
ctx.rotate(45.0_f32.to_radians());
ctx.scale(2.0, 2.0);
// Draw transformed
ctx.fill_rect(-25.0, -25.0, 50.0, 50.0, Color::BLUE);
// Restore previous transform
ctx.restore();
// Set clip rectangle
ctx.clip_rect(10.0, 10.0, 80.0, 80.0);
// All subsequent drawing is clipped
ctx.fill_rect(0.0, 0.0, 100.0, 100.0, Color::RED);
// Only the intersection is drawn
// Reset clip
ctx.reset_clip();
// Rectangle
ctx.fill_rect(x, y, width, height, color);
ctx.stroke_rect(x, y, width, height, color, stroke_width);
// Rounded rectangle
ctx.fill_rounded_rect(x, y, width, height, radius, color);
ctx.stroke_rounded_rect(x, y, width, height, radius, color, stroke_width);
// Circle
ctx.fill_circle(cx, cy, radius, color);
ctx.stroke_circle(cx, cy, radius, color, stroke_width);
// Ellipse
ctx.fill_ellipse(cx, cy, rx, ry, color);
ctx.stroke_ellipse(cx, cy, rx, ry, color, stroke_width);
// Line
ctx.draw_line(x1, y1, x2, y2, color, stroke_width);
blinc_paint
├── context.rs # PaintContext API
├── path.rs # Path and PathCommand
├── brush.rs # Brush, Gradient types
├── color.rs # Color utilities
└── transform.rs # 2D transforms
MIT OR Apache-2.0