Struct embedded_graphics::primitives::polyline::Polyline
source · pub struct Polyline<'a> {
pub translate: Point,
pub vertices: &'a [Point],
}
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§
source§impl<'a> Dimensions for Polyline<'a>
impl<'a> Dimensions for Polyline<'a>
source§fn bounding_box(&self) -> Rectangle
fn bounding_box(&self) -> Rectangle
Returns the bounding box.
source§impl<'a> Ord for Polyline<'a>
impl<'a> Ord for Polyline<'a>
source§impl<'a> PartialOrd for Polyline<'a>
impl<'a> PartialOrd for Polyline<'a>
source§impl<'a> PointsIter for Polyline<'a>
impl<'a> PointsIter for Polyline<'a>
source§impl<'a> Primitive for Polyline<'a>
impl<'a> Primitive for Polyline<'a>
source§fn 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
.source§impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDimensions<PrimitiveStyle<C>> for Polyline<'_>
source§fn 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.
source§impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
impl<C: PixelColor> StyledDrawable<PrimitiveStyle<C>> for Polyline<'_>
source§fn 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.
source§impl<'a> Transform for Polyline<'a>
impl<'a> Transform for Polyline<'a>
source§fn 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));
source§fn 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> StructuralPartialEq for Polyline<'a>
Auto Trait Implementations§
impl<'a> Freeze for Polyline<'a>
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
§impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.