ColorPalette.adjacent constructor

ColorPalette.adjacent(
  1. Color seed, {
  2. int numberOfColors = 5,
  3. num distance = 30,
  4. num hueVariability = 0,
  5. num saturationVariability = 0,
  6. num brightnessVariability = 0,
  7. bool perceivedBrightness = true,
  8. bool growable = true,
  9. bool unique = false,
})

Generates a ColorPalette by selecting colors with hues to both sides of color's hue value.

If numberOfColors is odd, color will be included in the palette. If even, color will be excluded from the palette. numberOfColors defaults to 5, must be > 0, and must not be null.

distance is the base spacing between the selected colors' hue values. distance defaults to 30 degrees and must not be null.

hueVariability, saturationVariability, and brightnessVariability, if > 0, add a degree of randomness to the selected color's hue, saturation, and brightness (HSB's value) values, respectively.

hueVariability defaults to 0, must be >= 0 && <= 360, and must not be null.

saturationVariability and brightnessVariability both default to 0, must be >= 0 && <= 100, and must not be null.

Implementation

factory ColorPalette.adjacent(
  Color seed, {
  int numberOfColors = 5,
  num distance = 30,
  num hueVariability = 0,
  num saturationVariability = 0,
  num brightnessVariability = 0,
  bool perceivedBrightness = true,
  bool growable = true,
  bool unique = false,
}) {
  assert(numberOfColors > 0);
  assert(hueVariability >= 0 && hueVariability <= 360);
  assert(saturationVariability >= 0 && saturationVariability <= 100);
  assert(brightnessVariability >= 0 && brightnessVariability <= 100);
  return ColorPalette(_cast(
    cp.ColorPalette.adjacent(
      RgbColor.fromColor(seed),
      numberOfColors: numberOfColors,
      distance: distance,
      hueVariability: hueVariability,
      saturationVariability: saturationVariability,
      brightnessVariability: brightnessVariability,
      perceivedBrightness: perceivedBrightness,
    ),
    growable: growable,
    unique: unique,
  ));
}