Game Development Reference
In-Depth Information
In Java (and thus JavaFX) different levels of ARGB color intensity values are rep-
resented using hexadecimal notation. Hexadecimal (or hex) is based on the original
Base16 computer notation. This was used long ago to represent 16 bits of data value.
Unlike the more common Base10 , which counts from 0 to 9, Base16 notation counts
from 0 to F, where F represents the Base10 value of 15 (0 to 15 yields 16 data values).
A hexadecimal value in Java always starts with a 0 and an x , like this: 0xFFFFFF .
This hexadecimal color value represents the Color.WHITE constant and uses no alpha
channel. Each of the six slots in this 24-bit hexadecimal representation stands for a
single Base16 value, so to get the 256 values required for each RGB color will take two
slots, as 16 × 16 = 256. Therefore, to represent a 24-bit image using hexadecimal nota-
tion, you would need to have six slots after the pound sign to hold each of the six hexa-
decimal data values (data pairs representing 256 levels of value each). If you multiply
16 × 16 × 16 × 16 × 16 × 16 you will get the 16,777,216 colors that are possible using
24-bit, truecolor image data.
The hexadecimal data slots represent RGB values in the following format:
0xRRGGBB . For the Java constant Color.WHITE, all the red, green, and blue chan-
nels in the hexadecimal color data value representation are at the full (maximum color
value) luminosity setting. If you add all these colors together, you will get white light.
The color yellow would be represented by the red and green channels' being on,
and the blue channel's being off, so a hexadecimal representation for Color.YELLOW
would therefore be 0xFFFF00 , where both the red and green channel slots are fully on
(FF, or a 255 Base10 data value), and the blue channel slots are fully off (00, or a 0
value).
The eight hexadecimal data slots for an ARGB value will hold data using the fol-
lowing format: 0xAARRGGBB . Thus, for the Color.WHITE, all alpha, red, green, and
blue channels in the hexadecimal color data value representation would be at their
maximum luminosity (or opacity), and the alpha channel would be fully opaque, that
is, not transparent, as represented by an FF value. Therefore, the hexadecimal value for
the Color.WHITE constant would be 0xFFFFFFFF .
A 100 percent transparent alpha channel can be represented by setting an alpha slot
to 0, as you observed when you created a windowless Java 8 application (see Chapter
4 ) . Therefore, you would represent transparent image pixel values using any value
between 0x00000000 and 0x00FFFFFF . It is important to note that if an alpha channel
value equates to full transparency, it would follow that the 16,777,216 color values that
could be contained in the other six (RGB) hexadecimal data value slots will not matter
at all, because that pixel, being transparent, will be evaluated as not being there and
thus will not be composited in the final image or animation composite image.
Search WWH ::




Custom Search