omgovich / colord

👑 A tiny yet powerful tool for high-performance color manipulations and conversions

Home Page:https://colord.omgovich.ru

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

isLight and isDark with threshold parameter

SrBrahma opened this issue · comments

commented

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!

commented

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.

Hi! Thanks for the kind words!

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