Actually, to be a bit more precise about my last answer, what you get from the calculations for Color is a number with 4 Billion possibilities (0-4B).

But this translates to a signed Integer of -2B to +2B (B = Billion).

And to be even more precise, the different color values (Alpha, Red, Green, Blue) are weighted in this calculation. Like this :

Alpha = a (the value you use for alpha) * 256^3

Red = r * 256^2

Green = g * 256

Blue = b

So basically only Blue increases the int of color by a 1:1 ratio.

And to be more precise againā¦ the -2B to +2B is not reflected in the logical order.

The calculation for Color is :

color c = a * 256^3 + r * 256^2 + g * 256 + b; //this is not gonna work in code because this gives an unsigned int, not a signed one.

Now this brings a problem, because we need a signed int. To get back to your question, the weird way that the number gets to +2B and then one more and we have -2B we have to look at how it is calculated in binary.

So, to make it Short, if the result of our calculation is 0, it translates to 0 as binary (000ā¦0) (it got 32 bits, so iāll abbreviate the binary parts).

If itās more like 64, we get 000ā¦100ā¦0.

If itās that 2B number, we get 0111ā¦111.

Now, if itās that 2B number plus one, the way itās calculated in binary is, you add 1 to the rightmost bit, and if itās more than 1, you set it to 0 and change the bit to itās left to 1 more.

Going all the way to the leftmost bit now, we have to set it to 1 and all others end up as 0 (1000ā¦000).

With this we have a 1 as the first Bit, which we already said, means a negative number.

And the others all being 0, means we got the -2B number. Now we can go back all the way to -1 or (111ā¦111) in binary.

Well, i hope that last part wasnāt too confusingā¦ thatās just the simplest way i could think of desrcibing it practicly.