colored-rs / colored

(Rust) Coloring terminal so simple you already know how to do it !
Mozilla Public License 2.0
1.68k stars 82 forks source link

Get closest color if TrueColor not supported #90

Closed spenserblack closed 9 months ago

spenserblack commented 3 years ago

This PR makes TrueColor convert into one of the more "basic" colors (Color::Black, Color::Red, etc.) if TrueColor is not supported based on the COLORTERM environment variable. It gets the closest color based on Euclidean distance.

I'm not sure if some of the functions I added should be made public or not, so I left them private for now.