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§
Implementations§
Source§impl EdgeSegment
impl EdgeSegment
Sourcepub fn line(p0: Vector2, p1: Vector2) -> EdgeSegment
pub fn line(p0: Vector2, p1: Vector2) -> EdgeSegment
Build a linear segment.
Sourcepub fn quadratic(p0: Vector2, p1: Vector2, p2: Vector2) -> EdgeSegment
pub fn quadratic(p0: Vector2, p1: Vector2, p2: Vector2) -> EdgeSegment
Build a quadratic, collapsing to a line if the control point is colinear.
Sourcepub fn cubic(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) -> EdgeSegment
pub fn cubic(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) -> EdgeSegment
Build a cubic, collapsing to a line or quadratic when degenerate.
Sourcepub fn control_points(&self) -> ([Vector2; 4], usize)
pub fn control_points(&self) -> ([Vector2; 4], usize)
Control points [0..=order], padded to a fixed array.
Sourcepub fn direction_change(&self, t: f64) -> Vector2
pub fn direction_change(&self, t: f64) -> Vector2
Second derivative direction (rate of tangent change) at parameter t.
Sourcepub fn signed_distance(&self, origin: Vector2) -> (SignedDistance, f64)
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, ¶m).
Sourcepub fn distance_to_perpendicular_distance(
&self,
distance: &mut SignedDistance,
origin: Vector2,
param: f64,
)
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.
Sourcepub fn scanline_intersections(&self, y: f64, out: &mut [(f64, i32); 3]) -> usize
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.
Sourcepub fn bound(&self, min: &mut Vector2, max: &mut Vector2)
pub fn bound(&self, min: &mut Vector2, max: &mut Vector2)
Expand (min, max) to include this segment’s bounding box.
Sourcepub fn move_start_point(&mut self, to: Vector2)
pub fn move_start_point(&mut self, to: Vector2)
Move the start point, adjusting controls (port of moveStartPoint).
Sourcepub fn move_end_point(&mut self, to: Vector2)
pub fn move_end_point(&mut self, to: Vector2)
Move the end point, adjusting controls (port of moveEndPoint).
Sourcepub fn split_in_thirds(&self) -> [EdgeSegment; 3]
pub fn split_in_thirds(&self) -> [EdgeSegment; 3]
Split into three equal-parameter thirds (used by Shape::normalize).
Sourcepub fn convert_to_cubic(&self) -> EdgeSegment
pub fn convert_to_cubic(&self) -> EdgeSegment
Promote a quadratic to an equivalent cubic (port of convertToCubic).
Trait Implementations§
Source§impl Clone for EdgeSegment
impl Clone for EdgeSegment
Source§fn clone(&self) -> EdgeSegment
fn clone(&self) -> EdgeSegment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EdgeSegment
Source§impl Debug for EdgeSegment
impl Debug for EdgeSegment
Source§impl PartialEq for EdgeSegment
impl PartialEq for EdgeSegment
Source§fn eq(&self, other: &EdgeSegment) -> bool
fn eq(&self, other: &EdgeSegment) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for EdgeSegment
Auto Trait Implementations§
impl Freeze for EdgeSegment
impl RefUnwindSafe for EdgeSegment
impl Send for EdgeSegment
impl Sync for EdgeSegment
impl Unpin for EdgeSegment
impl UnsafeUnpin for EdgeSegment
impl UnwindSafe for EdgeSegment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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