Macro embedded_graphics::egtriangle
source ยท macro_rules! egtriangle { (($x1:expr, $y1:expr), ($x2:expr, $y2:expr), ($x3:expr, $y3:expr) $(, $style_key:ident = $style_value:expr )* $(,)?) => { ... }; }
Expand description
Create a Triangle with optional styling using a
convenient macro.
use embedded_graphics::{egtriangle, style::Style, primitives::Triangle};
let empty_triangle: Triangle<u8> = egtriangle!((10, 20), (30, 40), (50, 60));
let filled_triangle: Triangle<u8> = egtriangle!((10, 20), (30, 40), (50, 60), stroke = Some(5u8), fill = Some(10u8));
let triangle_default_style: Triangle<u8> = egtriangle!((10, 20), (30, 40), (50, 60), style = Style::default());Style properties like stroke map to the method calls on the
WithStyle trait. For example, the following code makes two
identical triangles:
use embedded_graphics::prelude::*;
use embedded_graphics::{egtriangle, style::Style, primitives::Triangle};
let Triangle: Triangle<u8> = egtriangle!((10, 20), (30, 40), (50, 60), stroke = Some(5u8), fill = Some(10u8));
let Triangle: Triangle<u8> = Triangle::new(Coord::new(10, 20), Coord::new(30, 40), Coord::new(50, 60))
.stroke(Some(5u8))
.fill(Some(10u8));