I'm working on a data visualization library in JavaScript which depends on a "Color" class containing values for red, green, and blue channels from 0-255. Is there any reason to store decimal values for these color channels or is it safe to truncate to an integer?
E.g. in css, is
rgba(250, 0, 0, 100%)
the same as
rgba(250.1, 0, 0, 100%)
I know that hex color codes 00 through FF are equivalent to integer values 0 through 255, without decimals.
Humans actually being able to percieve 2 different colors is a different story here. I want to know:
- Are colors are actually interpreted differently by CSS?
- Does it depend on the user's monitor, browser, or GPU?
How the browsers choose to adjust the colours may depend, however according to the standard from W3C, it can be a decimal, following the CSS grammer
And following the definition of
<number>: