[][src]Struct embedded_graphics::primitives::polyline::Polyline

pub struct Polyline<'a> {
    pub translate: Point,
    pub vertices: &'a [Point],
}

Polyline primitive

Creates an unfilled chained line shape. Styles with a stroke width greater than 1px are not currently supported and will always render as a 1px wide line.

Examples

Draw a "heartbeat" shaped polyline

This example draws a stylized cardiogram in a 1px green stroke.

use embedded_graphics::{
    pixelcolor::Rgb565, prelude::*, primitives::Polyline, style::PrimitiveStyle,
};

// A "heartbeat" shaped polyline
let points: [Point; 10] = [
    Point::new(10, 64),
    Point::new(50, 64),
    Point::new(60, 44),
    Point::new(70, 64),
    Point::new(80, 64),
    Point::new(90, 74),
    Point::new(100, 10),
    Point::new(110, 84),
    Point::new(120, 64),
    Point::new(300, 64),
];

let line_style = PrimitiveStyle::with_stroke(Rgb565::GREEN, 1);

Polyline::new(&points)
    .into_styled(line_style)
    .draw(&mut display)?;

Fields

translate: Point

An offset to apply to the polyline as a whole

vertices: &'a [Point]

All vertices in the line

Implementations

impl<'a> Polyline<'a>[src]

pub const fn new(vertices: &'a [Point]) -> Self[src]

Create a new polyline from a list of vertices

If fewer than two vertices are provided, the line will not render anything when drawn.

Trait Implementations

impl<'a> Clone for Polyline<'a>[src]

impl<'a> Copy for Polyline<'a>[src]

impl<'a> Debug for Polyline<'a>[src]

impl<'a> Default for Polyline<'a>[src]

impl<'a> Dimensions for Polyline<'a>[src]

impl<'a> Eq for Polyline<'a>[src]

impl<'a> Hash for Polyline<'a>[src]

impl<'a> Ord for Polyline<'a>[src]

impl<'a> PartialEq<Polyline<'a>> for Polyline<'a>[src]

impl<'a> PartialOrd<Polyline<'a>> for Polyline<'a>[src]

impl<'a> Primitive for Polyline<'a>[src]

type PointsIter = Points<'a>

Iterator over all points inside the primitive.

impl<'a> StructuralEq for Polyline<'a>[src]

impl<'a> StructuralPartialEq for Polyline<'a>[src]

impl<'a> Transform for Polyline<'a>[src]

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

Translate the polyline from its current position to a new position by (x, y) pixels, returning a new Polyline. For a mutating transform, see translate_mut.

let points = [
    Point::new(5, 10),
    Point::new(7, 7),
    Point::new(5, 8),
    Point::new(10, 10),
];

let polyline = Polyline::new(&points);
let moved = polyline.translate(Point::new(10, 12));

assert_eq!(polyline.bounding_box().top_left, Point::new(5, 7));
assert_eq!(moved.bounding_box().top_left, Point::new(15, 19));

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

Translate the polyline from its current position to a new position by (x, y) pixels.

let points = [
    Point::new(5, 10),
    Point::new(7, 7),
    Point::new(5, 8),
    Point::new(10, 10),
];

let mut polyline = Polyline::new(&points);

polyline.translate_mut(Point::new(10, 12));

assert_eq!(polyline.bounding_box().top_left, Point::new(15, 19));

Auto Trait Implementations

impl<'a> Send for Polyline<'a>

impl<'a> Sync for Polyline<'a>

impl<'a> Unpin for Polyline<'a>

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> Dimensions for T where
    T: OriginDimensions
[src]

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

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

impl<Src, Dst> LosslessTryInto<Dst> for Src where
    Dst: LosslessTryFrom<Src>, 
[src]

impl<Src, Dst> LossyInto<Dst> for Src where
    Dst: LossyFrom<Src>, 
[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>,