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 PartialOrd for Line
impl PartialOrd for Line
source§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 StructuralPartialEq for Line
Auto Trait Implementations§
impl Freeze for Line
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnwindSafe for Line
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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.
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
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<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
§impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
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.