HsiColor.random constructor

HsiColor.random({
  1. num minHue = 0,
  2. num maxHue = 360,
  3. num minSaturation = 0,
  4. num maxSaturation = 100,
  5. num minIntensity = 0,
  6. num maxIntensity = 100,
  7. int? seed,
})

Generates a HsiColor at random.

minHue and maxHue constrain the generated hue value. If minHue < maxHue, the range will run in a clockwise direction between the two, however if minHue > maxHue, the range will run in a counter-clockwise direction. Both minHue and maxHue must be >= 0 && <= 360 and must not be null.

minSaturation and maxSaturation constrain the generated saturation value.

minIntensity and maxIntensity constrain the generated intensity value.

Min and max values, besides hues, must be min <= max && max >= min, must be in the range of >= 0 && <= 100, and must not be null.

Implementation

factory HsiColor.random({
  num minHue = 0,
  num maxHue = 360,
  num minSaturation = 0,
  num maxSaturation = 100,
  num minIntensity = 0,
  num maxIntensity = 100,
  int? seed,
}) {
  assert(minHue >= 0 && minHue <= 360);
  assert(maxHue >= 0 && maxHue <= 360);
  assert(minSaturation >= 0 && minSaturation <= maxSaturation);
  assert(maxSaturation >= minSaturation && maxSaturation <= 100);
  assert(minIntensity >= 0 && minIntensity <= maxIntensity);
  assert(maxIntensity >= minIntensity && maxIntensity <= 100);
  return cm.HsiColor.random(
    minHue: minHue,
    maxHue: maxHue,
    minSaturation: minSaturation,
    maxSaturation: maxSaturation,
    minIntensity: minIntensity,
    maxIntensity: maxIntensity,
    seed: seed,
  ).cast();
}