HsbColor.random constructor

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

Generates a HsbColor 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.

minBrightness and maxBrightness constrain the generated brightness 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 HsbColor.random({
  num minHue = 0,
  num maxHue = 360,
  num minSaturation = 0,
  num maxSaturation = 100,
  num minBrightness = 0,
  num maxBrightness = 100,
  int? seed,
}) {
  assert(minHue >= 0 && minHue <= 360);
  assert(maxHue >= 0 && maxHue <= 360);
  assert(minSaturation >= 0 && minSaturation <= maxSaturation);
  assert(maxSaturation >= minSaturation && maxSaturation <= 100);
  assert(minBrightness >= 0 && minBrightness <= maxBrightness);
  assert(maxBrightness >= minBrightness && maxBrightness <= 100);
  return cm.HsbColor.random(
    minHue: minHue,
    maxHue: maxHue,
    minSaturation: minSaturation,
    maxSaturation: maxSaturation,
    minBrightness: minBrightness,
    maxBrightness: maxBrightness,
    seed: seed,
  ).cast();
}