pub struct Line {
pub start: Point,
pub end: Point,
}
Expand description
Line primitive
§Examples
The macro examples make for more concise code.
§Create some lines with different styles
use embedded_graphics::{
pixelcolor::Rgb565, prelude::*, primitives::Line, style::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(65, 35))
.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§impl Ord for Line
impl Ord for Line
Source§impl PartialOrd for Line
impl PartialOrd for Line
Source§impl Primitive for Line
impl Primitive for Line
Source§fn into_styled<C>(
self,
style: PrimitiveStyle<C>,
) -> Styled<Self, PrimitiveStyle<C>>where
C: PixelColor,
Self: Sized,
fn into_styled<C>(
self,
style: PrimitiveStyle<C>,
) -> Styled<Self, PrimitiveStyle<C>>where
C: PixelColor,
Self: Sized,
Converts this primitive into a
Styled
.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§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes