Save and load Hex (player colors) in BlueG MySQL R39!
#5

As Vince said, colors are just numbers.
Color 0xFFFFFFFF is exactly the same as color -1.

It's just so we can read it easier.
Colors in hex are made up by red, green, blue and transparency values, each represented by 2 digits.

Take 0x12345678 for example.
The "12" represents the red value, "34" is green, "56" is blue and "78" is transparency.
The 0x tells the compiler that the following digits are hex-codes.

Each digit is a value from 0 to 15, where value above 10 are represented by A (10), B(11), C(12), D(13), E(14) and F(15).

The "12" isn't 12, as hex numbers don't work with base-10 value, they use base-16 values.

To convert to a decimal value:
(1 * 16^7) + (2 * 16^6) + (3 * 16^5) + (4 * 16^4) + (5 * 16^3) + (6 * 16^2) + (7 * 16^1) + (8 * 16^0)
= 268435456 + 33554432 + 3145728 + 262144 + 20480 + 1536 + 112 + 8
= 305419896

So value 0x12345678 equals integer number 305419896, which can be stored safely in an integer field.
Reply


Messages In This Thread
Save and load Hex (player colors) in BlueG MySQL R39! - by VenomMancer - 09.02.2015, 11:49
Re: Save and load Hex (player colors) in BlueG MySQL R39! - by Sime30 - 09.02.2015, 14:35
Re: Save and load Hex (player colors) in BlueG MySQL R39! - by VenomMancer - 09.02.2015, 15:00
Re: Save and load Hex (player colors) in BlueG MySQL R39! - by Vince - 09.02.2015, 16:51
Re: Save and load Hex (player colors) in BlueG MySQL R39! - by PowerPC603 - 09.02.2015, 18:32

Forum Jump:


Users browsing this thread: 1 Guest(s)