Skip to main content

polyline

Macro polyline 

Source
macro_rules! polyline {
    (vlogger: $vlogger:expr, target: $target:expr, $surface:expr, $($arg:tt)+) => { ... };
    (vlogger: $vlogger:expr, $surface:expr, $($arg:tt)+) => { ... };
    (target: $target:expr, $surface:expr, $($arg:tt)+) => { ... };
    ($surface:expr, $($arg:tt)+) => { ... };
}
Expand description

Sends an open or closed polyline to the vlogger.

ยงExamples

use v_log::polyline;

// Points must be of the same type for arrays to work,
// but are only required to implement IntoIterator.
// They can be arbitrary dimension, but only the first 3 are used.
let pos1 = [3.234, -1.223];
let pos2 = [2.713, 0.577];
let pos3 = [6.283, 0.692];

// Draw a single line with thickness 5.0 and color `Base` from pos1 to pos2.
// The label may get displayed, but the size, position and and format is up
// to the vlogger implementation. E.g. it may only be displayed as a tooltip.
polyline!("main_surface", (pos1, pos2), 5.0, Base, "--", "Position is: x: {}, y: {}", pos1[0], pos1[1]);
polyline!("main_surface", (pos1, pos2), 5.0, Base, "->");
polyline!("main_surface", (pos1, pos2), 5.0, Base);
// Draw two connected lines (polyline). These can not be labelled in
// the macro, as a label on polylines is hard to control in implementations.
// If you need a label, consider drawing the first segment with a label.
polyline!("main_surface", [pos1, pos2, pos3], 5.0, Base, "--");
polyline!("main_surface", [pos1, pos2, pos3], 5.0, Base);
// Draw a triangle (polygon). These can be labelled and the label is placed
// in the centeroid of them. Note, this may not be inside of the polygon.
// The textsize of the label must be specified before the text.
polyline!("main_surface", closed: [pos1, pos2, pos3], 5.0, Base, "--", 12.0, "Position is: x: {}, y: {}", pos1[0], pos1[1]);
polyline!("main_surface", closed: [pos1, pos2, pos3], 5.0, Base, "_>");
polyline!("main_surface", closed: [pos1, pos2, pos3], 5.0, Base);