pub trait PathBuilder {
Show 20 methods
// Required methods
fn num_attributes(&self) -> usize;
fn begin(
&mut self,
at: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId;
fn end(&mut self, close: bool);
fn line_to(
&mut self,
to: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId;
fn quadratic_bezier_to(
&mut self,
ctrl: Point2D<f32, UnknownUnit>,
to: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId;
fn cubic_bezier_to(
&mut self,
ctrl1: Point2D<f32, UnknownUnit>,
ctrl2: Point2D<f32, UnknownUnit>,
to: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId;
// Provided methods
fn close(&mut self) { ... }
fn reserve(&mut self, _endpoints: usize, _ctrl_points: usize) { ... }
fn path_event(
&mut self,
event: Event<Point2D<f32, UnknownUnit>, Point2D<f32, UnknownUnit>>,
attributes: &[f32],
) { ... }
fn event(
&mut self,
event: Event<(Point2D<f32, UnknownUnit>, &[f32]), Point2D<f32, UnknownUnit>>,
) { ... }
fn add_polygon(
&mut self,
polygon: Polygon<'_, Point2D<f32, UnknownUnit>>,
attributes: &[f32],
) { ... }
fn add_point(
&mut self,
at: Point2D<f32, UnknownUnit>,
attributes: &[f32],
) -> EndpointId { ... }
fn add_line_segment(
&mut self,
line: &LineSegment<f32>,
attributes: &[f32],
) -> (EndpointId, EndpointId) { ... }
fn add_ellipse(
&mut self,
center: Point2D<f32, UnknownUnit>,
radii: Vector2D<f32, UnknownUnit>,
x_rotation: Angle<f32>,
winding: Winding,
attributes: &[f32],
) { ... }
fn add_circle(
&mut self,
center: Point2D<f32, UnknownUnit>,
radius: f32,
winding: Winding,
attributes: &[f32],
)
where Self: Sized { ... }
fn add_rectangle(
&mut self,
rect: &Box2D<f32, UnknownUnit>,
winding: Winding,
attributes: &[f32],
) { ... }
fn add_rounded_rectangle(
&mut self,
rect: &Box2D<f32, UnknownUnit>,
radii: &BorderRadii,
winding: Winding,
custom_attributes: &[f32],
)
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§
fn num_attributes(&self) -> usize
sourcefn begin(
&mut self,
at: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId
fn begin( &mut self, at: Point2D<f32, UnknownUnit>, custom_attributes: &[f32], ) -> 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.
sourcefn end(&mut self, close: bool)
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.
sourcefn line_to(
&mut self,
to: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId
fn line_to( &mut self, to: Point2D<f32, UnknownUnit>, custom_attributes: &[f32], ) -> EndpointId
Adds a line segment to the current sub-path.
A sub-path must be in progress when this method is called.
sourcefn quadratic_bezier_to(
&mut self,
ctrl: Point2D<f32, UnknownUnit>,
to: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId
fn quadratic_bezier_to( &mut self, ctrl: Point2D<f32, UnknownUnit>, to: Point2D<f32, UnknownUnit>, custom_attributes: &[f32], ) -> EndpointId
Adds a quadratic bézier curve to the current sub-path.
A sub-path must be in progress when this method is called.
sourcefn cubic_bezier_to(
&mut self,
ctrl1: Point2D<f32, UnknownUnit>,
ctrl2: Point2D<f32, UnknownUnit>,
to: Point2D<f32, UnknownUnit>,
custom_attributes: &[f32],
) -> EndpointId
fn cubic_bezier_to( &mut self, ctrl1: Point2D<f32, UnknownUnit>, ctrl2: Point2D<f32, UnknownUnit>, to: Point2D<f32, UnknownUnit>, custom_attributes: &[f32], ) -> 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§
sourcefn reserve(&mut self, _endpoints: usize, _ctrl_points: usize)
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.
sourcefn path_event(
&mut self,
event: Event<Point2D<f32, UnknownUnit>, Point2D<f32, UnknownUnit>>,
attributes: &[f32],
)
fn path_event( &mut self, event: Event<Point2D<f32, UnknownUnit>, Point2D<f32, UnknownUnit>>, attributes: &[f32], )
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.
fn event( &mut self, event: Event<(Point2D<f32, UnknownUnit>, &[f32]), Point2D<f32, UnknownUnit>>, )
sourcefn add_polygon(
&mut self,
polygon: Polygon<'_, Point2D<f32, UnknownUnit>>,
attributes: &[f32],
)
fn add_polygon( &mut self, polygon: Polygon<'_, Point2D<f32, UnknownUnit>>, attributes: &[f32], )
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.
sourcefn add_point(
&mut self,
at: Point2D<f32, UnknownUnit>,
attributes: &[f32],
) -> EndpointId
fn add_point( &mut self, at: Point2D<f32, UnknownUnit>, attributes: &[f32], ) -> 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.
sourcefn add_line_segment(
&mut self,
line: &LineSegment<f32>,
attributes: &[f32],
) -> (EndpointId, EndpointId)
fn add_line_segment( &mut self, line: &LineSegment<f32>, attributes: &[f32], ) -> (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.
sourcefn add_ellipse(
&mut self,
center: Point2D<f32, UnknownUnit>,
radii: Vector2D<f32, UnknownUnit>,
x_rotation: Angle<f32>,
winding: Winding,
attributes: &[f32],
)
fn add_ellipse( &mut self, center: Point2D<f32, UnknownUnit>, radii: Vector2D<f32, UnknownUnit>, x_rotation: Angle<f32>, winding: Winding, attributes: &[f32], )
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.
sourcefn add_circle(
&mut self,
center: Point2D<f32, UnknownUnit>,
radius: f32,
winding: Winding,
attributes: &[f32],
)where
Self: Sized,
fn add_circle(
&mut self,
center: Point2D<f32, UnknownUnit>,
radius: f32,
winding: Winding,
attributes: &[f32],
)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.
sourcefn add_rectangle(
&mut self,
rect: &Box2D<f32, UnknownUnit>,
winding: Winding,
attributes: &[f32],
)
fn add_rectangle( &mut self, rect: &Box2D<f32, UnknownUnit>, winding: Winding, attributes: &[f32], )
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.
sourcefn add_rounded_rectangle(
&mut self,
rect: &Box2D<f32, UnknownUnit>,
radii: &BorderRadii,
winding: Winding,
custom_attributes: &[f32],
)where
Self: Sized,
fn add_rounded_rectangle(
&mut self,
rect: &Box2D<f32, UnknownUnit>,
radii: &BorderRadii,
winding: Winding,
custom_attributes: &[f32],
)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.
sourcefn flattened(self, tolerance: f32) -> Flattened<Self>where
Self: Sized,
fn flattened(self, tolerance: f32) -> Flattened<Self>where
Self: Sized,
Returns a builder that approximates all curves with sequences of line segments.
sourcefn transformed<Transform>(
self,
transform: Transform,
) -> Transformed<Self, Transform>
fn transformed<Transform>( self, transform: Transform, ) -> Transformed<Self, Transform>
Returns a builder that applies the given transformation to all positions.