HeadlinesBriefing favicon HeadlinesBriefing.com

Danielle Navarro’s Efficient R Cosine Palette Technique

Hacker News •
×

Danielle Navarro publishes a concise post on generating continuous colour palettes in R. She draws on Mike Cheng’s Mastodon tip and Inigo Quilez’s procedural approach, framing palettes with a simple cosine rule. The method picks four base colours, then blends them across a 0‑to‑1 span to create smooth gradients for designers and developers in art.

Navarro implements the formula in a compact R function, adding a seed parameter to guarantee reproducibility. With a random seed, the function samples base colours from R’s built‑in palette, normalises them, and evaluates the cosine expression for each t in a sequence. The result is a 256‑colour strip ready for visualisation in generative art projects.

To test palette quality, Navarro feeds seeds 11 through 22 into a subdivision algorithm that recursively splits rectangles. Each plot colours regions by interpolating the palette, producing abstract compositions that vary with the seed. Some renderings appear chaotic, others striking, demonstrating the method’s flexibility without heavy optimisation for creative experiments in data visualisation and design.

The article concludes that simple cosine‑based palettes perform well in generative contexts, matching the aesthetic of both subdivision and Lissajous‑based artworks. Navarro’s code, openly shared, offers a lightweight alternative to complex colour‑generation libraries. The post demonstrates that concise, reproducible scripts can deliver compelling visual results for developers and artists seeking efficient palette generation that scales.