macro_rules! fg {
($r:expr, $g:expr, $b:expr $(,)?) => { ... };
}Expand description
Creates a true rgb foreground color. R, G and B must be values in range 0..256.
Equivalent to CSI 3 8 ; 2 ; Pr ; Pg ; Pb m.
If the argument is literal, this expands to [&'static str]. Otherwise this
expands to String.
Foreground color can be reset with RESET_FG or RESET. Note that
RESET will also reset all text modes.
§Example
use termal_core::{codes, raw::term_size, Error};
let mut buf = codes::CLEAR.to_string();
let size = term_size()?;
let w = size.char_width;
let h = size.char_height - 1;
let l = (w * h).isqrt();
for y in 0..h {
for x in 0..w {
let r = y * 256 / h;
let g = x * 256 / w;
let b = 255 - (x * y).isqrt() * 256 / l;
buf += &codes::fg!(r, g, b);
buf.push('H');
}
buf.push('\n');
}
print!("{buf}");
Ok::<(), Error>(())§Result in terminal
