Rohit Agrawal

Product Engineer

Color Cruncher is a project that explores how algorithms can take on a subjective design problem (i.e. choosing a color palette) with a bit of inspiration from nature. Instead of spending hours choosing hex codes manually, I let optimisation algorithms inspired by natural processes generate aesthetically pleasing and usable palettes for me.

Why I built this

Most UI designers (and developers moonlighting as designers) know the pain: picking a good color palette is way harder than it looks. Get it wrong, and suddenly your app feels clunky, buttons don’t stand out, and text is either blinding or unreadable.

A good palette needs to:

  • Keep brand colors intact (your product still has to look like your product).
  • Maintain contrast for readability (so text doesn’t vanish into the background).
  • Be accessible (meeting WCAG guidelines for people with different visual abilities).

Designers often balance all of this by hand. I wanted to see if an algorithm could find palettes that are both pleasing and practical without the guesswork.

How it works

  1. You pick a primary color — e.g. your brand’s main color.

  2. The system tries to generate the other five key roles:

    • Accent color
    • Background color
    • Surface color (for cards/panels)
    • Button text color
    • Main text color
  3. Instead of random guesses, I use nature-inspired algorithms:

    • Hill Climbing: keep tweaking until it gets stuck.
    • Simulated Annealing: like Hill Climbing, but occasionally makes a “bad” move to explore better options later.
    • Genetic Algorithm: survival of the fittest palettes, mixing and mutating until something good emerges.
  4. Each candidate palette is scored by an objective function that rewards accessibility and allows for some creativity.

What I found

  • Hill Climbing is quick but often gets stuck.
  • Simulated Annealing is more thorough, but takes slightly longer.
  • Genetic Algorithms generated the most diverse palettes, but takes a lot longer to converge.

I tested the generated palettes on sample UI mockups, and they held up — buttons were visible, text was readable, and the overall vibe stayed clean and modern.