1 unstable release

0.1.0 Jul 25, 2022

#855 in Command-line interface

Download history 2065/week @ 2025-08-24 1509/week @ 2025-08-31 1266/week @ 2025-09-07 1142/week @ 2025-09-14 1118/week @ 2025-09-21 2748/week @ 2025-09-28 1401/week @ 2025-10-05 1715/week @ 2025-10-12 1300/week @ 2025-10-19 970/week @ 2025-10-26 2617/week @ 2025-11-02 3762/week @ 2025-11-09 4117/week @ 2025-11-16 3449/week @ 2025-11-23 5233/week @ 2025-11-30 4142/week @ 2025-12-07

16,992 downloads per month
Used in 4 crates

MIT license

23KB
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

~560KB
~12K SLoC