omgovich / colord

👑 A tiny yet powerful tool for high-performance color manipulations and conversions
https://colord.omgovich.ru
MIT License
1.63k stars 48 forks source link

isLight and isDark with threshold parameter #89

Closed SrBrahma closed 2 years ago

SrBrahma commented 2 years ago

First, many thanks for this lib! Tinycolor2 and polished are quite limited, color fits me more but has a bad and narrow minded dev, the rare type we hate to find here on GitHub. This lib is exactly what I've been looking for through those years.

color has this PR open for years, and I would really like to see it on this lib: https://github.com/Qix-/color/pull/141

Here is my use case: I prefer having a white overlay when pressing my buttons, but I can't have this white overlay when the button bg is white / very light. Instead of just isLight(), I would like to ~ "isVeryLight", like isLight(0.8) or some other value pattern.

Can you add it? Thanks!

SrBrahma commented 2 years ago

As isLight JSDoc comment says, it's the same as .brightness() >= 0.5, so I am using 0.8 for my taste (will still validate it).

Still, I think it's valid to have a parameter for it on isLight. It could check if >= x = 0.5, and isDark if < x = 0.5.

omgovich commented 2 years ago

Hi! Thanks for the kind words!

We are expecting developers to use .brightness() to perform their customs checks. That's exactly why brightness() exists.