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