Skip to main content

XPath

Struct XPath 

Source
pub struct XPath {
    pub segs: Vec<XPathSeg>,
    /* private fields */
}
Expand description

Matrix-transformed, flattened edge table derived from a Path.

§Construction pipeline

  1. Call XPath::new to build the edge table from a Path.
  2. Optionally call XPath::aa_scale once to scale coordinates by AA_SIZE for supersampled anti-aliasing.
  3. Hand the resulting XPath to XPathScanner for scan conversion.

Calling aa_scale more than once will multiply coordinates by AA_SIZE again, producing incorrect results. This is not checked at runtime.

Fields§

§segs: Vec<XPathSeg>

The flattened, transformed edge segments making up this path, in insertion order.

Implementations§

Source§

impl XPath

Source

pub fn new( path: &Path, matrix: &[f64; 6], flatness: f64, close_subpaths: bool, ) -> Self

Build an XPath from a Path by applying matrix and flattening curves.

§Arguments
  • path: the source path in user (pre-transform) space.
  • matrix: a 2-D affine transform [a, b, c, d, e, f] mapping user space to device space (column-vector convention; see module docs).
  • flatness: maximum chord deviation (in device pixels) for Bezier subdivision. Smaller values produce more accurate curves but more segments. Typical range: 0.11.0.
  • close_subpaths: if true, an implicit closing segment is added from the last point of each subpath back to its first point when they do not already coincide (matches SplashXPath constructor behaviour).
§Ordering constraints

After this call, segs is in insertion order (one entry per flattened edge). No further sorting is performed here; callers that need a sorted edge table must sort segs themselves or use XPathScanner.

Calling XPath::aa_scale after this method scales all coordinates by AA_SIZE. It must be called at most once.

Source

pub fn aa_scale(&mut self)

Scale all segment coordinates by AA_SIZE for supersampled anti-aliasing.

dxdy (the slope) is invariant under uniform scaling and is not modified — a uniform scale cancels out in (x1-x0)/(y1-y0).

Matches SplashXPath::aaScale().

§Ordering constraint

This method must be called after XPath::new and at most once. Calling it a second time multiplies coordinates by AA_SIZE again, which will produce incorrect scan-conversion results. There is no runtime guard against double-scaling.

§Panics

Does not panic in practice. However, if any coordinate is so large that multiplying by AA_SIZE would overflow to f64::INFINITY, subsequent scan-conversion arithmetic will silently produce wrong results. A debug_assert! fires in debug builds if any coordinate is non-finite before scaling.

Auto Trait Implementations§

§

impl Freeze for XPath

§

impl RefUnwindSafe for XPath

§

impl Send for XPath

§

impl Sync for XPath

§

impl Unpin for XPath

§

impl UnsafeUnpin for XPath

§

impl UnwindSafe for XPath

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> 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, 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.