Struct tiny_skia_path::PathBuilder
source · pub struct PathBuilder { /* private fields */ }
Expand description
A path builder.
Implementations§
source§impl 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 last_point(&self) -> Option<Point>
pub fn last_point(&self) -> Option<Point>
Returns the last point if any.
sourcepub fn push_rect(&mut self, rect: Rect)
pub fn push_rect(&mut self, rect: Rect)
Adds a rectangle contour.
The contour is closed and has a clock-wise direction.
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§
source§impl Clone for PathBuilder
impl Clone for PathBuilder
source§fn clone(&self) -> PathBuilder
fn clone(&self) -> PathBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PathBuilder
impl Debug for PathBuilder
source§impl Default for PathBuilder
impl Default for PathBuilder
source§fn default() -> PathBuilder
fn default() -> PathBuilder
Auto Trait Implementations§
impl Freeze for PathBuilder
impl RefUnwindSafe for PathBuilder
impl Send for PathBuilder
impl Sync for PathBuilder
impl Unpin for PathBuilder
impl UnwindSafe for PathBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)