Struct visioncortex::Path[][src]

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

Path of generic points in 2D space

Fields

path: Vec<T>

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

Implementations

impl<T> Path<T>[src]

pub fn new() -> Self[src]

Creates a new 2D Path with no points

pub fn add(&mut self, point: T)[src]

Adds a point to the end of the path

pub fn iter(&self) -> Iter<'_, T>[src]

Returns an iterator on the vector of points in the path

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

Returns the number of points in the path

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

Returns true if the path is empty, false otherwise

impl<T> Path<T> where
    T: AddAssign + Copy
[src]

pub fn offset(&mut self, o: &T)[src]

Applies an offset to all points in the path

impl<T> Path<T> where
    T: ToSvgString + Copy + Add<Output = T>, 
[src]

pub fn to_svg_string(&self, close: bool, offset: &T) -> String[src]

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

impl<T> Path<Point2<T>> where
    T: Add<Output = T> + Sub<Output = T> + Mul<Output = T> + PartialEq + PartialOrd + Copy + Into<f64>, 
[src]

pub fn reduce(&self, tolerance: f64) -> Option<Self>[src]

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.

impl Path<Point2<i32>>[src]

pub fn smooth(
    &self,
    corner_threshold: f64,
    outset_ratio: f64,
    segment_length: f64,
    max_iterations: usize
) -> PathF64
[src]

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

impl Path<Point2<f64>>[src]

pub fn smooth(
    &self,
    corner_threshold: f64,
    outset_ratio: f64,
    segment_length: f64,
    max_iterations: usize
) -> PathF64
[src]

impl Path<Point2<i32>>[src]

pub fn simplify(&self, clockwise: bool) -> Self[src]

Returns a copy of self after Path Simplification:

First remove staircases then simplify by limiting penalties.

pub fn image_to_path(
    image: &BinaryImage,
    clockwise: bool,
    mode: PathSimplifyMode
) -> PathI32
[src]

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

pub fn to_path_f64(&self) -> PathF64[src]

Returns a copy of self converted to PathF64

Trait Implementations

impl<T: Debug> Debug for Path<T>[src]

impl<T: Default> Default for Path<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Path<T> where
    T: RefUnwindSafe

impl<T> Send for Path<T> where
    T: Send

impl<T> Sync for Path<T> where
    T: Sync

impl<T> Unpin for Path<T> where
    T: Unpin

impl<T> UnwindSafe for Path<T> where
    T: UnwindSafe

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