[][src]Struct embedded_graphics::primitives::line::Line

pub struct Line {
    pub start: Point,
    pub end: Point,
}

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

Methods

impl Line[src]

pub const fn new(start: Point, end: Point) -> Self[src]

Create a new line

Trait Implementations

impl Clone for Line[src]

impl Copy for Line[src]

impl Debug for Line[src]

impl Default for Line[src]

impl Dimensions for Line[src]

impl Eq for Line[src]

impl Hash for Line[src]

impl Ord for Line[src]

impl PartialEq<Line> for Line[src]

impl PartialOrd<Line> for Line[src]

impl Primitive for Line[src]

impl StructuralEq for Line[src]

impl StructuralPartialEq for Line[src]

impl Transform for Line[src]

fn translate(&self, by: Point) -> Self[src]

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

fn translate_mut(&mut self, by: Point) -> &mut Self[src]

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

Auto Trait Implementations

impl Send for Line

impl Sync for Line

impl Unpin for Line

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: PartialEq<T> + Copy + Any + Debug
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,