pub struct ILine { /* private fields */ }Expand description
A line segment represented by two points, in integer coordinates.
Implementations§
Source§impl ILine
impl ILine
pub const ZERO: Self
Sourcepub fn new<P>(start: P, end: P) -> Self
pub fn new<P>(start: P, end: P) -> Self
Creates a new line with the given start and end points.
Sourcepub fn length_squared(&self) -> f32
pub fn length_squared(&self) -> f32
Get the line’s length squared.
pub fn distance_squared_to_point(&self, p: Vec2) -> f32
pub fn distance_to_point(&self, p: Vec2) -> f32
Sourcepub fn rotate(&self, radians: f32) -> Self
pub fn rotate(&self, radians: f32) -> Self
Create a new line that is the rotation of this line around its start point, by the given radians.
Sourcepub fn rotate_around(&self, center: IVec2, radians: f32) -> Self
pub fn rotate_around(&self, center: IVec2, radians: f32) -> Self
Create a new line that is the rotation of this line around the given point, by the given radians.
Sourcepub fn flip(&self) -> Self
pub fn flip(&self) -> Self
Flip the orientation of the line such that the start point becomes the end point and vice versa.
pub fn is_vertical(&self) -> bool
pub fn is_horizontal(&self) -> bool
Sourcepub fn is_axis_aligned(&self) -> bool
pub fn is_axis_aligned(&self) -> bool
Determine if this line is axis-aligned.
Sourcepub fn axis_alignment(&self) -> Option<Direction>
pub fn axis_alignment(&self) -> Option<Direction>
Get the axis-aligned direction of this line, if it is axis-aligned, None otherwise.
Sourcepub fn diagonal_axis_alignment(&self) -> Option<Direction>
pub fn diagonal_axis_alignment(&self) -> Option<Direction>
Get the diagonal axis-aligned direction of this line, if it is diagonally axis-aligned, None otherwise.
Sourcepub fn intersects_line(&self, other: &ILine) -> Option<IVec2>
pub fn intersects_line(&self, other: &ILine) -> Option<IVec2>
Determine if this line intersects the given line.
Sourcepub fn intersects_rect(&self, rect: &IRect) -> bool
pub fn intersects_rect(&self, rect: &IRect) -> bool
Determine if this line intersects the edges of, or is contained within the given rectangle.
Sourcepub fn axis_aligned_intersect_rect(&self, rect: &IRect) -> Option<ILine>
pub fn axis_aligned_intersect_rect(&self, rect: &IRect) -> Option<ILine>
Obtain the segment of this line that intersects the given rectangle, if any, otherwise None.
This line must be axis-aligned, otherwise None is returned.
Sourcepub fn overlap(&self, other: &ILine) -> Option<ILine>
pub fn overlap(&self, other: &ILine) -> Option<ILine>
If this and the given line segments overlap, return the overlapping segment.
Otherwise, return None.
Sourcepub fn visit_points<F>(&self, visitor: F)
pub fn visit_points<F>(&self, visitor: F)
Use Bresenham’s line algorithm to visit points on this line.
pub fn pixels(&self) -> LinePixelIterator ⓘ
Trait Implementations§
impl Copy for ILine
impl Eq for ILine
impl StructuralPartialEq for ILine
Auto Trait Implementations§
impl Freeze for ILine
impl RefUnwindSafe for ILine
impl Send for ILine
impl Sync for ILine
impl Unpin for ILine
impl UnwindSafe for ILine
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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