Struct tiny_skia::PathBuilder[][src]

pub struct PathBuilder { /* fields omitted */ }

A path builder.

Implementations

impl PathBuilder[src]

pub fn new() -> Self[src]

Creates a new builder.

pub fn with_capacity(verbs_capacity: usize, points_capacity: usize) -> Self[src]

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

pub fn from_rect(rect: Rect) -> Path[src]

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.

pub fn from_circle(cx: f32, cy: f32, radius: f32) -> Option<Path>[src]

Creates a new Path from a circle.

The contour is closed and has a clock-wise direction.

Returns None when:

  • radius <= 0
  • any value is not finite or really large

pub fn len(&self) -> usize[src]

Returns the current number of segments in the builder.

pub fn is_empty(&self) -> bool[src]

Checks if the builder has any segments added.

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

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.

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

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.

pub fn quad_to(&mut self, x1: f32, y1: f32, x: f32, y: f32)[src]

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.

pub fn cubic_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x: f32, y: f32)[src]

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.

pub fn close(&mut self)[src]

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.

pub fn push_rect(&mut self, x: f32, y: f32, w: f32, h: f32)[src]

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

pub fn push_circle(&mut self, x: f32, y: f32, r: f32)[src]

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

pub fn clear(&mut self)[src]

Reset the builder.

Memory is not deallocated.

pub fn finish(self) -> Option<Path>[src]

Finishes the builder and returns a Path.

Returns None when Path is empty or has invalid bounds.

Trait Implementations

impl Clone for PathBuilder[src]

impl Debug for PathBuilder[src]

impl Default for PathBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.