[][src]Macro embedded_graphics::egline

macro_rules! egline {
    (($x1:expr, $y1:expr), ($x2:expr, $y2:expr) $(, $style_key:ident = $style_value:expr )* $(,)?) => { ... };
}

Create a Line with optional styling using a convenient macro.

Note that only the stroke property has any effect on lines currently.

use embedded_graphics::prelude::*;
use embedded_graphics::{egline, style::Style, primitives::Line, pixelcolor::Rgb565};

let line: Line<Rgb565> = egline!((10, 20), (30, 40));
let stroke_line: Line<Rgb565> = egline!((10, 20), (30, 40), stroke = Some(Rgb565::BLUE));

Style properties like stroke map to the method calls on the WithStyle trait. For example, the following code makes two identical lines:

use embedded_graphics::prelude::*;
use embedded_graphics::{egline, style::Style, primitives::Line, pixelcolor::Rgb565};

let Line: Line<Rgb565> = egline!((10, 20), (30, 40), stroke = Some(Rgb565::BLUE), fill = Some(Rgb565::YELLOW));
let Line: Line<Rgb565> = Line::new(Point::new(10, 20), Point::new(30, 40))
    .stroke(Some(Rgb565::BLUE))
    .fill(Some(Rgb565::YELLOW));