Color constructor

const Color(
  1. int value
)

Constructs a color from the lower 32-bits of an int.

The bits are interpreted as follows:

  • Bits 24-31 are the alpha value.
  • Bits 16-23 are the red value.
  • Bits 08-15 are the green value.
  • Bits 00-07 are the blue value.

In other words, if:

  • AA is the alpha value (in hex)
  • RR is the red value (in hex)
  • GG is the green value (in hex)
  • BB is the blue vlaue (in hex)

... the color can be expressed as const Color(0xAARRGGBB).

For example, to get a fully opaque orange, you would use:

//              red blue
//              vv  vv
const Color(0xFFFF9000)
//            ^^  ^^
              alpha^
                  ^^
                   green

Implementation

const Color(int value) : value = value & 0xFFFFFFFF;