lyon_path::builder

Trait PathBuilder

source
pub trait PathBuilder {
Show 20 methods // Required methods fn num_attributes(&self) -> usize; fn begin( &mut self, at: Point, custom_attributes: Attributes<'_>, ) -> EndpointId; fn end(&mut self, close: bool); fn line_to( &mut self, to: Point, custom_attributes: Attributes<'_>, ) -> EndpointId; fn quadratic_bezier_to( &mut self, ctrl: Point, to: Point, custom_attributes: Attributes<'_>, ) -> EndpointId; fn cubic_bezier_to( &mut self, ctrl1: Point, ctrl2: Point, to: Point, custom_attributes: Attributes<'_>, ) -> EndpointId; // Provided methods fn close(&mut self) { ... } fn reserve(&mut self, _endpoints: usize, _ctrl_points: usize) { ... } fn path_event(&mut self, event: PathEvent, attributes: Attributes<'_>) { ... } fn event(&mut self, event: Event<(Point, Attributes<'_>), Point>) { ... } fn add_polygon( &mut self, polygon: Polygon<'_, Point>, attributes: Attributes<'_>, ) { ... } fn add_point(&mut self, at: Point, attributes: Attributes<'_>) -> EndpointId { ... } fn add_line_segment( &mut self, line: &LineSegment<f32>, attributes: Attributes<'_>, ) -> (EndpointId, EndpointId) { ... } fn add_ellipse( &mut self, center: Point, radii: Vector, x_rotation: Angle, winding: Winding, attributes: Attributes<'_>, ) { ... } fn add_circle( &mut self, center: Point, radius: f32, winding: Winding, attributes: Attributes<'_>, ) where Self: Sized { ... } fn add_rectangle( &mut self, rect: &Box2D, winding: Winding, attributes: Attributes<'_>, ) { ... } fn add_rounded_rectangle( &mut self, rect: &Box2D, radii: &BorderRadii, winding: Winding, custom_attributes: Attributes<'_>, ) where Self: Sized { ... } fn flattened(self, tolerance: f32) -> Flattened<Self> where Self: Sized { ... } fn transformed<Transform>( self, transform: Transform, ) -> Transformed<Self, Transform> where Self: Sized, Transform: Transformation<f32> { ... } fn with_svg(self) -> WithSvg<Self> where Self: Sized { ... }
}
Expand description

The base path building interface.

Unlike SvgPathBuilder, this interface strictly requires sub-paths to be manually started and ended (See the begin and end methods). All positions are provided in absolute coordinates.

The goal of this interface is to abstract over simple and fast implementations that do not deal with corner cases such as adding segments without starting a sub-path.

More elaborate interfaces are built on top of the provided primitives. In particular, the SvgPathBuilder trait providing more permissive and richer interface is automatically implemented via the WithSvg adapter (See the with_svg method).

Required Methods§

source

fn num_attributes(&self) -> usize

source

fn begin(&mut self, at: Point, custom_attributes: Attributes<'_>) -> EndpointId

Starts a new sub-path at a given position.

There must be no sub-path in progress when this method is called. at becomes the current position of the sub-path.

source

fn end(&mut self, close: bool)

Ends the current sub path.

A sub-path must be in progress when this method is called. After this method is called, there is no sub-path in progress until begin is called again.

source

fn line_to( &mut self, to: Point, custom_attributes: Attributes<'_>, ) -> EndpointId

Adds a line segment to the current sub-path.

A sub-path must be in progress when this method is called.

source

fn quadratic_bezier_to( &mut self, ctrl: Point, to: Point, custom_attributes: Attributes<'_>, ) -> EndpointId

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

A sub-path must be in progress when this method is called.

source

fn cubic_bezier_to( &mut self, ctrl1: Point, ctrl2: Point, to: Point, custom_attributes: Attributes<'_>, ) -> EndpointId

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

A sub-path must be in progress when this method is called.

Provided Methods§

source

fn close(&mut self)

Closes the current sub path.

Shorthand for builder.end(true).

source

fn reserve(&mut self, _endpoints: usize, _ctrl_points: usize)

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.

source

fn path_event(&mut self, event: PathEvent, attributes: Attributes<'_>)

Applies the provided path event.

By default this calls one of begin, end, line, quadratic_bezier_segment, or cubic_bezier_segment according to the path event.

The requirements for each method apply to the corresponding event.

source

fn event(&mut self, event: Event<(Point, Attributes<'_>), Point>)

source

fn add_polygon( &mut self, polygon: Polygon<'_, Point>, attributes: Attributes<'_>, )

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.

source

fn add_point(&mut self, at: Point, attributes: Attributes<'_>) -> EndpointId

Adds a sub-path containing a single point.

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

source

fn add_line_segment( &mut self, line: &LineSegment<f32>, attributes: Attributes<'_>, ) -> (EndpointId, EndpointId)

Adds a sub-path containing a single line segment.

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

source

fn add_ellipse( &mut self, center: Point, radii: Vector, x_rotation: Angle, winding: Winding, attributes: Attributes<'_>, )

Adds a sub-path containing an ellipse.

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

source

fn add_circle( &mut self, center: Point, radius: f32, winding: Winding, attributes: Attributes<'_>, )
where Self: Sized,

Adds a sub-path containing a circle.

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

source

fn add_rectangle( &mut self, rect: &Box2D, winding: Winding, attributes: Attributes<'_>, )

Adds a sub-path containing a rectangle.

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

source

fn add_rounded_rectangle( &mut self, rect: &Box2D, radii: &BorderRadii, winding: Winding, custom_attributes: Attributes<'_>, )
where Self: Sized,

Adds a sub-path containing a rectangle.

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

source

fn flattened(self, tolerance: f32) -> Flattened<Self>
where Self: Sized,

Returns a builder that approximates all curves with sequences of line segments.

source

fn transformed<Transform>( self, transform: Transform, ) -> Transformed<Self, Transform>
where Self: Sized, Transform: Transformation<f32>,

Returns a builder that applies the given transformation to all positions.

source

fn with_svg(self) -> WithSvg<Self>
where Self: Sized,

Returns a builder that support SVG commands.

This must be called before starting to add any sub-path.

Implementors§

source§

impl PathBuilder for BuilderImpl

source§

impl PathBuilder for lyon_path::path::BuilderWithAttributes

source§

impl<'l> PathBuilder for Builder<'l>

source§

impl<'l> PathBuilder for lyon_path::path_buffer::BuilderWithAttributes<'l>

source§

impl<B: PathBuilder> PathBuilder for NoAttributes<B>

source§

impl<Builder, Transform> PathBuilder for Transformed<Builder, Transform>
where Builder: PathBuilder, Transform: Transformation<f32>,

source§

impl<Builder: PathBuilder> PathBuilder for Flattened<Builder>