rm-hull / inkspot

A small Clojure/ClojureScript library for creating colour swatches
https://www.destructuring-bind.org/inkspot/
MIT License
39 stars 2 forks source link

hsv->rgb yields wrong result for white #8

Open martinzuern opened 5 years ago

martinzuern commented 5 years ago

Color white is represented in HSV and HSL as [0 0 1] (as per https://en.wikipedia.org/wiki/HSL_and_HSV#Examples)

While rgb->hsv works perfectly fine, hsv->rgb (and hsl->rgb) return for white [1 1 1] instead of [255 255 255].

[1:0]~shadow.user=> (use 'inkspot.converter)
nil
[1:0]~shadow.user=> (rgb->hsv [255 255 255])
[0.0 0.0 1.0]
[1:0]~shadow.user=> (hsv->rgb [0 0 1])
#object[java.awt.Color 0x70c88923 "java.awt.Color[r=1,g=1,b=1]"]
[1:0]~shadow.user=> (hsv->rgb [0.0 0.0 1.0])
#object[java.awt.Color 0x15f63744 "java.awt.Color[r=1,g=1,b=1]"]
[1:0]~shadow.user=>

I think it's due to this line: https://github.com/rm-hull/inkspot/blob/ccb7a452a0930f451bcc6c960024d6029f616cd2/src/inkspot/converter.cljc#L29-L31

rm-hull commented 5 years ago

Yes, I think you are correct.