Color.from constructor

const Color.from({
  1. required double alpha,
  2. required double red,
  3. required double green,
  4. required double blue,
  5. ColorSpace colorSpace = ColorSpace.sRGB,
})

Construct a color with floating-point color components.

Color components allows arbitrary bit depths for color components to be be supported. The values are interpreted relative to the ColorSpace argument.

Example

// Fully opaque maximum red color
const Color c1 = Color.from(alpha: 1.0, red: 1.0, green: 0.0, blue: 0.0);

// Partially transparent moderately blue and green color
const Color c2 = Color.from(alpha: 0.5, red: 0.0, green: 0.5, blue: 0.5);

// Fully transparent color
const Color c3 = Color.from(alpha: 0.0, red: 0.0, green: 0.0, blue: 0.0);

Implementation

const Color.from({
  required double alpha,
  required double red,
  required double green,
  required double blue,
  this.colorSpace = ColorSpace.sRGB,
}) : a = alpha,
     r = red,
     g = green,
     b = blue;