[−][src]Struct embedded_graphics::primitives::triangle::Triangle
Triangle primitive
Examples
The macro examples make for more concise code.
Create some triangles with different styles
use embedded_graphics::prelude::*; use embedded_graphics::primitives::Triangle; // Default triangle with no styling let t1 = Triangle::new(Coord::new(10, 20), Coord::new(30, 40), Coord::new(50, 60)); // Triangle with styled stroke from (50, 20) to (60, 35) let t2 = Triangle::new(Coord::new(50, 20), Coord::new(60, 35), Coord::new(70, 80)) .stroke(Some(5u8)); // Triangle with translation applied let t3 = Triangle::new(Coord::new(50, 20), Coord::new(60, 35), Coord::new(70, 80)) .translate(Coord::new(65, 35)); display.draw(t1); display.draw(t2); display.draw(t3);
Fields
p1: Coord
First point of the triangle
p2: Coord
Second point of the triangle
p3: Coord
Third point of the triangle
style: Style<C>
Object style
Methods
impl<C> Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
Trait Implementations
impl<C: Clone + PixelColor> Clone for Triangle<C>
[src]
fn clone(&self) -> Triangle<C>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<C: Copy + PixelColor> Copy for Triangle<C>
[src]
impl<C: Debug + PixelColor> Debug for Triangle<C>
[src]
impl<C> Dimensions for Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
fn top_left(&self) -> Coord
[src]
fn bottom_right(&self) -> Coord
[src]
fn size(&self) -> UnsignedCoord
[src]
impl<C> Drawable for Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C> IntoIterator for Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
type Item = Pixel<C>
The type of the elements being iterated over.
type IntoIter = TriangleIterator<C>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, C> IntoIterator for &'a Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
type Item = Pixel<C>
The type of the elements being iterated over.
type IntoIter = TriangleIterator<C>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<C> Primitive for Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
impl<C> Transform for Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
fn translate(&self, by: Coord) -> Self
[src]
Translate the triangle from its current position to a new position by (x, y) pixels,
returning a new Triangle
. For a mutating transform, see translate_mut
.
let tri = Triangle::new(Coord::new(5, 10), Coord::new(15, 20), Coord::new(8, 15)) let moved = tri.translate(Coord::new(10, 10)); assert_eq!(moved.p1, Coord::new(15, 20)); assert_eq!(moved.p2, Coord::new(25, 30)); assert_eq!(moved.p3, Coord::new(18, 25));
fn translate_mut(&mut self, by: Coord) -> &mut Self
[src]
Translate the triangle from its current position to a new position by (x, y) pixels.
let mut tri = Triangle::new(Coord::new(5, 10), Coord::new(15, 20), Coord::new(10, 15)) tri.translate_mut(Coord::new(10, 10)); assert_eq!(tri.p1, Coord::new(15, 20)); assert_eq!(tri.p2, Coord::new(25, 30)); assert_eq!(tri.p3, Coord::new(20, 25));
impl<C> WithStyle<C> for Triangle<C> where
C: PixelColor,
[src]
C: PixelColor,
Auto Trait Implementations
impl<C> Send for Triangle<C> where
C: Send,
C: Send,
impl<C> Sync for Triangle<C> where
C: Sync,
C: Sync,
impl<C> Unpin for Triangle<C> where
C: Unpin,
C: Unpin,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[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.
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>,