1 unstable release

0.1.0 Jul 25, 2022

#912 in Command-line interface

Download history 1942/week @ 2025-10-14 916/week @ 2025-10-21 923/week @ 2025-10-28 3791/week @ 2025-11-04 4271/week @ 2025-11-11 3077/week @ 2025-11-18 3226/week @ 2025-11-25 5783/week @ 2025-12-02 3703/week @ 2025-12-09 4353/week @ 2025-12-16 4222/week @ 2025-12-23 5047/week @ 2025-12-30 6450/week @ 2026-01-06 4348/week @ 2026-01-13 2233/week @ 2026-01-20 3006/week @ 2026-01-27

17,373 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

~585KB
~12K SLoC