pub struct Path<T> {
    pub path: Vec<T>,
}
Expand description

Path of generic points in 2D space

Fields

path: Vec<T>

T can be PointI32/PointF64, etc. (see src/point.rs).

Implementations

Creates a new 2D Path with no points

Creates a 2D Path with ‘points’ as its points

Adds a point to the end of the path

Removes the last point from the path and returns it, or None if it is empty.

Returns an iterator on the vector of points in the path

Returns the number of points in the path

Returns true if the path is empty, false otherwise

Convert a closed path to an open path. A clone of ‘self’ is returned untouched if ‘self’ is empty or open.

Convert an unclosed path to a closed path. A clone of ‘self’ is returned untouched if ‘self’ is empty or closed.

Applies an offset to all points in the path

Generates a string representation of the path in SVG format.

Takes a bool to indicate whether the end should be wrapped back to start.

An offset is specified to apply an offset to the display points (useful when displaying on canvas elements).

If close is true, assume the last point of the path repeats the first point

Path is a closed path (shape), but the reduce algorithm only reduces open paths. We divide the path into four sections, spliced at the extreme points (max-x max-y min-x min-y), and reduce each section individually. Thus the most simplified path consists of at least 4 points. This function assumes the last point of the path repeats the first point.

Returns a copy of self after Path Smoothing, preserving corners.

corner_threshold is specified in radians. outset_ratio is a real number >= 1.0. segment_length is specified in pixels (length unit in path coordinate system).

Returns a copy of self after Path Simplification:

First remove staircases then simplify by limiting penalties.

Converts outline of pixel cluster to path with Path Walker. Takes a bool representing the clockwiseness of traversal (useful in svg representation to represent holes). Takes an enum PathSimplifyMode which indicates the required operation:

  • Polygon - Walk path and simplify it
  • Otherwise - Walk path only

Returns a copy of self converted to PathF64

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.