Struct visioncortex::Path
source · 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§
source§impl<T> Path<T>
impl<T> Path<T>
source§impl<T> Path<T>
impl<T> Path<T>
sourcepub fn to_svg_string(
&self,
close: bool,
offset: &T,
precision: Option<u32>
) -> String
pub fn to_svg_string( &self, close: bool, offset: &T, precision: Option<u32> ) -> String
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
source§impl<T> Path<Point2<T>>
impl<T> Path<Point2<T>>
sourcepub fn reduce(&self, tolerance: f64) -> Option<Self>
pub fn reduce(&self, tolerance: f64) -> Option<Self>
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.
source§impl Path<Point2<i32>>
impl Path<Point2<i32>>
sourcepub fn smooth(
&self,
corner_threshold: f64,
outset_ratio: f64,
segment_length: f64,
max_iterations: usize
) -> PathF64
pub fn smooth( &self, corner_threshold: f64, outset_ratio: f64, segment_length: f64, max_iterations: usize ) -> PathF64
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).
source§impl Path<Point2<i32>>
impl Path<Point2<i32>>
sourcepub fn simplify(&self, clockwise: bool) -> Self
pub fn simplify(&self, clockwise: bool) -> Self
Returns a copy of self after Path Simplification:
First remove staircases then simplify by limiting penalties.
sourcepub fn image_to_path(
image: &BinaryImage,
clockwise: bool,
mode: PathSimplifyMode
) -> PathI32
pub fn image_to_path( image: &BinaryImage, clockwise: bool, mode: PathSimplifyMode ) -> PathI32
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
sourcepub fn to_path_f64(&self) -> PathF64
pub fn to_path_f64(&self) -> PathF64
Returns a copy of self converted to PathF64