[][src]Macro embedded_graphics::line

macro_rules! line {
    (($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::{line, style::Style, primitives::Line};

let line: Line<u8> = line!((10, 20), (30, 40));
let stroke_line: Line<u8> = line!((10, 20), (30, 40), stroke = Some(5u8));

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::{line, style::Style, primitives::Line};

let Line: Line<u8> = line!((10, 20), (30, 40), stroke = Some(5u8), fill = Some(10u8));
let Line: Line<u8> = Line::new(Coord::new(10, 20), Coord::new(30, 40))
    .stroke(Some(5u8))
    .fill(Some(10u8));