[−][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::{ pixelcolor::Rgb565, prelude::*, primitives::Triangle, style::PrimitiveStyle, }; // Triangle with red 1 px wide stroke Triangle::new(Point::new(50, 20), Point::new(60, 35), Point::new(70, 80)) .into_styled(PrimitiveStyle::with_stroke(Rgb565::RED, 1)) .draw(&mut display)?; // Triangle with translation applied Triangle::new(Point::new(50, 20), Point::new(60, 35), Point::new(70, 80)) .translate(Point::new(65, 35)) .into_styled(PrimitiveStyle::with_stroke(Rgb565::GREEN, 1)) .draw(&mut display)?;
Create a triangle from an array of points
use embedded_graphics::{geometry::Point, primitives::Triangle}; let p1 = Point::new(5, 10); let p2 = Point::new(15, 25); let p3 = Point::new(5, 25); // Owned let tri = Triangle::from_points([p1, p2, p3]); // Or borrowed let tri_ref = Triangle::from_points(&[p1, p2, p3]);
Fields
p1: Point
First point of the triangle
p2: Point
Second point of the triangle
p3: Point
Third point of the triangle
Methods
impl Triangle
[src]
pub const fn new(p1: Point, p2: Point, p3: Point) -> Self
[src]
Create a new triangle with a given style
pub fn from_points<P, I>(points: P) -> Self where
I: Into<Point> + Copy,
P: Borrow<[I; 3]>,
[src]
I: Into<Point> + Copy,
P: Borrow<[I; 3]>,
Creates a new triangle from an array of points.
This supports both Point
s, as well as anything that implements Into<Point>
like
(i32, i32)
.
Trait Implementations
impl Clone for Triangle
[src]
fn clone(&self) -> Triangle
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Triangle
[src]
impl Debug for Triangle
[src]
impl Default for Triangle
[src]
impl Dimensions for Triangle
[src]
impl Eq for Triangle
[src]
impl Hash for Triangle
[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 Ord for Triangle
[src]
fn cmp(&self, other: &Triangle) -> 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 PartialEq<Triangle> for Triangle
[src]
impl PartialOrd<Triangle> for Triangle
[src]
fn partial_cmp(&self, other: &Triangle) -> Option<Ordering>
[src]
fn lt(&self, other: &Triangle) -> bool
[src]
fn le(&self, other: &Triangle) -> bool
[src]
fn gt(&self, other: &Triangle) -> bool
[src]
fn ge(&self, other: &Triangle) -> bool
[src]
impl Primitive for Triangle
[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 StructuralEq for Triangle
[src]
impl StructuralPartialEq for Triangle
[src]
impl Transform for Triangle
[src]
fn translate(&self, by: Point) -> 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(Point::new(5, 10), Point::new(15, 20), Point::new(8, 15)); let moved = tri.translate(Point::new(10, 10)); assert_eq!(moved.p1, Point::new(15, 20)); assert_eq!(moved.p2, Point::new(25, 30)); assert_eq!(moved.p3, Point::new(18, 25));
fn translate_mut(&mut self, by: Point) -> &mut Self
[src]
Translate the triangle from its current position to a new position by (x, y) pixels.
let mut tri = Triangle::new(Point::new(5, 10), Point::new(15, 20), Point::new(10, 15)); tri.translate_mut(Point::new(10, 10)); assert_eq!(tri.p1, Point::new(15, 20)); assert_eq!(tri.p2, Point::new(25, 30)); assert_eq!(tri.p3, Point::new(20, 25));
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,