Loading...
Logo
Processing Forum

RGB decimal

in Programming Questions  •  1 year ago  
Is it possible to extract decimal values from a colour ?

Example

color c = color(251.2,200.3,200.4);
float rr = c>>16&255
print (rr);

this prints 251.0  instead of 251.2

Are colors stored without decimals?


Replies(2)

Re: RGB decimal

1 year ago
Yup, 8 bits as a number between 0 - 255:  http://processing.org/reference/color_datatype.html

Re: RGB decimal

1 year ago
rr = red(c);
...
With colorMode(), you can use whatever scale suits you, but at the end, the numbers will end being in the 0-255 scale, so some rounding is to be expected.