Struct embedded_graphics::primitives::polyline::Polyline
source · [−]Expand description
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, 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
Trait Implementations
sourceimpl<'a> Dimensions for Polyline<'a>
impl<'a> Dimensions for Polyline<'a>
sourcefn bounding_box(&self) -> Rectangle
fn bounding_box(&self) -> Rectangle
Returns the bounding box.
sourceimpl<'a> Ord for Polyline<'a>
impl<'a> Ord for Polyline<'a>
sourceimpl<'a> PartialOrd<Polyline<'a>> for Polyline<'a>
impl<'a> PartialOrd<Polyline<'a>> for Polyline<'a>
sourcefn partial_cmp(&self, other: &Polyline<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &Polyline<'a>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'a> PointsIter for Polyline<'a>
impl<'a> PointsIter for Polyline<'a>
sourceimpl<'a> Primitive for Polyline<'a>
impl<'a> Primitive for Polyline<'a>
sourcefn into_styled<S>(self, style: S) -> Styled<Self, S> where
Self: Sized,
fn into_styled<S>(self, style: S) -> Styled<Self, S> where
Self: Sized,
Converts this primitive into a Styled
.
sourceimpl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
sourcefn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
fn styled_bounding_box(&self, style: &PrimitiveStyle<C>) -> Rectangle
Returns the bounding box using the given style.
sourceimpl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
type Color = C
type Color = C
Color type.
sourcefn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error> where
D: DrawTarget<Color = C>,
fn draw_styled<D>(
&self,
style: &PrimitiveStyle<C>,
target: &mut D
) -> Result<Self::Output, D::Error> where
D: DrawTarget<Color = C>,
Draws the primitive using the given style.
sourceimpl<'a> Transform for Polyline<'a>
impl<'a> Transform for Polyline<'a>
sourcefn translate(&self, by: Point) -> Self
fn translate(&self, by: Point) -> Self
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));
sourcefn translate_mut(&mut self, by: Point) -> &mut Self
fn translate_mut(&mut self, by: Point) -> &mut Self
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));
impl<'a> Copy for Polyline<'a>
impl<'a> Eq for Polyline<'a>
impl<'a> StructuralEq for Polyline<'a>
impl<'a> StructuralPartialEq for Polyline<'a>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcepub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
pub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcepub fn checked_cast_from(src: Src) -> Option<Dst>
pub fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcepub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcepub fn overflowing_cast_from(src: Src) -> (Dst, bool)
pub fn overflowing_cast_from(src: Src) -> (Dst, bool)
OverflowingCasts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcepub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
pub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcepub fn saturating_cast_from(src: Src) -> Dst
pub fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcepub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
pub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcepub fn unwrapped_cast_from(src: Src) -> Dst
pub fn unwrapped_cast_from(src: Src) -> Dst
UnwrappedCasts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcepub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
pub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcepub fn wrapping_cast_from(src: Src) -> Dst
pub fn wrapping_cast_from(src: Src) -> Dst
WrappingCasts the value.