While working on Whimsical Dark Mode, I needed to expand our range of colors at both ends of the spectrum. Previously, this is something I’d do manually, but there is one big catch: we allow users to create custom palettes.
As a result, we need an algorithmic way to generate color palettes, since we can’t control what they choose at runtime. Given a single color, we need to infer a harmonious range of colors.
From previous work, I knew the oklch color space was the best bet.
-
The
lightness channel would form the basis for steps. A constant L value across colors ensures they have perceptually similar contrast. We also want to offer more colors at end ranges for layering and nuance. -
The
hue channel would be chosen by the user. We’d infer this from a user’s choice. -
The
chroma channel was the tricky part. We want to desaturate the colors as the approach the ends, so that they don’t look too vibrant. We’d also infer this from the user’s choice.
To achieve this, I spun up a Make app that lets me generate palettes parametrically. This lets me try out different easing functions for L and C channels before moving into code.




