Rainmeter documentation explains that RGBa colors are specified by four comma separated decimal digits each of which should be in the range 0-255.
Technical sources state that RGBa colors are specified by R,G,B,a where the RGB components are 0-255 whereas 'a' (alpha) should be in the range 0-1.
Is there a site which explains the difference and for your use of 0-255 for the alpha channel. I'd like to read up on it.
Thanks.
It is currently April 20th, 2024, 10:25 am
RGBA alpha 0-255 or 0-1?
-
- Posts: 1
- Joined: June 29th, 2019, 6:00 pm
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: RGBA alpha 0-255 or 0-1?
We use the RGBA color model, which is described here:briton wrote: ↑June 29th, 2019, 6:13 pm Rainmeter documentation explains that RGBa colors are specified by four comma separated decimal digits each of which should be in the range 0-255.
Technical sources state that RGBa colors are specified by R,G,B,a where the RGB components are 0-255 whereas 'a' (alpha) should be in the range 0-1.
Is there a site which explains the difference and for your use of 0-255 for the alpha channel. I'd like to read up on it.
Thanks.
https://en.wikipedia.org/wiki/RGBA_color_space
I mostly see what is better known as the RGBa model with the alpha in a range from 0 to 1 used in HTML / CSS.
Believe me, there are dozens, maybe hundreds, of ways of expressing colors in code.
The human eye can distinguish about 10,000,000 distinct colors. At the end of the day, your monitor can display 16,777,216 distinct colors. That is 256*256*256 of color with 32 bits, or 256 bytes of support for transparency. So 0-255 is the most logical way to represent these values.
I can see the charm, from a user standpoint, of expressing opacity as percentage. That is sorta how you think about it really. That is why HTML / CSS went that route, and I'm fine with that. From a strictly technical standpoint however, that doesn't entirely make sense. A percentage expressed as a floating point number between 0 and 1 has theoretically unlimited granularity, which is in no way actually supported by the hardware. Is 0.500000000 a different level of opacity from 0.500000001? I think not. I'm quite sure that the 0.0-1.0 value in CSS is simply applied as a percentage to 256 and rounded to the nearest integer. So the net effect is the same.
It's not about right and wrong. We use what is natively supported in all the C++ code we write. That is either decimal RRR,GGG,BBB,AAA or hex RRGGBBAA, all of which are values from 0-255. It's likely this was done this way many, many years ago in order to keep the component values to 8-bit byte integers, rather than the relatively more expensive floating-point decimal numbers.
To be sure, I would be delighted, absolutely delighted, if the alpha component in a color could actually support fractional amounts. While SolidColor=0,0,0,1 (invisible but "solid") generally works ok, if you have a really good monitor, and a good eye, you can see a tiny difference between that and SolidColor=0,0,0,0 (fully transparent). However, we have looked into this repeatedly, and it seems that there is just no way to do this. The alpha component (and in fact all the color components) must be expressed as integers at the end of the day.
-
- Rainmeter Sage
- Posts: 5398
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: RGBA alpha 0-255 or 0-1?
I am sure Brian or JSMorley (see above! ) can provide more details, but here are a few links describing the PNG32 format.
Patrick Hansen | PNG8, 24, 32... what?
Intro to PNG Features (see Alpha Channels)
Patrick Hansen | PNG8, 24, 32... what?
Intro to PNG Features (see Alpha Channels)
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::