Struct rten_imageproc::Line
source · pub struct Line<T: Coord = i32> {
pub start: Point<T>,
pub end: Point<T>,
}
Expand description
A bounded line segment defined by a start and end point.
Fields§
§start: Point<T>
§end: Point<T>
Implementations§
source§impl<T: Coord> Line<T>
impl<T: Coord> Line<T>
pub fn from_endpoints(start: Point<T>, end: Point<T>) -> Line<T>
sourcepub fn width(&self) -> T
pub fn width(&self) -> T
Return the difference between the starting and ending X coordinates of the line.
sourcepub fn height(&self) -> T
pub fn height(&self) -> T
Return the difference between the starting and ending Y coordinates of the line.
sourcepub fn is_horizontal(&self) -> bool
pub fn is_horizontal(&self) -> bool
Return true if the Y coordinate of the line’s start and end points are the same.
sourcepub fn reverse(&self) -> Line<T>
pub fn reverse(&self) -> Line<T>
Return a copy of this line with the start and end points swapped.
sourcepub fn downwards(&self) -> Line<T>
pub fn downwards(&self) -> Line<T>
Return a copy of this line with the same endpoints but swapped if
needed so that end.y >= start.y
.
sourcepub fn rightwards(&self) -> Line<T>
pub fn rightwards(&self) -> Line<T>
Return a copy of this line with the same endpoints but swapped if
needed so that end.x >= start.x
.
sourcepub fn vertical_overlap(&self, other: Line<T>) -> T
pub fn vertical_overlap(&self, other: Line<T>) -> T
Return the number of pixels by which this line overlaps other
in the
vertical direction.
sourcepub fn horizontal_overlap(&self, other: Line<T>) -> T
pub fn horizontal_overlap(&self, other: Line<T>) -> T
Return the number of pixels by which this line overlaps other
in the
horizontal direction.
source§impl Line<f32>
impl Line<f32>
sourcepub fn distance(&self, p: PointF) -> f32
pub fn distance(&self, p: PointF) -> f32
Return the euclidean distance between a point and the closest coordinate that lies on the line.
sourcepub fn intersects(&self, other: Line<f32>) -> bool
pub fn intersects(&self, other: Line<f32>) -> bool
Test whether this line segment intersects other
at a single point.
Returns false if the line segments do not intersect, or are coincident (ie. overlap for part of their lengths).
source§impl Line<f32>
impl Line<f32>
sourcepub fn center(&self) -> PointF
pub fn center(&self) -> PointF
Return the midpoint between the start and end points of the line.
source§impl Line<i32>
impl Line<i32>
pub fn to_f32(&self) -> LineF
sourcepub fn distance(&self, p: Point) -> f32
pub fn distance(&self, p: Point) -> f32
Return the euclidean distance between a point and the closest coordinate that lies on the line.
sourcepub fn intersects(&self, other: Line) -> bool
pub fn intersects(&self, other: Line) -> bool
Test whether this line segment intersects other
at a single point.
Returns false if the line segments do not intersect, or are coincident (ie. overlap for part of their lengths).