Struct svgdom::PathBuilder
source · pub struct PathBuilder { /* private fields */ }
Expand description
A builder for Path
.
Examples
Ellipse to path:
use svgtypes::PathBuilder;
let (cx, cy, rx, ry) = (10.0, 20.0, 5.0, 8.0);
let path = PathBuilder::with_capacity(6)
.move_to(cx + rx, cy)
.arc_to(rx, ry, 0.0, false, true, cx, cy + ry)
.arc_to(rx, ry, 0.0, false, true, cx - rx, cy)
.arc_to(rx, ry, 0.0, false, true, cx, cy - ry)
.arc_to(rx, ry, 0.0, false, true, cx + rx, cy)
.close_path()
.finalize();
assert_eq!(path.to_string(), "M 15 20 A 5 8 0 0 1 10 28 A 5 8 0 0 1 5 20 \
A 5 8 0 0 1 10 12 A 5 8 0 0 1 15 20 Z");
Implementations
sourceimpl PathBuilder
impl PathBuilder
sourcepub fn new() -> PathBuilder
pub fn new() -> PathBuilder
Constructs a new builder.
sourcepub fn with_capacity(capacity: usize) -> PathBuilder
pub fn with_capacity(capacity: usize) -> PathBuilder
Constructs a new builder with a specified capacity.
sourcepub fn move_to(self, x: f64, y: f64) -> PathBuilder
pub fn move_to(self, x: f64, y: f64) -> PathBuilder
Appends a new absolute MoveTo segment.
sourcepub fn rel_move_to(self, x: f64, y: f64) -> PathBuilder
pub fn rel_move_to(self, x: f64, y: f64) -> PathBuilder
Appends a new relative MoveTo segment.
sourcepub fn close_path(self) -> PathBuilder
pub fn close_path(self) -> PathBuilder
Appends a new absolute ClosePath segment.
sourcepub fn rel_close_path(self) -> PathBuilder
pub fn rel_close_path(self) -> PathBuilder
Appends a new relative ClosePath segment.
sourcepub fn line_to(self, x: f64, y: f64) -> PathBuilder
pub fn line_to(self, x: f64, y: f64) -> PathBuilder
Appends a new absolute LineTo segment.
sourcepub fn rel_line_to(self, x: f64, y: f64) -> PathBuilder
pub fn rel_line_to(self, x: f64, y: f64) -> PathBuilder
Appends a new relative LineTo segment.
sourcepub fn hline_to(self, x: f64) -> PathBuilder
pub fn hline_to(self, x: f64) -> PathBuilder
Appends a new absolute HorizontalLineTo segment.
sourcepub fn rel_hline_to(self, x: f64) -> PathBuilder
pub fn rel_hline_to(self, x: f64) -> PathBuilder
Appends a new relative HorizontalLineTo segment.
sourcepub fn vline_to(self, y: f64) -> PathBuilder
pub fn vline_to(self, y: f64) -> PathBuilder
Appends a new absolute VerticalLineTo segment.
sourcepub fn rel_vline_to(self, y: f64) -> PathBuilder
pub fn rel_vline_to(self, y: f64) -> PathBuilder
Appends a new relative VerticalLineTo segment.
sourcepub fn curve_to(
self,
x1: f64,
y1: f64,
x2: f64,
y2: f64,
x: f64,
y: f64
) -> PathBuilder
pub fn curve_to(
self,
x1: f64,
y1: f64,
x2: f64,
y2: f64,
x: f64,
y: f64
) -> PathBuilder
Appends a new absolute CurveTo segment.
sourcepub fn rel_curve_to(
self,
x1: f64,
y1: f64,
x2: f64,
y2: f64,
x: f64,
y: f64
) -> PathBuilder
pub fn rel_curve_to(
self,
x1: f64,
y1: f64,
x2: f64,
y2: f64,
x: f64,
y: f64
) -> PathBuilder
Appends a new relative CurveTo segment.
sourcepub fn smooth_curve_to(self, x2: f64, y2: f64, x: f64, y: f64) -> PathBuilder
pub fn smooth_curve_to(self, x2: f64, y2: f64, x: f64, y: f64) -> PathBuilder
Appends a new absolute SmoothCurveTo segment.
sourcepub fn rel_smooth_curve_to(self, x2: f64, y2: f64, x: f64, y: f64) -> PathBuilder
pub fn rel_smooth_curve_to(self, x2: f64, y2: f64, x: f64, y: f64) -> PathBuilder
Appends a new relative SmoothCurveTo segment.
sourcepub fn quad_to(self, x1: f64, y1: f64, x: f64, y: f64) -> PathBuilder
pub fn quad_to(self, x1: f64, y1: f64, x: f64, y: f64) -> PathBuilder
Appends a new absolute QuadTo segment.
sourcepub fn rel_quad_to(self, x1: f64, y1: f64, x: f64, y: f64) -> PathBuilder
pub fn rel_quad_to(self, x1: f64, y1: f64, x: f64, y: f64) -> PathBuilder
Appends a new relative QuadTo segment.
sourcepub fn smooth_quad_to(self, x: f64, y: f64) -> PathBuilder
pub fn smooth_quad_to(self, x: f64, y: f64) -> PathBuilder
Appends a new absolute SmoothQuadTo segment.
sourcepub fn rel_smooth_quad_to(self, x: f64, y: f64) -> PathBuilder
pub fn rel_smooth_quad_to(self, x: f64, y: f64) -> PathBuilder
Appends a new relative SmoothQuadTo segment.
sourcepub fn arc_to(
self,
rx: f64,
ry: f64,
x_axis_rotation: f64,
large_arc: bool,
sweep: bool,
x: f64,
y: f64
) -> PathBuilder
pub fn arc_to(
self,
rx: f64,
ry: f64,
x_axis_rotation: f64,
large_arc: bool,
sweep: bool,
x: f64,
y: f64
) -> PathBuilder
Appends a new absolute ArcTo segment.
sourcepub fn rel_arc_to(
self,
rx: f64,
ry: f64,
x_axis_rotation: f64,
large_arc: bool,
sweep: bool,
x: f64,
y: f64
) -> PathBuilder
pub fn rel_arc_to(
self,
rx: f64,
ry: f64,
x_axis_rotation: f64,
large_arc: bool,
sweep: bool,
x: f64,
y: f64
) -> PathBuilder
Appends a new relative ArcTo segment.