1 unstable release

0.1.0 Jul 25, 2022

#890 in Command-line interface

Download history 2750/week @ 2025-09-29 1426/week @ 2025-10-06 1993/week @ 2025-10-13 1011/week @ 2025-10-20 958/week @ 2025-10-27 2832/week @ 2025-11-03 3559/week @ 2025-11-10 4632/week @ 2025-11-17 2917/week @ 2025-11-24 5345/week @ 2025-12-01 3987/week @ 2025-12-08 4636/week @ 2025-12-15 3237/week @ 2025-12-22 5079/week @ 2025-12-29 6641/week @ 2026-01-05 5146/week @ 2026-01-12

20,288 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

~555KB
~12K SLoC