API ReferencePainting & Animation
Paint
Immutable paint builder with brush, stroke, blend, and filter options.
Small immutable builder over brush, stroke, blend, and color filter. Default:
solid black fill, 1 px butt/miter stroke, SrcOver, no filter.
| Setter | Type | Default |
|---|---|---|
brush / color / shader | Brush | Solid black |
style | Fill / Stroke | Fill |
stroke_width | f32, sanitized finite >= 0 | 1.0 |
blend_mode | BlendMode | SrcOver |
color_filter | Option<ColorFilter`>`` | None |
use incular::prelude::*;
use std::sync::Arc;
fn main() {
let paint = Paint::new()
.color(Color::rgba(200, 30, 30, 255))
.stroke_width(2.0)
.blend_mode(BlendMode::Multiply);
println!("width: {}", paint.stroke_value().width);
let mut b = Path::builder();
b.move_to(Offset::new(10.0, 10.0));
b.line_to(Offset::new(190.0, 110.0));
b.close();
let path = Arc::new(b.build());
let app = Application::new(move |_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(CustomPaint::new(
Size::new(200.0, 120.0),
{
let mut canvas = Canvas::default();
canvas.draw_path(path.clone(), &paint, FillRule::NonZero);
canvas.finish()
},
))
.build()
.into()
})
.expect("valid application");
incular::run(app).expect("run application");
}PaintStyle: Fill (default) / Stroke. Stroke { width: 1.0, cap: Butt, join: Miter, miter_limit: 4.0 }. LineCap: Butt / Round / Square.
LineJoin: Miter / Round / Bevel.