Struct embedded_graphics::primitives::line::Line
source · pub struct Line<C: PixelColor> {
pub start: Coord,
pub end: Coord,
pub style: Style<C>,
}Expand description
Line primitive
§Examples
The macro examples make for more concise code.
§Create some lines with different styles
use embedded_graphics::prelude::*;
use embedded_graphics::primitives::Line;
// Default line from (10, 20) to (30, 40)
let l1 = Line::new(Coord::new(10, 20), Coord::new(30, 40));
// Line with styled stroke from (50, 20) to (60, 35)
let l2 = Line::new(Coord::new(50, 20), Coord::new(60, 35))
.stroke(Some(5u8));
// Line with translation applied
let l3 = Line::new(Coord::new(50, 20), Coord::new(60, 35))
.translate(Coord::new(65, 35));
display.draw(l1);
display.draw(l2);
display.draw(l3);Fields§
§start: CoordStart point
end: CoordEnd point
style: Style<C>Line style
Implementations§
Trait Implementations§
source§impl<C> Dimensions for Line<C>where
C: PixelColor,
impl<C> Dimensions for Line<C>where
C: PixelColor,
source§impl<'a, C: PixelColor> IntoIterator for &'a Line<C>
impl<'a, C: PixelColor> IntoIterator for &'a Line<C>
source§impl<C> IntoIterator for Line<C>where
C: PixelColor,
impl<C> IntoIterator for Line<C>where
C: PixelColor,
source§impl<C> Transform for Line<C>where
C: PixelColor,
impl<C> Transform for Line<C>where
C: PixelColor,
source§fn translate(&self, by: Coord) -> Self
fn translate(&self, by: Coord) -> 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(Coord::new(5, 10), Coord::new(15, 20))
let moved = line.translate(Coord::new(10, 10));
assert_eq!(moved.start, Coord::new(15, 20));
assert_eq!(moved.end, Coord::new(25, 30));source§fn translate_mut(&mut self, by: Coord) -> &mut Self
fn translate_mut(&mut self, by: Coord) -> &mut Self
Translate the line from its current position to a new position by (x, y) pixels.
let mut line = Line::new(Coord::new(5, 10), Coord::new(15, 20))
line.translate_mut(Coord::new(10, 10));
assert_eq!(line.start, Coord::new(15, 20));
assert_eq!(line.end, Coord::new(25, 30));source§impl<C> WithStyle<C> for Line<C>where
C: PixelColor,
impl<C> WithStyle<C> for Line<C>where
C: PixelColor,
source§fn stroke_width(self, width: u8) -> Self
fn stroke_width(self, width: u8) -> Self
Set the stroke width for the object Read more
impl<C: Copy + PixelColor> Copy for Line<C>
impl<C> Drawable for Line<C>where
C: PixelColor,
impl<C> Primitive for Line<C>where
C: PixelColor,
Auto Trait Implementations§
impl<C> Freeze for Line<C>where
C: Freeze,
impl<C> RefUnwindSafe for Line<C>where
C: RefUnwindSafe,
impl<C> Send for Line<C>where
C: Send,
impl<C> Sync for Line<C>where
C: Sync,
impl<C> Unpin for Line<C>where
C: Unpin,
impl<C> UnwindSafe for Line<C>where
C: 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§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 moresource§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).source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.