Struct embedded_graphics::primitives::line::Line
source · pub struct Line {
pub start: Point,
pub end: Point,
}
Expand description
Line primitive
Examples
Create some lines with different styles
use embedded_graphics::{
pixelcolor::Rgb565, prelude::*, primitives::{Line, PrimitiveStyle},
};
// Red 1 pixel wide line from (50, 20) to (60, 35)
Line::new(Point::new(50, 20), Point::new(60, 35))
.into_styled(PrimitiveStyle::with_stroke(Rgb565::RED, 1))
.draw(&mut display)?;
// Green 10 pixel wide line with translation applied
Line::new(Point::new(50, 20), Point::new(60, 35))
.translate(Point::new(-30, 10))
.into_styled(PrimitiveStyle::with_stroke(Rgb565::GREEN, 10))
.draw(&mut display)?;
Fields§
§start: Point
Start point
end: Point
End point
Implementations§
Trait Implementations§
source§impl Dimensions for Line
impl Dimensions for Line
source§fn bounding_box(&self) -> Rectangle
fn bounding_box(&self) -> Rectangle
Returns the bounding box.
source§impl Ord for Line
impl Ord for Line
source§impl PartialEq<Line> for Line
impl PartialEq<Line> for Line
source§impl PartialOrd<Line> for Line
impl PartialOrd<Line> for Line
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PointsIter for Line
impl PointsIter for Line
source§impl Primitive for Line
impl Primitive for Line
source§fn into_styled<S>(self, style: S) -> Styled<Self, S>where
Self: Sized,
fn into_styled<S>(self, style: S) -> Styled<Self, S>where Self: Sized,
Converts this primitive into a
Styled
.source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Line
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Line
source§fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Line
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Line
source§fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error>where
D: DrawTarget<Color = C>,
fn draw_styled<D>( &self, style: &PrimitiveStyle<C>, target: &mut D ) -> Result<Self::Output, D::Error>where D: DrawTarget<Color = C>,
Draws the primitive using the given style.
source§impl Transform for Line
impl Transform for Line
source§fn translate(&self, by: Point) -> Self
fn translate(&self, by: Point) -> Self
Translate the line from its current position to a new position by (x, y) pixels, returning
a new Line
. For a mutating transform, see translate_mut
.
let line = Line::new(Point::new(5, 10), Point::new(15, 20));
let moved = line.translate(Point::new(10, 10));
assert_eq!(moved.start, Point::new(15, 20));
assert_eq!(moved.end, Point::new(25, 30));
source§fn translate_mut(&mut self, by: Point) -> &mut Self
fn translate_mut(&mut self, by: Point) -> &mut Self
Translate the line from its current position to a new position by (x, y) pixels.
let mut line = Line::new(Point::new(5, 10), Point::new(15, 20));
line.translate_mut(Point::new(10, 10));
assert_eq!(line.start, Point::new(15, 20));
assert_eq!(line.end, Point::new(25, 30));
impl Copy for Line
impl Eq for Line
impl StructuralEq for Line
impl StructuralPartialEq for Line
Auto Trait Implementations§
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.