bgrins / TinyColor

Fast, small color manipulation and conversion for JavaScript
https://bgrins.github.io/TinyColor/
MIT License
5.05k stars 438 forks source link

.lighten() with negative values darkens the color #204

Open dragonee opened 5 years ago

dragonee commented 5 years ago

It appears that values lower than 0 are accepted, which contradicts the documentations (which says that values are in 0-100 range). This results in somewhat unexpected behaviour, where lighten(-15) does somewhat similar thing to darken(15).

There are a few possible solutions I can come up with. The best one would be to clamp input values to 0-100. The rationale is that the scale for lighten and darken is different and depends on the luminosity of the original color.

Example - I have a color that has 70% luminosity. lighten(100) does 70+30 = 100 luminosity. lighten(-100) does 70-30 = 40% which is strange or the stepping value is different, which would also be strange.

So I would vote for removal of this unexpected behaviour.