1 unstable release

0.1.0 Jul 25, 2022

#983 in Command-line interface

Download history 955/week @ 2024-03-27 890/week @ 2024-04-03 1296/week @ 2024-04-10 1491/week @ 2024-04-17 1001/week @ 2024-04-24 596/week @ 2024-05-01 870/week @ 2024-05-08 1263/week @ 2024-05-15 933/week @ 2024-05-22 1223/week @ 2024-05-29 1370/week @ 2024-06-05 1221/week @ 2024-06-12 1340/week @ 2024-06-19 691/week @ 2024-06-26 833/week @ 2024-07-03 978/week @ 2024-07-10

4,109 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

~410KB