enum
DrawCommand
pub enum DrawCommand {
Clear { w: f32, h: f32 },
Save,
Restore,
SetFill(String),
SetFillLinear { x0: f32, y0: f32, x1: f32, y1: f32, from: String, to: String },
SetFillRadial { x: f32, y: f32, r: f32, from: String, to: String },
SetStroke(String),
SetLineWidth(f32),
SetLineCap(String),
SetLineJoin(String),
SetShadow { blur: f32, color: String },
SetGlobalAlpha(f32),
SetFont(String),
SetTextAlign(String),
FillRect { x: f32, y: f32, w: f32, h: f32 },
StrokeRect { x: f32, y: f32, w: f32, h: f32 },
BeginPath,
MoveTo(f32, f32),
LineTo(f32, f32),
QuadTo(f32, f32, f32, f32),
BezierTo { c1x: f32, c1y: f32, c2x: f32, c2y: f32, x: f32, y: f32 },
Arc { cx: f32, cy: f32, r: f32, start: f32, end: f32, ccw: bool },
ClosePath,
Fill,
Stroke,
FillText { text: String, x: f32, y: f32 },
Image { src: String, tint: Option<String>, x: f32, y: f32, w: f32, h: f32 },
}One Canvas 2D API call.
Variants
SetFillLinear
SetFillLinear { x0: f32, y0: f32, x1: f32, y1: f32, from: String, to: String }fillStyle as a linear gradient.
SetFillRadial
SetFillRadial { x: f32, y: f32, r: f32, from: String, to: String }fillStyle as a radial gradient.
Arc
Arc { cx: f32, cy: f32, r: f32, start: f32, end: f32, ccw: bool }Angles in radians, canvas convention (0 = 3 o'clock).
Image
Image { src: String, tint: Option<String>, x: f32, y: f32, w: f32, h: f32 }An image by URL, drawn once loaded. An SVG with a tint has its colours replaced by it.