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(); // a54e3cColorPalette.BRICK.getHexCodeWithLeadingHash(); // #a54e3cColorPalette.BRICK.getValue(); // brickColorPalette.DUCK_EGG.getValue(); // duck-eggColorPalette.BRICK.getRgbColor(); // RgbColor(165, 78, 60)ColorPalette.BRICK.isBlackContrastingColor(); // false → white textgetValue() 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.
Picking and matching
Section titled “Picking and matching”ColorPalette nearest = ColorPalette.getNearest("#a04b3a"); // BRICKColorPalette 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.
The colors
Section titled “The colors”Text on each tile is drawn in the color isBlackContrastingColor2() picks for that background.
License
Section titled “License”Part of the library, MIT licensed.