henrywright
henrywright

Reputation: 10240

Hexadecimal color system

I'm trying to allocate a color for an image using imagecolorallocate(). The red, green and blue parameters can either be integers between 0 and 255 or hexadecimals between 0x00 and 0xFF. For example:

Decimal way:

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

Hexadecimal way:

$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

In the hexadecimal colour system, I know that #000000 is black. The first two digits 00 are the red value, the second two digits 00 are the green and the third two digits 00 are the blue.

I notice each 00 in imagecolorallocate($im, 0x00, 0x00, 0x00) is prefixed with an 0x. Can someone help me understand what the 0x part is?

Upvotes: 0

Views: 778

Answers (1)

WDMTech
WDMTech

Reputation: 173

The 0x tells whatever is reading the values to expect hex rather than decimal. This SO article might help :)

Upvotes: 2

Related Questions