Skip to main content

PathBuilder

Struct PathBuilder 

Source
pub struct PathBuilder { /* private fields */ }
Expand description

Builder for constructing paths from PDF path operators.

Coordinates are transformed through the CTM before storage.

Implementations§

Source§

impl PathBuilder

Source

pub fn stroke(&mut self, gs: &GraphicsState) -> PaintedPath

S operator: stroke the current path.

Paints the path outline using the current stroking color and line width. Clears the current path after painting.

Source

pub fn close_and_stroke(&mut self, gs: &GraphicsState) -> PaintedPath

s operator: close the current subpath, then stroke.

Equivalent to h S.

Source

pub fn fill(&mut self, gs: &GraphicsState) -> PaintedPath

f or F operator: fill the current path using the nonzero winding rule.

Any open subpaths are implicitly closed before filling.

Source

pub fn fill_even_odd(&mut self, gs: &GraphicsState) -> PaintedPath

f* operator: fill the current path using the even-odd rule.

Source

pub fn fill_and_stroke(&mut self, gs: &GraphicsState) -> PaintedPath

B operator: fill then stroke the current path (nonzero winding).

Source

pub fn fill_even_odd_and_stroke(&mut self, gs: &GraphicsState) -> PaintedPath

B* operator: fill (even-odd) then stroke the current path.

Source

pub fn close_fill_and_stroke(&mut self, gs: &GraphicsState) -> PaintedPath

b operator: close, fill (nonzero winding), then stroke.

Equivalent to h B.

Source

pub fn close_fill_even_odd_and_stroke( &mut self, gs: &GraphicsState, ) -> PaintedPath

b* operator: close, fill (even-odd), then stroke.

Equivalent to h B*.

Source

pub fn end_path(&mut self) -> Option<PaintedPath>

n operator: end the path without painting.

Discards the current path. Used primarily for clipping paths. Returns None since no painted path is produced.

Source§

impl PathBuilder

Source

pub fn new(ctm: Ctm) -> Self

Create a new PathBuilder with the given CTM.

Source

pub fn set_ctm(&mut self, ctm: Ctm)

Update the CTM.

Source

pub fn ctm(&self) -> &Ctm

Get the current CTM.

Source

pub fn move_to(&mut self, x: f64, y: f64)

m operator: move to a new point, starting a new subpath.

Source

pub fn line_to(&mut self, x: f64, y: f64)

l operator: straight line from current point to (x, y).

Source

pub fn curve_to(&mut self, x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64)

c operator: cubic Bezier curve with three coordinate pairs.

Source

pub fn curve_to_v(&mut self, x2: f64, y2: f64, x3: f64, y3: f64)

v operator: cubic Bezier where first control point equals current point.

Source

pub fn curve_to_y(&mut self, x1: f64, y1: f64, x3: f64, y3: f64)

y operator: cubic Bezier where last control point equals endpoint.

Source

pub fn close_path(&mut self)

h operator: close the current subpath.

Source

pub fn rectangle(&mut self, x: f64, y: f64, width: f64, height: f64)

re operator: append a rectangle as moveto + 3 lineto + closepath.

Source

pub fn current_point(&self) -> Option<Point>

Get the current point (already CTM-transformed).

Source

pub fn build(self) -> Path

Consume the builder and return the constructed path.

Source

pub fn is_empty(&self) -> bool

Check if the builder has no segments.

Source

pub fn take_and_reset(&mut self) -> Path

Take the accumulated segments as a Path and reset the builder.

After this call, the builder is empty and ready for a new path. The current point and subpath start are also reset.

Trait Implementations§

Source§

impl Clone for PathBuilder

Source§

fn clone(&self) -> PathBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PathBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.