Expand description
Blinc Paint/Canvas API
A 2D drawing API for custom graphics, similar to HTML Canvas or Skia. All core types are unified with blinc_core for seamless integration with the GPU renderer.
§Features
- Path drawing (lines, curves, arcs)
- Shape primitives (rect, circle, rounded rect)
- Fills and strokes with colors, gradients
- Text rendering
- DrawContext implementation for GPU rendering
§Example
ⓘ
use blinc_paint::{PaintContext, Color, Rect};
use blinc_core::DrawContext;
let mut ctx = PaintContext::new(800.0, 600.0);
// Canvas-like API
ctx.fill_rect_xywh(10.0, 20.0, 100.0, 50.0, Color::BLUE);
ctx.translate(50.0, 50.0);
ctx.fill_rounded_rect_xywh(0.0, 0.0, 80.0, 40.0, 8.0, Color::RED);
// Or use the DrawContext API directly
ctx.fill_rect(Rect::new(0.0, 0.0, 50.0, 25.0), 4.0.into(), Color::GREEN.into());
// Get commands for GPU execution
let commands = ctx.take_commands();Re-exports§
pub use context::PaintContext;pub use path::PathBuilder;pub use primitives::shadow_presets;pub use primitives::Circle;pub use primitives::Ellipse;pub use primitives::RoundedRect;
Modules§
- color
- Color types - re-exported from blinc_core
- context
- Paint context - Canvas-like drawing API implementing DrawContext
- gradient
- Gradient fills - re-exported from blinc_core for unified type system
- path
- Path building and representation
- primitives
- Geometric primitives
Structs§
- Color
- RGBA color (linear space)
- Corner
Radius - Corner radii for rounded rectangles
- Gradient
Stop - Gradient stop
- Path
- A vector path
- Point
- 2D point
- Rect
- 2D rectangle
- Shadow
- Shadow configuration
- Size
- 2D size
- Stroke
- Stroke style configuration
- Text
Style - Text style configuration
Enums§
- Brush
- Brush for filling shapes
- Draw
Command - A draw command that can be recorded and replayed
- Gradient
- Gradient type
- LineCap
- Line cap style
- Line
Join - Line join style
- Path
Command - Path command for building vector paths
- Transform
- Unified transform that can represent 2D or 3D transformations
Traits§
- Draw
Context - Unified drawing context that adapts to the current layer type
- Draw
Context Ext - Extension trait for DrawContext that provides ergonomic generic methods