Struct visioncortex::Spline

source ·
pub struct Spline {
    pub points: Vec<PointF64>,
}
Expand description

Series of connecting 2D Bezier Curves

Fields§

§points: Vec<PointF64>

1+3*(num_curves) points, where the first curve is represented by the first 4 points and each subsequent curve is represented by the last point in the previous curve plus 3 points Points are of PointF64 type.

Implementations§

source§

impl Spline

source

pub fn new(point: PointF64) -> Self

Creates an empty spline defined by a starting point

source

pub fn add(&mut self, point2: PointF64, point3: PointF64, point4: PointF64)

Adds a curve to the end of the spline. Takes 3 points that are the second to fourth control points of the bezier curve. Note that the first control point is taken from the last point of the previous curve.

source

pub fn iter(&self) -> Iter<'_, PointF64>

Returns an iterator on the vector of points on the spline

source

pub fn get_control_points(&self) -> Vec<&[PointF64]>

source

pub fn len(&self) -> usize

Returns the number of points on the spline

source

pub fn num_curves(&self) -> usize

Returns the number of curves on the spline

source

pub fn is_empty(&self) -> bool

Returns true if the spline contains no curve, false otherwise A curve is defined by 4 points, so a non-empty spline should contain at least 4 points.

source

pub fn offset(&mut self, offset: &PointF64)

Applies an offset to all points on the spline

source

pub fn from_image( image: &BinaryImage, clockwise: bool, corner_threshold: f64, outset_ratio: f64, segment_length: f64, max_iterations: usize, splice_threshold: f64 ) -> Self

Returns a spline created from image. The following steps are performed:

  1. Convert pixels into path
  2. Simplify the path into polygon
  3. Smoothen the polygon and approximate it with a curve-fitter

Corner/Splice thresholds are specified in radians. Length threshold is specified in pixels (length unit in path coordinate system).

source

pub fn from_path_f64(path: &PathF64, splice_threshold: f64) -> Self

Returns a spline by curve-fitting a path.

Splice threshold is specified in radians.

source

pub fn to_svg_string( &self, close: bool, offset: &PointF64, precision: Option<u32> ) -> String

Converts spline to svg path. Panic if the length of spline is not valid (not 1+3n for some integer n)

Trait Implementations§

source§

impl Clone for Spline

source§

fn clone(&self) -> Spline

Returns a copy 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 Spline

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Spline

source§

fn default() -> Spline

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

Auto Trait Implementations§

§

impl Freeze for Spline

§

impl RefUnwindSafe for Spline

§

impl Send for Spline

§

impl Sync for Spline

§

impl Unpin for Spline

§

impl UnwindSafe for Spline

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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.