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>

source

pub fn from_endpoints(start: Point<T>, end: Point<T>) -> Line<T>

source

pub fn is_empty(&self) -> bool

Return true if this line has zero length.

source

pub fn width(&self) -> T

Return the difference between the starting and ending X coordinates of the line.

source

pub fn height(&self) -> T

Return the difference between the starting and ending Y coordinates of the line.

source

pub fn is_horizontal(&self) -> bool

Return true if the Y coordinate of the line’s start and end points are the same.

source

pub fn reverse(&self) -> Line<T>

Return a copy of this line with the start and end points swapped.

source

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.

source

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.

source

pub fn vertical_overlap(&self, other: Line<T>) -> T

Return the number of pixels by which this line overlaps other in the vertical direction.

source

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>

source

pub fn distance(&self, p: PointF) -> f32

Return the euclidean distance between a point and the closest coordinate that lies on the line.

source

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>

source

pub fn center(&self) -> PointF

Return the midpoint between the start and end points of the line.

source

pub fn x_for_y(&self, y: f32) -> Option<f32>

Return the X coordinate that corresponds to a given Y coordinate on the line.

Returns None if the Y coordinate is not on the line or the line is horizontal.

source

pub fn y_for_x(&self, x: f32) -> Option<f32>

Return the Y coordinate that corresponds to a given X coordinate on the line.

Returns None if the X coordinate is not on the line or the line is vertical.

source§

impl Line<i32>

source

pub fn to_f32(&self) -> LineF

source

pub fn distance(&self, p: Point) -> f32

Return the euclidean distance between a point and the closest coordinate that lies on the line.

source

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).

Trait Implementations§

source§

impl<T: Coord> BoundingRect for Line<T>

§

type Coord = T

Coordinate type of bounding rect.
source§

fn bounding_rect(&self) -> Rect<T>

Return the smallest axis-aligned bounding rect which contains this shape.
source§

impl<T: Clone + Coord> Clone for Line<T>

source§

fn clone(&self) -> Line<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Coord> Debug for Line<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: PartialEq + Coord> PartialEq for Line<T>

source§

fn eq(&self, other: &Line<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Copy + Coord> Copy for Line<T>

source§

impl<T: Coord> StructuralPartialEq for Line<T>

Auto Trait Implementations§

§

impl<T> Freeze for Line<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Line<T>
where T: RefUnwindSafe,

§

impl<T> Send for Line<T>
where T: Send,

§

impl<T> Sync for Line<T>
where T: Sync,

§

impl<T> Unpin for Line<T>
where T: Unpin,

§

impl<T> UnwindSafe for Line<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.