pub enum Command {
MoveTo(f32, f32),
LineTo(f32, f32),
QuadTo(f32, f32, f32, f32),
CubicTo(f32, f32, f32, f32, f32, f32),
Close,
}Expand description
One resolved path segment, absolute.
Variants§
MoveTo(f32, f32)
Start a new subpath at this point.
LineTo(f32, f32)
Straight segment to this point.
QuadTo(f32, f32, f32, f32)
Quadratic segment: control point, then the on-curve endpoint.
CubicTo(f32, f32, f32, f32, f32, f32)
Cubic segment: two control points, then the on-curve endpoint.
Close
Close the current subpath. The line back to the subpath start is
implicit: the stored command list gains no synthetic LineTo, but
Path::area, Path::bbox, and every consumer of a
Path account for it.
Implementations§
Source§impl Command
impl Command
Sourcepub fn end_point(&self) -> Option<(f32, f32)>
pub fn end_point(&self) -> Option<(f32, f32)>
The on-curve point this command ends at (None for
Command::Close).
Sourcepub const fn move_to(x: f32, y: f32) -> Self
pub const fn move_to(x: f32, y: f32) -> Self
Command::MoveTo as a standalone command.
Sourcepub const fn line_to(x: f32, y: f32) -> Self
pub const fn line_to(x: f32, y: f32) -> Self
Command::LineTo as a standalone command.
Sourcepub const fn quad_to(cx: f32, cy: f32, x: f32, y: f32) -> Self
pub const fn quad_to(cx: f32, cy: f32, x: f32, y: f32) -> Self
Command::QuadTo as a standalone command.
Sourcepub const fn cubic_to(
c1x: f32,
c1y: f32,
c2x: f32,
c2y: f32,
x: f32,
y: f32,
) -> Self
pub const fn cubic_to( c1x: f32, c1y: f32, c2x: f32, c2y: f32, x: f32, y: f32, ) -> Self
Command::CubicTo as a standalone command.
Sourcepub const fn close() -> Self
pub const fn close() -> Self
Command::Close as a standalone command.
Sourcepub fn relative_to(&self, current: (f32, f32)) -> (u8, [f32; 6])
pub fn relative_to(&self, current: (f32, f32)) -> (u8, [f32; 6])
Rewrite this command as deltas from current, the point the segment
starts at: (opcode, [dx, dy, dx2, dy2]).
The model stores absolute commands; this is the relative view a writer
emits for delta-encoded contours. The array holds
[dx, dy, dx2, dy2, dx3, dy3] — control points and endpoint, each as a
delta from current; unused trailing slots are zero. Opcodes: 0 move,
1 line, 2 quad, 3 cubic, 4 close.