Skip to main content

EdgeSegment

Enum EdgeSegment 

Source
pub enum EdgeSegment {
    Line([Vector2; 2]),
    Quadratic([Vector2; 3]),
    Cubic([Vector2; 4]),
}
Expand description

An edge: linear (2 points), quadratic (3), or cubic (4 control points).

Variants§

§

Line([Vector2; 2])

§

Quadratic([Vector2; 3])

§

Cubic([Vector2; 4])

Implementations§

Source§

impl EdgeSegment

Source

pub fn line(p0: Vector2, p1: Vector2) -> EdgeSegment

Build a linear segment.

Source

pub fn quadratic(p0: Vector2, p1: Vector2, p2: Vector2) -> EdgeSegment

Build a quadratic, collapsing to a line if the control point is colinear.

Source

pub fn cubic(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) -> EdgeSegment

Build a cubic, collapsing to a line or quadratic when degenerate.

Source

pub fn order(&self) -> usize

Polynomial order: 1 = line, 2 = quadratic, 3 = cubic.

Source

pub fn control_points(&self) -> ([Vector2; 4], usize)

Control points [0..=order], padded to a fixed array.

Source

pub fn point(&self, t: f64) -> Vector2

Point on the curve at parameter t in [0,1].

Source

pub fn direction(&self, t: f64) -> Vector2

Tangent (unnormalized direction) at parameter t.

Source

pub fn direction_change(&self, t: f64) -> Vector2

Second derivative direction (rate of tangent change) at parameter t.

Source

pub fn length(&self) -> f64

Arc length of the segment.

Source

pub fn signed_distance(&self, origin: Vector2) -> (SignedDistance, f64)

Signed distance from origin to the segment, plus the parameter t of the nearest point. Mirrors signedDistance(origin, &param).

Source

pub fn distance_to_perpendicular_distance( &self, distance: &mut SignedDistance, origin: Vector2, param: f64, )

Converts a true signed distance to a perpendicular one when the closest point falls outside the [0,1] domain. Port of distanceToPerpendicularDistance.

Source

pub fn scanline_intersections(&self, y: f64, out: &mut [(f64, i32); 3]) -> usize

Horizontal scanline intersections at height y. Writes up to 3 (x, dy) pairs into out and returns the count. dy is the crossing direction.

Source

pub fn bound(&self, min: &mut Vector2, max: &mut Vector2)

Expand (min, max) to include this segment’s bounding box.

Source

pub fn reverse(&mut self)

Reverse the parameterization direction.

Source

pub fn move_start_point(&mut self, to: Vector2)

Move the start point, adjusting controls (port of moveStartPoint).

Source

pub fn move_end_point(&mut self, to: Vector2)

Move the end point, adjusting controls (port of moveEndPoint).

Source

pub fn split_in_thirds(&self) -> [EdgeSegment; 3]

Split into three equal-parameter thirds (used by Shape::normalize).

Source

pub fn convert_to_cubic(&self) -> EdgeSegment

Promote a quadratic to an equivalent cubic (port of convertToCubic).

Trait Implementations§

Source§

impl Clone for EdgeSegment

Source§

fn clone(&self) -> EdgeSegment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for EdgeSegment

Source§

impl Debug for EdgeSegment

Source§

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

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

impl PartialEq for EdgeSegment

Source§

fn eq(&self, other: &EdgeSegment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for EdgeSegment

Auto Trait Implementations§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

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.