Struct tiny_skia::PathBuilder
source · [−]pub struct PathBuilder { /* private fields */ }
Expand description
A path builder.
Implementations
sourceimpl PathBuilder
impl PathBuilder
sourcepub fn with_capacity(verbs_capacity: usize, points_capacity: usize) -> Self
pub fn with_capacity(verbs_capacity: usize, points_capacity: usize) -> Self
Creates a new builder with a specified capacity.
Number of points depends on a verb type:
- Move - 1
- Line - 1
- Quad - 2
- Cubic - 3
- Close - 0
sourcepub fn from_rect(rect: Rect) -> Path
pub fn from_rect(rect: Rect) -> Path
Creates a new Path
from Rect
.
Never fails since Rect
is always valid.
Segments are created clockwise: TopLeft -> TopRight -> BottomRight -> BottomLeft
The contour is closed.
sourcepub fn from_circle(cx: f32, cy: f32, radius: f32) -> Option<Path>
pub fn from_circle(cx: f32, cy: f32, radius: f32) -> Option<Path>
Creates a new Path
from a circle.
See PathBuilder::push_circle
for details.
sourcepub fn from_oval(oval: Rect) -> Option<Path>
pub fn from_oval(oval: Rect) -> Option<Path>
Creates a new Path
from an oval.
See PathBuilder::push_oval
for details.
sourcepub fn move_to(&mut self, x: f32, y: f32)
pub fn move_to(&mut self, x: f32, y: f32)
Adds beginning of a contour.
Multiple continuous MoveTo segments are not allowed. If the previous segment was also MoveTo, it will be overwritten with the current one.
sourcepub fn line_to(&mut self, x: f32, y: f32)
pub fn line_to(&mut self, x: f32, y: f32)
Adds a line from the last point.
- If
Path
is empty - adds Move(0, 0) first. - If
Path
ends with Close - adds Move(last_x, last_y) first.
sourcepub fn quad_to(&mut self, x1: f32, y1: f32, x: f32, y: f32)
pub fn quad_to(&mut self, x1: f32, y1: f32, x: f32, y: f32)
Adds a quad curve from the last point to x
, y
.
- If
Path
is empty - adds Move(0, 0) first. - If
Path
ends with Close - adds Move(last_x, last_y) first.
sourcepub fn cubic_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x: f32, y: f32)
pub fn cubic_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x: f32, y: f32)
Adds a cubic curve from the last point to x
, y
.
- If
Path
is empty - adds Move(0, 0) first. - If
Path
ends with Close - adds Move(last_x, last_y) first.
sourcepub fn close(&mut self)
pub fn close(&mut self)
Closes the current contour.
A closed contour connects the first and the last Point with a line, forming a continuous loop.
Does nothing when Path
is empty or already closed.
Open and closed contour will be filled the same way. Stroking an open contour will add LineCap at contour’s start and end. Stroking an closed contour will add LineJoin at contour’s start and end.
sourcepub fn push_rect(&mut self, x: f32, y: f32, w: f32, h: f32)
pub fn push_rect(&mut self, x: f32, y: f32, w: f32, h: f32)
Adds a rectangle contour.
The contour is closed and has a clock-wise direction.
Does nothing when:
- any value is not finite or really large
sourcepub fn push_oval(&mut self, oval: Rect)
pub fn push_oval(&mut self, oval: Rect)
Adds an oval contour bounded by the provided rectangle.
The contour is closed and has a clock-wise direction.
sourcepub fn push_circle(&mut self, x: f32, y: f32, r: f32)
pub fn push_circle(&mut self, x: f32, y: f32, r: f32)
Adds a circle contour.
The contour is closed and has a clock-wise direction.
Does nothing when:
radius
<= 0- any value is not finite or really large
Trait Implementations
sourceimpl Clone for PathBuilder
impl Clone for PathBuilder
sourcefn clone(&self) -> PathBuilder
fn clone(&self) -> PathBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PathBuilder
impl Debug for PathBuilder
sourceimpl Default for PathBuilder
impl Default for PathBuilder
sourcefn default() -> PathBuilder
fn default() -> PathBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for PathBuilder
impl Send for PathBuilder
impl Sync for PathBuilder
impl Unpin for PathBuilder
impl UnwindSafe for PathBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more