MsMaterialColor.fromRGBO constructor

MsMaterialColor.fromRGBO(
  1. int r,
  2. int g,
  3. int b,
  4. double opacity,
)

Create a MsMaterialColor from red, green, blue, and opacity, similar to rgba() in CSS.

  • r is red, from 0 to 255.
  • g is green, from 0 to 255.
  • b is blue, from 0 to 255.
  • opacity is alpha channel of this color as a double, with 0.0 being transparent and 1.0 being fully opaque.

Out of range values are brought into range using modulo 255.

Implementation

factory MsMaterialColor.fromRGBO(int r, int g, int b, double opacity) =>
    MsMaterialColor(((((opacity * 0xff ~/ 1) & 0xff) << 24) |
            ((r & 0xff) << 16) |
            ((g & 0xff) << 8) |
            ((b & 0xff) << 0)) &
        0xFFFFFFFF);