In 2014, Casey Reas demonstrated a generative piece where colors emerged not from random number generators, but from a system that understood color the way painters do—through relationships. The result was striking: thousands of iterations, each with its own palette, yet every single one felt intentional. This wasn't luck. It was mathematics wearing the mask of intuition.
Most creative coders begin with RGB, the native tongue of screens. They randomize values, maybe constrain ranges, and hope for harmony. Sometimes it works. More often, the results feel chaotic or muddy—like a band where every musician plays in a different key. The problem isn't randomness itself. It's that RGB doesn't map to how humans perceive color relationships.
Algorithmic color harmony isn't about eliminating chance—it's about giving chance better tools. By choosing the right color model, implementing harmonic rules, and letting compositions influence their own palettes, generative artists can create work where every color choice, while computationally determined, resonates with the aesthetic logic we've understood for centuries.
Color Space Navigation
RGB treats color as a hardware problem: how much red, green, and blue light should each pixel emit? This makes perfect sense for monitors but terrible sense for artists. In RGB space, rotating through hues means coordinating three independent channels in non-obvious ways. Increasing brightness often shifts perceived hue. Finding analogous colors requires trigonometry that has nothing to do with visual similarity.
HSL (Hue, Saturation, Lightness) reorganizes this chaos into something navigable. Hue becomes a single value on a 360-degree wheel—red at 0°, green at 120°, blue at 240°. Want colors that sit next to each other? Add or subtract 30 degrees. Want to lighten a color without changing its character? Adjust L while preserving H and S. Suddenly, the creative operations you want to perform align with simple arithmetic.
LAB color space goes further, modeling human perception rather than physical light. The L channel represents lightness, while A and B encode color along red-green and blue-yellow axes. Colors that appear equally bright to human eyes have equal L values—something RGB can't guarantee. This perceptual uniformity means that algorithms creating color progressions produce results that feel smooth and intentional rather than computationally arbitrary.
The choice of color space is a creative decision disguised as a technical one. RGB gives you access to every possible screen color but no map to navigate them meaningfully. HSL provides an intuitive map but distorts perceptual relationships—colors with identical saturation values can look wildly different in vibrancy. LAB sacrifices some simplicity for perceptual truth. Most sophisticated generative work converts to HSL or LAB for palette logic, then back to RGB for rendering.
TakeawayChoose your color space based on what operations your algorithm needs to perform. If you're rotating through hues or finding harmonics, work in HSL. If perceptual uniformity matters—smooth gradients, balanced compositions—work in LAB.
Harmonic Rule Systems
Color theory has names for relationships that please the eye: complementary (opposite on the wheel), analogous (neighbors), triadic (equilateral triangle), split-complementary (a color plus the two adjacent to its complement). These aren't arbitrary rules—they emerge from how our visual system processes contrast and similarity. Translating them into code is surprisingly straightforward once you're working in HSL.
A complementary palette starts with any hue and adds 180 degrees. Triadic relationships add 120 and 240 degrees. Analogous palettes stay within a 30-60 degree range. The elegance here is that sophisticated color relationships reduce to simple angular arithmetic: complementary = (baseHue + 180) % 360. Your algorithm can generate infinite variations while guaranteeing that each one follows harmonic logic.
The real artistry comes in how you vary saturation and lightness within these harmonic frameworks. A triadic palette where all three colors share identical saturation and lightness feels flat and designed-by-committee. Professional colorists know to create hierarchy: one dominant hue at full saturation, supporting hues desaturated or shifted in lightness. Your algorithm can encode these principles—perhaps the first hue gets S: 0.8, L: 0.5, while harmonic companions get S: 0.6, L: 0.65.
Temperature adds another layer of systematic control. Warm colors (reds, oranges, yellows) advance visually while cool colors (blues, greens, purples) recede. An algorithm can assign warm/cool designations based on hue ranges and use temperature relationships to create depth. Some generative artists implement subtle hue shifts across a composition—warming colors in focal areas, cooling them at edges—all through rules that never break harmonic relationships.
TakeawayHarmonic relationships are angular arithmetic in HSL space. Build your palette generator around these rules, then create visual hierarchy by systematically varying saturation and lightness rather than treating all harmonic colors as equals.
Context-Aware Adaptation
Static palettes break down in dynamic compositions. A color that sings against white space becomes invisible in dense regions. Focal points demand emphasis that surrounding areas shouldn't compete with. The most sophisticated generative color systems don't just pick palettes—they respond to what they're coloring.
Density-based adaptation adjusts saturation and contrast according to local complexity. In sparse areas, colors can be bold and saturated—they have room to breathe. In busy regions, reducing saturation prevents visual overload while maintaining harmony. One implementation counts neighboring elements within a radius and maps that count to a saturation multiplier. Dense areas get 60-70% of base saturation; sparse areas get 100% or more.
Focal point emphasis requires identifying where attention should land, then engineering color to direct it there. This might mean higher saturation at focal points, greater lightness contrast, or warmer temperatures. Some systems calculate visual center-of-mass and increase color intensity for elements near it. Others respond to compositional features—edges, curves, intersections—intensifying colors at points of interest.
The most nuanced approach treats composition as a conversation between elements. When two shapes overlap, their colors might blend, push each other toward complementary relationships, or adjust lightness to maintain legibility. When one element clearly dominates, subordinate elements shift toward neutrals. These rules simulate the decision-making a human colorist would apply, but at algorithmic scale—thousands of adjustments per frame, all following the same aesthetic logic.
TakeawayLet your composition influence its own palette. Build feedback loops where density reduces saturation, focal points increase contrast, and overlapping elements negotiate their colors. Static palette selection is only the beginning—context-aware adaptation is where algorithmic color becomes truly intelligent.
Algorithmic color harmony isn't about replacing human aesthetic judgment—it's about encoding it. The rules that painters learned through centuries of practice can become parameters in functions, transforming intuition into repeatable, scalable systems.
The progression from random RGB to harmonic HSL to context-aware LAB represents more than technical sophistication. It mirrors how any artist develops: from naive experimentation to structured understanding to nuanced responsiveness. Code can travel this same path, embodying lessons that took human colorists lifetimes to accumulate.
The goal isn't to generate colors that no human could choose—it's to generate colors that feel chosen. When the mathematics disappear and only the beauty remains, the algorithm has done its job.