[−][src]Struct embedded_graphics::primitives::polyline::Polyline
Polyline primitive
Creates an unfilled chained line shape.
Examples
Draw a "heartbeat" shaped polyline
This example draws a stylized cardiogram in a 5px 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, 5); 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]
pub fn bounding_box(&self) -> Rectangle
[src]
impl<'a> Eq for Polyline<'a>
[src]
impl<'a> Hash for Polyline<'a>
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub 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]
pub fn cmp(&self, other: &Polyline<'a>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<'a> PartialEq<Polyline<'a>> for Polyline<'a>
[src]
pub fn eq(&self, other: &Polyline<'a>) -> bool
[src]
pub fn ne(&self, other: &Polyline<'a>) -> bool
[src]
impl<'a> PartialOrd<Polyline<'a>> for Polyline<'a>
[src]
pub fn partial_cmp(&self, other: &Polyline<'a>) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Polyline<'a>) -> bool
[src]
pub fn le(&self, other: &Polyline<'a>) -> bool
[src]
pub fn gt(&self, other: &Polyline<'a>) -> bool
[src]
pub fn ge(&self, other: &Polyline<'a>) -> bool
[src]
impl<'a> PointsIter for Polyline<'a>
[src]
type Iter = Points<'a>
Iterator over all points inside the primitive.
pub fn points(&self) -> Self::Iter
[src]
impl<'a> Primitive for Polyline<'a>
[src]
pub 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]
pub 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));
pub 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> RefUnwindSafe for Polyline<'a>
impl<'a> Send for Polyline<'a>
impl<'a> Sync for Polyline<'a>
impl<'a> Unpin for Polyline<'a>
impl<'a> UnwindSafe for Polyline<'a>
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,
pub fn borrow_mut(&mut self) -> &mut T
[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>,
pub fn lossless_try_into(self) -> Option<Dst>
[src]
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
[src]
Dst: LossyFrom<Src>,
pub fn lossy_into(self) -> Dst
[src]
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
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>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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.
pub 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>,