Skip to main content

generate_gradient_text

Macro generate_gradient_text 

Source
macro_rules! generate_gradient_text {
    ($txt:expr, $gr:expr) => { ... };
    ($txt:expr, $gr:expr, $bgtype:expr) => { ... };
}
Expand description

§Macro for generating gradient text that returns a Vec<Span> with the inputted gradient.

§Parameters

  1. any type that can be converted to Line (String, Line, &str, Vec)
  2. a colorgrad gradient (can be either Box or an owned type)
    let gradient_text = generate_gradient_text!("Rainbow Text", colorgrad::preset::rainbow());
    // displays "Rainbow Text" with a rainbow gradient
    buf.set_line(1, 1, &gradient_text, gradient_text.width())