blinc_paint
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.
Overview
blinc_paint provides a Canvas-like API for 2D drawing, similar to HTML Canvas or Skia.
Features
- Path Drawing: Lines, curves, arcs, beziers
- Shape Primitives: Rectangles, circles, rounded rectangles
- Fills & Strokes: Solid colors, gradients
- Text Rendering: Basic text drawing
- GPU Backend: DrawContext implementation for GPU rendering
Quick Start
use ;
Paths
use ;
// Create a path
let mut path = new;
path.move_to;
path.line_to;
path.line_to;
path.quad_to;
path.close;
// Draw the path
ctx.fill_path;
ctx.stroke_path;
Gradients
use ;
// Linear gradient
let linear = new
.add_stop
.add_stop
.add_stop;
ctx.fill_rect_gradient;
// Radial gradient
let radial = new
.add_stop
.add_stop;
ctx.fill_circle_gradient;
Transforms
// Save current transform
ctx.save;
// Apply transforms
ctx.translate;
ctx.rotate;
ctx.scale;
// Draw transformed
ctx.fill_rect;
// Restore previous transform
ctx.restore;
Clipping
// Set clip rectangle
ctx.clip_rect;
// All subsequent drawing is clipped
ctx.fill_rect;
// Only the intersection is drawn
// Reset clip
ctx.reset_clip;
Shapes
// Rectangle
ctx.fill_rect;
ctx.stroke_rect;
// Rounded rectangle
ctx.fill_rounded_rect;
ctx.stroke_rounded_rect;
// Circle
ctx.fill_circle;
ctx.stroke_circle;
// Ellipse
ctx.fill_ellipse;
ctx.stroke_ellipse;
// Line
ctx.draw_line;
Architecture
blinc_paint
├── context.rs # PaintContext API
├── path.rs # Path and PathCommand
├── brush.rs # Brush, Gradient types
├── color.rs # Color utilities
└── transform.rs # 2D transforms
License
MIT OR Apache-2.0