bgrins / TinyColor

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

why tinycolor({h: 0, s: 100,v: 0}).toHsv() result {h: 0, s: 0, v: 0} ? #272

Closed otary closed 6 months ago

otary commented 9 months ago

why tinycolor({h: 0, s: 100,v: 0}).toHsv() result {h: 0, s: 0, v: 0} ?

aiktb commented 6 months ago

I encountered the same issue and it has troubled me for a long time. Have you found a solution?

otary commented 6 months ago

I added a layer of judgment on the outer layer instead of directly using tinycolor, code like this:

if (color.s === 100) {
    return {
        h: 0,
        s: 100,
        v: 0
    }
}
return tinycolor(color);