toUint8 method

int toUint8()

Converts this Color to a 32-bit unsigned integer representation (ABGR).

For example, opaque red (1.0, 0.0, 0.0, 1.0) would become 0xFFFF0000. Transparent black (0.0, 0.0, 0.0, 0.0) would become 0x00000000.

Returns: An integer representing the color in ABGR format.

Implementation

int toUint8() {
  return (((a.clamp(0.0, 1.0) * 255).round().toInt() & 0xFF) << 24 |
      ((b.clamp(0.0, 1.0) * 255).round().toInt() & 0xFF) << 16 |
      ((g.clamp(0.0, 1.0) * 255).round().toInt() & 0xFF) << 8 |
      ((r.clamp(0.0, 1.0) * 255).round().toInt() & 0xFF) << 0);
}