#gradient #color #ansi #terminal #cli

no-std tiny-gradient

Make your string colored in gradient

1 unstable release

0.1.0 Jul 25, 2022

#797 in Text processing

Download history 60/week @ 2022-11-29 829/week @ 2022-12-06 1273/week @ 2022-12-13 831/week @ 2022-12-20 120/week @ 2022-12-27 2709/week @ 2023-01-03 6388/week @ 2023-01-10 9182/week @ 2023-01-17 7660/week @ 2023-01-24 8239/week @ 2023-01-31 7617/week @ 2023-02-07 7930/week @ 2023-02-14 5447/week @ 2023-02-21 4385/week @ 2023-02-28 3644/week @ 2023-03-07 2530/week @ 2023-03-14

16,117 downloads per month
Used in 2 crates

MIT license

22KB
557 lines

tiny-gradient

github crates.io docs.rs

Preview

Usage

use tiny_gradient::{Gradient, GradientStr, RGB};

let text = "Hello World!";

// Use custom gradient
let colored = text.gradient([RGB::new(0x01, 0x00, 0x00), RGB::new(0xDA, 0x00, 0xFF)]);
println!("{}", colored);

// Use built-in gradient.
let colored = text.gradient(Gradient::Forest);
println!("{}", colored);

Notes

All the credit should go to https://stackoverflow.com/questions/22607043/color-gradient-algorithm/.

Some insiration were taken from https://github.com/bokub/gradient-string.

There's an analogues library https://crates.io/crates/colorgrad. I wasn't aware at the begining that it exists. It seems to be more mature so you may need to take a look at it.

Dependencies

~410KB