pub struct Line<N: Num = f32>(pub Point<N>, pub Point<N>);
Tuple Fields§
§0: Point<N>
§1: Point<N>
Implementations§
Source§impl<N: Num> Line<N>
impl<N: Num> Line<N>
pub fn new_from_points(points: &[N]) -> Self
pub fn new_zero_value() -> Self
pub fn start(self) -> Point<N>
pub fn end(self) -> Point<N>
pub fn min_point(self) -> Point<N>
pub fn max_point(self) -> Point<N>
pub fn left_x(self) -> N
pub fn right_x(self) -> N
pub fn bottom_y(self) -> N
pub fn top_y(self) -> N
pub fn is_empty(self) -> bool
pub fn is_horizontal(self) -> bool
pub fn is_vertical(self) -> bool
pub fn is_straight(self) -> bool
Sourcepub fn to<T: Num + From<N>>(&self) -> Line<T>
pub fn to<T: Num + From<N>>(&self) -> Line<T>
This is to allow creating a new Point, with a new type, from the type given.
i.e. Point::new(1 as u8, 1 as u8)::to::<u32>()
pub fn to_rect(self) -> Rect<N>
Sourcepub fn interpolation_point(self, n: N) -> Point<N>
pub fn interpolation_point(self, n: N) -> Point<N>
Where n
is a valid from 0.0 to 1.0,
this will return a point on the length of the line.
pub fn is_direction_negative_x(self) -> bool
pub fn is_direction_positive_x(self) -> bool
pub fn is_direction_negative_y(self) -> bool
pub fn is_direction_positive_y(self) -> bool
pub fn abs(&self) -> Self
pub fn min(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
pub fn min_x(self) -> N
pub fn min_y(self) -> N
pub fn max_x(self) -> N
pub fn max_y(self) -> N
pub fn overlaps_line(self, other: Line<N>) -> bool
pub fn overlaps_circle(self, other: Circle<N>) -> bool
pub fn intersect_line(self, other: Line<N>) -> Option<Point<N>>
Sourcepub fn intersect_rect(self, rect: Rect<N>) -> Option<Line<N>>
pub fn intersect_rect(self, rect: Rect<N>) -> Option<Line<N>>
Calculates if this overlaps another rectangle. If it does, it will return the part of the line that intersects within that rectangle.
None
is returned when no intersection is found.
pub fn direction(self) -> Size<f32>
pub fn hypot(self) -> N
pub fn hypot_sqrd(self) -> N
pub fn rotate(self, angle: f32) -> Self
pub fn rotate_around_zero(self, angle: f32) -> Self
pub fn rotate_around_point(self, angle: f32, target: Point<N>) -> Self
pub fn rotate_around_start(self, angle: f32) -> Self
pub fn rotate_around_end(self, angle: f32) -> Self
pub fn midpoint(self) -> Point<N>
Sourcepub fn flip(self) -> Self
pub fn flip(self) -> Self
Returns a line where the start is at the end, and the end is at the start.
pub fn into_iter_with_step(self, step: N) -> LineIterator<N> ⓘ
pub fn into_iter_inclusive(self) -> LineIterator<N> ⓘ
pub fn into_iter_inclusive_with_step(self, step: N) -> LineIterator<N> ⓘ
pub fn into_slice(self) -> [N; 4]
Source§impl<N: Num + ToSignedClamped> Line<N>
impl<N: Num + ToSignedClamped> Line<N>
pub fn to_signed_clamped(self) -> Line<<N as ToSignedClamped>::Output>
pub fn diff(self) -> Size<<N as ToSignedClamped>::Output>
pub fn x_diff(self) -> <N as ToSignedClamped>::Output
pub fn y_diff(self) -> <N as ToSignedClamped>::Output
pub fn slope(self) -> <N as ToSignedClamped>::Output
pub fn inverse_slope(self) -> <N as ToSignedClamped>::Output
pub fn step_direction(self) -> Point<<N as ToSignedClamped>::Output>
Trait Implementations§
Source§impl<N: Num> AddAssign<Point<N>> for Line<N>
impl<N: Num> AddAssign<Point<N>> for Line<N>
Source§fn add_assign(&mut self, other: Point<N>)
fn add_assign(&mut self, other: Point<N>)
Performs the
+=
operation. Read moreSource§impl<N: Num> AddAssign for Line<N>
impl<N: Num> AddAssign for Line<N>
Source§fn add_assign(&mut self, other: Line<N>)
fn add_assign(&mut self, other: Line<N>)
Performs the
+=
operation. Read moreSource§impl<N: Num> DivAssign<N> for Line<N>
impl<N: Num> DivAssign<N> for Line<N>
Source§fn div_assign(&mut self, other: N)
fn div_assign(&mut self, other: N)
Performs the
/=
operation. Read moreSource§impl<N: Num> DivAssign<Point<N>> for Line<N>
impl<N: Num> DivAssign<Point<N>> for Line<N>
Source§fn div_assign(&mut self, other: Point<N>)
fn div_assign(&mut self, other: Point<N>)
Performs the
/=
operation. Read moreSource§impl<N: Num> DivAssign<Size<N>> for Line<N>
impl<N: Num> DivAssign<Size<N>> for Line<N>
Source§fn div_assign(&mut self, other: Size<N>)
fn div_assign(&mut self, other: Size<N>)
Performs the
/=
operation. Read moreSource§impl<N: Num> DivAssign for Line<N>
impl<N: Num> DivAssign for Line<N>
Source§fn div_assign(&mut self, other: Line<N>)
fn div_assign(&mut self, other: Line<N>)
Performs the
/=
operation. Read moreSource§impl<N: Num> IntoIterator for Line<N>
impl<N: Num> IntoIterator for Line<N>
Source§impl<N: Num> MulAssign<N> for Line<N>
impl<N: Num> MulAssign<N> for Line<N>
Source§fn mul_assign(&mut self, other: N)
fn mul_assign(&mut self, other: N)
Performs the
*=
operation. Read moreSource§impl<N: Num> MulAssign<Point<N>> for Line<N>
impl<N: Num> MulAssign<Point<N>> for Line<N>
Source§fn mul_assign(&mut self, other: Point<N>)
fn mul_assign(&mut self, other: Point<N>)
Performs the
*=
operation. Read moreSource§impl<N: Num> MulAssign<Size<N>> for Line<N>
impl<N: Num> MulAssign<Size<N>> for Line<N>
Source§fn mul_assign(&mut self, other: Size<N>)
fn mul_assign(&mut self, other: Size<N>)
Performs the
*=
operation. Read moreSource§impl<N: Num> MulAssign for Line<N>
impl<N: Num> MulAssign for Line<N>
Source§fn mul_assign(&mut self, other: Line<N>)
fn mul_assign(&mut self, other: Line<N>)
Performs the
*=
operation. Read moreSource§impl<N: INum> ShlAssign<N> for Line<N>
impl<N: INum> ShlAssign<N> for Line<N>
Source§fn shl_assign(&mut self, other: N)
fn shl_assign(&mut self, other: N)
Performs the
<<=
operation. Read moreSource§impl<N: INum> ShrAssign<N> for Line<N>
impl<N: INum> ShrAssign<N> for Line<N>
Source§fn shr_assign(&mut self, other: N)
fn shr_assign(&mut self, other: N)
Performs the
>>=
operation. Read moreSource§impl<N: Num> SubAssign<Point<N>> for Line<N>
impl<N: Num> SubAssign<Point<N>> for Line<N>
Source§fn sub_assign(&mut self, other: Point<N>)
fn sub_assign(&mut self, other: Point<N>)
Performs the
-=
operation. Read moreSource§impl<N: Num> SubAssign for Line<N>
impl<N: Num> SubAssign for Line<N>
Source§fn sub_assign(&mut self, other: Line<N>)
fn sub_assign(&mut self, other: Line<N>)
Performs the
-=
operation. Read moreSource§impl<O: Num, N: Num + ToRounded<O>> ToRounded<Line<O>> for Line<N>
impl<O: Num, N: Num + ToRounded<O>> ToRounded<Line<O>> for Line<N>
Source§fn to_rounded(self) -> Line<O>
fn to_rounded(self) -> Line<O>
Returns the value in the new type, but clamped.
impl<N: Copy + Num> Copy for Line<N>
impl<N: Num> StructuralPartialEq for Line<N>
Auto Trait Implementations§
impl<N> Freeze for Line<N>where
N: Freeze,
impl<N> RefUnwindSafe for Line<N>where
N: RefUnwindSafe,
impl<N> Send for Line<N>where
N: Send,
impl<N> Sync for Line<N>where
N: Sync,
impl<N> Unpin for Line<N>where
N: Unpin,
impl<N> UnwindSafe for Line<N>where
N: UnwindSafe,
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
Mutably borrows from an owned value. Read more