Skip to content

ColorPalette

ColorPalette is the palette the library started with: 64 named colors, from BRICK through to WHITE, with no shade scale underneath them. Names like DUCK_EGG, FRENCH_VANILLA and SILVER_LINING come from a fashion color card rather than a design system, which is exactly what makes it useful for labelling things — TIFFANY is a name a person can remember, teal-300 is not.

ColorPalette.BRICK.getHexCode(); // a54e3c
ColorPalette.BRICK.getHexCodeWithLeadingHash(); // #a54e3c
ColorPalette.BRICK.getValue(); // brick
ColorPalette.DUCK_EGG.getValue(); // duck-egg
ColorPalette.BRICK.getRgbColor(); // RgbColor(165, 78, 60)
ColorPalette.BRICK.isBlackContrastingColor(); // false → white text

getValue() is annotated with @JsonValue, so Jackson serializes the enum as "duck-egg" rather than "DUCK_EGG", and the @Schema(enumAsRef = true) annotation makes it a named enum in a generated OpenAPI document instead of an inline list repeated at every usage.

ColorPalette nearest = ColorPalette.getNearest("#a04b3a"); // BRICK
ColorPalette random = ColorPalette.getRandomValue();
ColorPalette unused = ColorPalette.getRandomValue(alreadyAssigned);

getNearest() routes through ColorCode.getNearest() and therefore matches in OKLAB, the same as the other two palettes. Up to 0.6.x it compared rgb channels directly, so a few inputs land on a different constant after upgrading.

getRandomValue(Collection) returns null once the collection covers all 64 entries, which a caller assigning colors to a growing list has to handle.

Text on each tile is drawn in the color isBlackContrastingColor2() picks for that background.

brick#a54e3c
pomegrante#881f30
cabernet#721432
aubergine#5b1946
indigo#461c5d
plum#5c145e
royal#97348a
french-blue#3266ad
teal#337b8d
aquamarine#22586f
marine#18456b
navy#0e2e57
lilac#ae9cc7
orchid#985a9c
cobalt#4099d4
pool#9cd6f5
periwinkle#a7b4d0
dove#aec4d0
duck-egg#97babf
turquoise#6fbabf
jade#73aba0
tiffany#a5d2c1
mint#c8e0c4
spring#d3e2a3
chive#b8d26e
tree-top#759150
bottle#378159
emerald#29634e
lemon#fef6a6
sunshine#fcf151
tumeric#f9d549
clementine#f3b143
peach#f7d19d
salmon#f0b79f
coral#e89487
watermelon#e3708e
rasberry#ac2c69
magenta#db318a
red-balloon#db3656
fire-engine#db3732
blood-orange#e06151
papaya#e88b5b
rose#e6aab3
cherry-blossom#f6d6dc
blush#f6d6d1
french-vanilla#f8f1de
ivory#fbf8da
clay#e8d4b8
sandstone#c4b199
sage#a5b4a3
moss#a2a495
olive#7b7d6a
smoke#63605c
espresso#473937
chocolate#684940
caramel#957d62
black#221f20
charcoal#58585a
slate#949599
silver-lining#d1d2d4
oyster#e3ddd4
stone#d2cfc9
smog#928b88
white#ffffff

Part of the library, MIT licensed.