pub mod colorful_text {
#[derive(Clone)]
pub enum OutputFormat {
Ansi, EightBit, }
pub fn apply_gradient(text: &str, format: OutputFormat) -> String {
let mut result = String::new();
let hue_step = 360.0 / text.chars().count() as f32;
for (i, char) in text.chars().enumerate() {
let hue = (i as f32) * hue_step;
let base = 16; let color_index = base + ((hue / 360.0) * 216.0).floor() as u8;
let color_code = match format {
OutputFormat::Ansi | OutputFormat::EightBit => format!("\x1b[38;5;{}m", color_index),
};
result.push_str(&color_code);
result.push(char); }
result.push_str("\x1b[0m"); result
}
}