Question

So with RGBA, you set the alpha with the last attribute. However, I have seen people set the alpha as 255 to get it at 100% when I always thought the correct way was to set it to 1?

What I'm trying to say is this:

rgba(0, 0, 0, 120)  // What they did
rgba(0, 0, 0, 0.47) // What I would do.

From what I can see, they do the same thing. Is there a "correct" way of doing it?

Was it helpful?

Solution

The type we usually use to represent the RGBA information should be an 4 bytes integer. 0x00000000 these four bytes represent red green blue alpha (or red blue green alpha) respectively.

So the "Correct" way is to set the last byte to be 255, if you want the alpha to be 1. However, in some libraries or languages there are 2 interfaces to set the last byte to be 255:

rgba(int,int,int,int) 

and

rgba(int,int,int,float)

So, that depends! You should find out the interface in the documentation! Hope this can help you!

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