ColorPalette.splitComplimentary constructor
Generates a ColorPalette by selecting colors to both sides
of the color with the opposite hue
of seed
.
If numberOfColors
is even, the coolor opposite of seed
will
be included in the palette. If odd, the opposite color will be
excluded from the palette. numberOfColors
defaults to 3
, 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
.
If perceivedBrightness
is true
, colors will be generated in the
HSP color space. If false
, colors will be generated in the HSB
color space.
If growable
is false
, a fixed-length the palette will be constructed
with a fixed-length list. If true
, a growable list will be used instead.
If unique
is false
, the palette will be constructed with a List.
If true
, a uniqueList
will be used instead.
Implementation
factory ColorPalette.splitComplimentary(
ColorModel seed, {
int numberOfColors = 3,
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);
final palette = <ColorModel>[seed];
final oppositeColor = seed.opposite;
var colorsRemaining = numberOfColors;
if (numberOfColors.isEven) {
palette.add(oppositeColor);
colorsRemaining -= 1;
}
for (var i = 1; i < colorsRemaining; i++) {
final color = _generateColor(
oppositeColor,
(i % 2 == 0 ? distance * -1 : distance) * ((i / 2).ceil()),
hueVariability,
saturationVariability,
brightnessVariability,
perceivedBrightness,
);
palette.add(color);
}
return ColorPalette(unique
? UniqueList<ColorModel>.from(palette, growable: growable)
: List<ColorModel>.from(palette, growable: growable));
}