1 unstable release

0.1.0 Jul 25, 2022

#1164 in Command-line interface

Download history 870/week @ 2024-11-14 1263/week @ 2024-11-21 712/week @ 2024-11-28 1206/week @ 2024-12-05 1002/week @ 2024-12-12 532/week @ 2024-12-19 133/week @ 2024-12-26 770/week @ 2025-01-02 871/week @ 2025-01-09 1492/week @ 2025-01-16 1998/week @ 2025-01-23 2707/week @ 2025-01-30 2631/week @ 2025-02-06 2116/week @ 2025-02-13 1724/week @ 2025-02-20 3348/week @ 2025-02-27

10,429 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

~395KB