chromakitx 1.0.2

A comprehensive color manipulation library for Rust
Documentation
// SPDX-FileCopyrightText: 2023 CELESTIFYX Team
// SPDX-License-Identifier: GPL-3.0-or-later

use chromakitx::{
    RGB,
    HSL,
    AnsiColor,
    CustomColor,

    helpers::{
        colorize,
        gradient
    }
};

fn main() -> () {
    let text: &str = "RAINBOW COLORS";
    println!("Rainbow using HSL interpolation:\n");

    let mut result: String = String::new();
    let len: usize = text.len();

    for (i, ch) in text.chars().enumerate() {
        let hue: f32 = (i as f32 / len as f32) * 360.0;
        let hsl: HSL = HSL::new(hue / 360.0, 0.9, 0.5).unwrap();

        let colored: String = colorize(&ch.to_string(), CustomColor::from(hsl), None::<AnsiColor>);
        (&mut result).push_str(&colored);
    }

    println!("{}\n", result);
    println!("Multiple rainbow lines:\n");

    let lines: [&str; 3] = [
        "CHROMAKITX",
        "IS AWESOME",
        "FOR COLORS"
    ];

    for line in lines {
        let mut colored_line: String = String::new();
        let len: usize = line.len();

        for (i, ch) in line.chars().enumerate() {
            let hue: f32 = (i as f32 / len as f32) * 360.0;
            let hsl: HSL = HSL::new(hue / 360.0, 1.0, 0.5).unwrap();

            let colored: String = colorize(&ch.to_string(), CustomColor::from(hsl), None::<AnsiColor>);
            (&mut colored_line).push_str(&colored);
        }

        println!("{}", colored_line);
    }

    let rainbow_start: RGB = RGB::new(255, 0, 0);
    let rainbow_end:   RGB = RGB::new(148, 0, 211);

    println!("\nRainbow gradient effect:");
    println!("{}", gradient("Rust Programming Language", &rainbow_start, &rainbow_end));
}