Question

I've implemented some functions according to the HSL->RGB and HSV->RGB algorithms.
They mostly work fine, but I'm not sure what is the right thing to do then a color component overflows as a result of the conversion.

E.g., the red component ends up being 1.2 whereas the allowed range is [0..1]. If I multiply that by 255 I will obviously get a value that is invalid in the RGB world.

What is the correct way of handling this -- truncating (if > 1 then set to 1) or wrapping around (if > 1 then substract 1)?

Was it helpful?

Solution

It is not possible that the values ​​R, G and B come out of their range if you have properly implemented standard algorithms and inputs are in their ranges.

What algorithms you've implemented?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top