Struct lyon_geom::LineSegment
source · pub struct LineSegment<S> {
pub from: Point<S>,
pub to: Point<S>,
}
Expand description
A linear segment.
Fields§
§from: Point<S>
§to: Point<S>
Implementations§
source§impl<S: Scalar> LineSegment<S>
impl<S: Scalar> LineSegment<S>
sourcepub fn x(&self, t: S) -> S
pub fn x(&self, t: S) -> S
Sample the x coordinate of the segment at t (expecting t between 0 and 1).
sourcepub fn y(&self, t: S) -> S
pub fn y(&self, t: S) -> S
Sample the y coordinate of the segment at t (expecting t between 0 and 1).
pub fn from(&self) -> Point<S>
pub fn to(&self) -> Point<S>
pub fn solve_t_for_x(&self, x: S) -> S
pub fn solve_t_for_y(&self, y: S) -> S
pub fn solve_y_for_x(&self, x: S) -> S
pub fn solve_x_for_y(&self, y: S) -> S
sourcepub fn flip(&self) -> Self
pub fn flip(&self) -> Self
Returns an inverted version of this segment where the beginning and the end points are swapped.
sourcepub fn split_range(&self, t_range: Range<S>) -> Self
pub fn split_range(&self, t_range: Range<S>) -> Self
Return the sub-segment inside a given range of t.
This is equivalent splitting at the range’s end points.
sourcepub fn split(&self, t: S) -> (Self, Self)
pub fn split(&self, t: S) -> (Self, Self)
Split this curve into two sub-segments.
sourcepub fn before_split(&self, t: S) -> Self
pub fn before_split(&self, t: S) -> Self
Return the segment before the split point.
sourcepub fn after_split(&self, t: S) -> Self
pub fn after_split(&self, t: S) -> Self
Return the segment after the split point.
pub fn split_at_x(&self, x: S) -> (Self, Self)
sourcepub fn bounding_box(&self) -> Box2D<S>
pub fn bounding_box(&self) -> Box2D<S>
Return the smallest rectangle containing this segment.
sourcepub fn bounding_rect(&self) -> Rect<S>
pub fn bounding_rect(&self) -> Rect<S>
Return the smallest rectangle containing this segment.
sourcepub fn to_vector(&self) -> Vector<S>
pub fn to_vector(&self) -> Vector<S>
Returns the vector between this segment’s from
and to
points.
sourcepub fn set_length(&mut self, new_length: S)
pub fn set_length(&mut self, new_length: S)
Changes the segment’s length, moving destination point.
pub fn translate(&mut self, by: Vector<S>) -> Self
sourcepub fn transformed<T: Transformation<S>>(&self, transform: &T) -> Self
pub fn transformed<T: Transformation<S>>(&self, transform: &T) -> Self
Applies the transform to this segment and returns the results.
sourcepub fn intersection_t(&self, other: &Self) -> Option<(S, S)>
pub fn intersection_t(&self, other: &Self) -> Option<(S, S)>
Computes the intersection (if any) between this segment and another one.
The result is provided in the form of the t
parameter of each
segment. To get the intersection point, sample one of the segments
at the corresponding value.
pub fn intersection(&self, other: &Self) -> Option<Point<S>>
pub fn line_intersection_t(&self, line: &Line<S>) -> Option<S>
pub fn line_intersection(&self, line: &Line<S>) -> Option<Point<S>>
pub fn horizontal_line_intersection_t(&self, y: S) -> Option<S>
pub fn vertical_line_intersection_t(&self, x: S) -> Option<S>
pub fn horizontal_line_intersection(&self, y: S) -> Option<Point<S>>
pub fn vertical_line_intersection(&self, x: S) -> Option<Point<S>>
pub fn intersects(&self, other: &Self) -> bool
pub fn intersects_line(&self, line: &Line<S>) -> bool
pub fn overlaps_line(&self, line: &Line<S>) -> bool
pub fn overlaps_segment(&self, other: &LineSegment<S>) -> bool
pub fn contains_segment(&self, other: &LineSegment<S>) -> bool
pub fn clipped_x(&self, clip: Range<S>) -> Option<Self>
pub fn clipped_y(&self, clip: Range<S>) -> Option<Self>
pub fn clipped(&self, clip: &Box2D<S>) -> Option<Self>
Trait Implementations§
source§impl<S: Clone> Clone for LineSegment<S>
impl<S: Clone> Clone for LineSegment<S>
source§fn clone(&self) -> LineSegment<S>
fn clone(&self) -> LineSegment<S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<S: Debug> Debug for LineSegment<S>
impl<S: Debug> Debug for LineSegment<S>
source§impl<S> From<LineSegment<S>> for BezierSegment<S>
impl<S> From<LineSegment<S>> for BezierSegment<S>
source§fn from(s: LineSegment<S>) -> Self
fn from(s: LineSegment<S>) -> Self
source§impl<S: PartialEq> PartialEq for LineSegment<S>
impl<S: PartialEq> PartialEq for LineSegment<S>
source§fn eq(&self, other: &LineSegment<S>) -> bool
fn eq(&self, other: &LineSegment<S>) -> bool
self
and other
values to be equal, and is used
by ==
.