[−][src]Struct embedded_graphics::primitives::polyline::Polyline
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]
fn clone(&self) -> Polyline<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
fn bounding_box(&self) -> Rectangle
[src]
impl<'a> Eq for Polyline<'a>
[src]
impl<'a> Hash for Polyline<'a>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a> Ord for Polyline<'a>
[src]
fn cmp(&self, other: &Polyline<'a>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a> PartialEq<Polyline<'a>> for Polyline<'a>
[src]
impl<'a> PartialOrd<Polyline<'a>> for Polyline<'a>
[src]
fn partial_cmp(&self, other: &Polyline<'a>) -> Option<Ordering>
[src]
fn lt(&self, other: &Polyline<'a>) -> bool
[src]
fn le(&self, other: &Polyline<'a>) -> bool
[src]
fn gt(&self, other: &Polyline<'a>) -> bool
[src]
fn ge(&self, other: &Polyline<'a>) -> bool
[src]
impl<'a> Primitive for Polyline<'a>
[src]
type PointsIter = Points<'a>
Iterator over all points inside the primitive.
fn points(&self) -> Self::PointsIter
[src]
fn into_styled<C>(
self,
style: PrimitiveStyle<C>
) -> Styled<Self, PrimitiveStyle<C>> where
C: PixelColor,
Self: Sized,
[src]
self,
style: PrimitiveStyle<C>
) -> Styled<Self, PrimitiveStyle<C>> where
C: PixelColor,
Self: Sized,
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
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Dimensions for T where
T: OriginDimensions,
[src]
T: OriginDimensions,
fn bounding_box(&Self) -> Rectangle
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
[src]
Dst: LosslessTryFrom<Src>,
fn lossless_try_into(self) -> Option<Dst>
[src]
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
[src]
Dst: LossyFrom<Src>,
fn lossy_into(self) -> Dst
[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]
T: PartialEq<T> + Copy + Any + Debug,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,