[][src]Trait lyon_path::builder::SvgPathBuilder

pub trait SvgPathBuilder {
    pub fn move_to(&mut self, to: Point);
pub fn close(&mut self);
pub fn line_to(&mut self, to: Point);
pub fn quadratic_bezier_to(&mut self, ctrl: Point, to: Point);
pub fn cubic_bezier_to(&mut self, ctrl1: Point, ctrl2: Point, to: Point);
pub fn relative_move_to(&mut self, to: Vector);
pub fn relative_line_to(&mut self, to: Vector);
pub fn relative_quadratic_bezier_to(&mut self, ctrl: Vector, to: Vector);
pub fn relative_cubic_bezier_to(
        &mut self,
        ctrl1: Vector,
        ctrl2: Vector,
        to: Vector
    );
pub fn smooth_cubic_bezier_to(&mut self, ctrl2: Point, to: Point);
pub fn smooth_relative_cubic_bezier_to(&mut self, ctrl2: Vector, to: Vector);
pub fn smooth_quadratic_bezier_to(&mut self, to: Point);
pub fn smooth_relative_quadratic_bezier_to(&mut self, to: Vector);
pub fn horizontal_line_to(&mut self, x: f32);
pub fn relative_horizontal_line_to(&mut self, dx: f32);
pub fn vertical_line_to(&mut self, y: f32);
pub fn relative_vertical_line_to(&mut self, dy: f32);
pub fn arc_to(
        &mut self,
        radii: Vector,
        x_rotation: Angle,
        flags: ArcFlags,
        to: Point
    );
pub fn relative_arc_to(
        &mut self,
        radii: Vector,
        x_rotation: Angle,
        flags: ArcFlags,
        to: Vector
    ); pub fn reserve(&mut self, _endpoints: usize, _ctrl_points: usize) { ... }
pub fn add_polygon(&mut self, polygon: Polygon<'_, Point>) { ... } }

A path building interface that tries to stay close to SVG's path specification. https://svgwg.org/specs/paths/

Some of the wording in the documentation of this trait is borrowed from the SVG specification.

Unlike PathBuilder, implementations of this trait are expected to deal with various corners cases such as adding segments without starting a sub-path.

Required methods

pub fn move_to(&mut self, to: Point)[src]

Start a new sub-path at the given position.

Corresponding SVG command: M.

This command establishes a new initial point and a new current point. The effect is as if the "pen" were lifted and moved to a new location. If a sub-path is in progress, it is ended without being closed.

pub fn close(&mut self)[src]

ends the current sub-path by connecting it back to its initial point.

Corresponding SVG command: Z.

A straight line is drawn from the current point to the initial point of the current sub-path. The current position is set to the initial position of the sub-path that was closed.

pub fn line_to(&mut self, to: Point)[src]

Adds a line segment to the current sub-path.

Corresponding SVG command: L.

The segment starts at the builder's current position. If this is the very first command of the path (the builder therefore does not have a current position), the line_to command is replaced with a move_to(to).

pub fn quadratic_bezier_to(&mut self, ctrl: Point, to: Point)[src]

Adds a quadratic bézier segment to the current sub-path.

Corresponding SVG command: Q.

The segment starts at the builder's current position. If this is the very first command of the path (the builder therefore does not have a current position), the quadratic_bezier_to command is replaced with a move_to(to).

pub fn cubic_bezier_to(&mut self, ctrl1: Point, ctrl2: Point, to: Point)[src]

Adds a cubic bézier segment to the current sub-path.

Corresponding SVG command: C.

The segment starts at the builder's current position. If this is the very first command of the path (the builder therefore does not have a current position), the cubic_bezier_to command is replaced with a move_to(to).

pub fn relative_move_to(&mut self, to: Vector)[src]

Equivalent to move_to in relative coordinates.

Corresponding SVG command: m.

the provided coordinates are offsets relative to the current position of the builder.

pub fn relative_line_to(&mut self, to: Vector)[src]

Equivalent to line_to in relative coordinates.

Corresponding SVG command: l.

the provided coordinates are offsets relative to the current position of the builder.

pub fn relative_quadratic_bezier_to(&mut self, ctrl: Vector, to: Vector)[src]

Equivalent to quadratic_bezier_to in relative coordinates.

Corresponding SVG command: q.

the provided coordinates are offsets relative to the current position of the builder.

pub fn relative_cubic_bezier_to(
    &mut self,
    ctrl1: Vector,
    ctrl2: Vector,
    to: Vector
)
[src]

Equivalent to cubic_bezier_to in relative coordinates.

the provided coordinates are offsets relative to the current position of the builder.

pub fn smooth_cubic_bezier_to(&mut self, ctrl2: Point, to: Point)[src]

Equivalent to cubic_bezier_to with implicit first control point.

Corresponding SVG command: S.

The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. If there is no previous command or if the previous command was not a cubic bézier segment, the first control point is coincident with the current position.

pub fn smooth_relative_cubic_bezier_to(&mut self, ctrl2: Vector, to: Vector)[src]

Equivalent to smooth_cubic_bezier_to in relative coordinates.

Corresponding SVG command: s.

the provided coordinates are offsets relative to the current position of the builder.

pub fn smooth_quadratic_bezier_to(&mut self, to: Point)[src]

Equivalent to quadratic_bezier_to with implicit control point.

Corresponding SVG command: T.

The control point is assumed to be the reflection of the control point on the previous command relative to the current point. If there is no previous command or if the previous command was not a quadratic bézier segment, a line segment is added instead.

pub fn smooth_relative_quadratic_bezier_to(&mut self, to: Vector)[src]

Equivalent to smooth_quadratic_bezier_to in relative coordinates.

Corresponding SVG command: t.

the provided coordinates are offsets relative to the current position of the builder.

pub fn horizontal_line_to(&mut self, x: f32)[src]

Adds an horizontal line segment.

Corresponding SVG command: L.

Equivalent to line_to, using the y coordinate of the current position.

pub fn relative_horizontal_line_to(&mut self, dx: f32)[src]

Adds an horizontal line segment in relative coordinates.

Corresponding SVG command: l.

Equivalent to line_to, using the y coordinate of the current position. dx is the horizontal offset relative to the current position.

pub fn vertical_line_to(&mut self, y: f32)[src]

Adds a vertical line segment.

Corresponding SVG command: V.

Equivalent to line_to, using the x coordinate of the current position.

pub fn relative_vertical_line_to(&mut self, dy: f32)[src]

Adds a vertical line segment in relative coordinates.

Corresponding SVG command: v.

Equivalent to line_to, using the y coordinate of the current position. dy is the horizontal offset relative to the current position.

pub fn arc_to(
    &mut self,
    radii: Vector,
    x_rotation: Angle,
    flags: ArcFlags,
    to: Point
)
[src]

Adds an elliptical arc.

Corresponding SVG command: A.

The arc starts at the current point and ends at to. The size and orientation of the ellipse are defined by radii and an x_rotation, which indicates how the ellipse as a whole is rotated relative to the current coordinate system. The center of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. the arc flags contribute to the automatic calculations and help determine how the arc is built.

pub fn relative_arc_to(
    &mut self,
    radii: Vector,
    x_rotation: Angle,
    flags: ArcFlags,
    to: Vector
)
[src]

Equivalent to arc_to in relative coordinates.

Corresponding SVG command: a.

the provided to coordinates are offsets relative to the current position of the builder.

Loading content...

Provided methods

pub fn reserve(&mut self, _endpoints: usize, _ctrl_points: usize)[src]

Hints at the builder that a certain number of endpoints and control points will be added.

The Builder implementation may use this information to pre-allocate memory as an optimization.

pub fn add_polygon(&mut self, polygon: Polygon<'_, Point>)[src]

Adds a sub-path from a polygon.

There must be no sub-path in progress when this method is called. No sub-path is in progress after the method is called.

Loading content...

Implementors

impl<Builder: PathBuilder> SvgPathBuilder for WithSvg<Builder>[src]

Loading content...