HsiColor.fromList constructor

HsiColor.fromList(
  1. List<num> values
)

Constructs a HsiColor from a list of hsi values.

hsi must not be null and must have exactly 3 or 4 values.

The hue must be >= 0 and <= 360.

The saturation and intensity must both be >= 0 and <= 100.

The alpha value, if provided, must be >= 0 && <= 255.

Implementation

factory HsiColor.fromList(List<num> values) {
  assert(values.length == 3 || values.length == 4);
  assert(values[0] >= 0 && values[0] <= 360);
  assert(values[1] >= 0 && values[1] <= 100);
  assert(values[2] >= 0 && values[2] <= 100);
  if (values.length == 4) assert(values[3] >= 0 && values[3] <= 255);
  final alpha = values.length == 4 ? values[3].round() : 255;
  return HsiColor(values[0], values[1], values[2], alpha);
}