SHIP:Data Types:Color

From Serious Documentation
Jump to: navigation, search

See Also

Color

Colors in SHIP are 32-bit numbers in ARGB8888 format.

Data Type Description
Color A 32-bit value representing an ARGB8888-format color which includes 8-bits each of alpha (transparency), red, green, and blue.

All color manipulation in SHIP, regardless of the underlying hardware's capabilities, is performed using 32-bit Color values. This 32-bit value is composed of four 8-bit values representing the Alpha (transparency), Red, Green, and Blue intensities respectively and is often called "ARGB8888" encoding to represent the order and size of the four elements.

Regardless of the underlying endianness of the hardware, in SHIP the Color values are always represented as little endian values, with:

  • the 1st (low) byte the Blue,
  • the 2nd byte the Green,
  • the 3rd byte the Red,
  • the 4th (high) byte the Alpha.

Color constants in Sail scripts as well as SHIPTide property manipulation are often written as hex values (e.g.0xFF002244) or #-prefixed hex values (e.g. #FF002244).

An alpha value of 0x00 means completely transparent. As the alpha element of a Color increases, so also does the opacity of the color. An alpha value of 0xFF means the color is completely opaque.

Similarly, an R/G/B element value of 0x00 means that color element (e.g. Red) has no intensity, up to a value of 0xFF meaning full intensity for that color element.

Examples

  • 0x00000000 is a completely transparent color
  • #00FFFFFF is also completely transparent since the alpha element is 0x00
  • #40FFFFFF is a 1/4 opaque (3/4 transparent) white color, since the alpha element is 0x40 which is approximately 1/4 of 0xFF and the color elements (RGB) are equal. When you mix all three colors equally, you get white.
  • #FFFF0000 is fully opaque red, since the alpha element is 0xFF which is 100% opaque and the Red color element is also full intensity but the Blue and Green elements have zero intensity.