vividtext

Crates.iovividtext
lib.rsvividtext
version0.1.3
sourcesrc
created_at2024-03-27 09:19:38.371968
updated_at2024-03-27 14:08:32.708251
descriptionLibrary to change text color
homepage
repositoryhttps://github.com/cuticle999/VividText
max_upload_size
id1187673
size26,306
Kikawada Seina (cuticle999)

documentation

README

What is this?

This is a library for coloring text. At this stage, it is designed for output on the CLI.

vividtext-cli

How to use

Add a dependency cargo add vividtext

Example of coloring the specified text main.rs

use vividtext::colorful_text::{apply_gradient, OutputFormat};

fn main() {
    let text = "Hello, world!";
    let formatted_text = apply_gradient(text, OutputFormat::Ansi);
    println!("{}", formatted_text);
}

Example of outputting text entered in a text file main.rs

use std::fs::File;
use std::io::{self, Read};
use vividtext::colorful_text::{apply_gradient, OutputFormat};

fn main() -> io::Result<()> {
    let file_path = "./like.text";
    let mut file = File::open(file_path)?;
    let mut contents = String::new();
    file.read_to_string(&mut contents)?;

    let gradient_text = apply_gradient(&contents, OutputFormat::Ansi);
    // または
    // let gradient_text = apply_gradient(&contents, OutputFormat::Rgb); 
    println!("{}", gradient_text);

    Ok(())
}

How to use with CLI If you specify a text file, etc., the text will be colored on the CLI.

cargo install vividtext

vividtext your_file

license

MIT

Commit count: 15

cargo fmt