Macro zng::color::gradient::stops

source ·
macro_rules! stops {
    (($color:expr, $stop0:expr, $stop1:expr) $(,)?) => { ... };
    (($color:expr, $stop0:expr, $stop1:expr), $($stops:tt)+) => { ... };
    ($start:expr, $($stops:tt)+) => { ... };
}
Expand description

Creates a GradientStops containing the arguments.

A minimum of two arguments are required, the first and last argument must be expressions that convert to ColorStop, the middle arguments mut be expressions that convert to GradientStop.

§Examples

// green 0%, red 30%, blue 100%.
let stops = stops![colors::GREEN, (colors::RED, 30.pct()), colors::BLUE];

// green to blue, the midway color is at 30%.
let stops = stops![colors::GREEN, 30.pct(), colors::BLUE];

§Two Stops Per Color

The stops! macro also accepts a special 3 item tuple that represents a color followed by two offsets, this expands to two color stops of the same color. The color type must implement Into<Rgba> + Copy. The offset types must implement Into<Length>.

§Examples

let zebra_stops = stops![(colors::WHITE, 0, 20), (colors::BLACK, 20, 40)];