# Color: Why is color with four attributes and a value of 0 to 1?

I noticed in the document that Color has four attribute and a value of 0 to 1. I’m not understanding the concept well. I want to understand the concept.

e.g. I’ve seen this:

``````new Color(1f, 0f, 0f, 0.4f);
``````

Let’s say I have a color gray and I want to use the Color attribute. I know that gray’s rgb value is (192,192,192). How do I convert that to a value from 0 to 1? Why is Color written from 0 to 1?

Can someone explain the concept and why Unity uses something like the new Color declared above? I can’t find a good explanation online.

it’s RGBA
red
green
blue
alpha

minimum value is 0, maximum is 1

it means 0 = 0, 1 = 255 for RGB and 0 = 0, 1 = 100 for alpha

it’s actually pretty simple and pretty good for purposes of programmer and that’s the reason why it’s that … number from 0 to 255 is nothing more than minimum and maximum of some range, but if you want to calculate with color you always need to divide it by maximum (so by 255) first and that’s the reason unity skips this step

your example mean red color with 40% transparency (photoshop values)

gray color as you describe it would be new Color(0.75f, 0.75f, 0.75f); (the alpha is optional) you’ll get the number by dividing 192 / 255

to work with unity i was forced to forget my old habbits like thinking in this photoshop RGB or thinking about animation as it consists from frames … and it works even better

Why Unity uses this format I have no Idea, but you can always use color32:

0-1 RGBA has always been the official format used inside all graphics cards and shaders. Because of that, programmers tend to use 0-1 for colors (since all colors are going to into a shader at some point.) When I first looked at Unity, seeing they used 0-1 for Color variables was one of the things that convinced me they knew what they were doing.