HSL / Hue Cycle
First appeared 1978 · Alvy Ray Smith — Cyclic hue rotation relies on the HSV/HSL colour model formalized by Alvy Ray Smith ("Color Gamut Transform Pairs", SIGGRAPH 1978); animated colour/palette cycling was a staple of 1980s–90s demo and games graphics. A diffuse technique with no single first. · timeline ↗
community / folk Name — Descriptive: cycling hue in the HSL colour space (Alvy Ray Smith, 1978). An index label for the technique, not a coined name.
In one line Generating rainbows and gradients by cycling hue around the colour wheel (HSL/HSV/Lab) as a function of position, index or time. The colouring behind Chromie Squiggle and many spectral palettes.
The code
The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.
hsl-cycle/index.html
const SEED = Math.floor(Math.random()*1e9);
function setup() {
randomSeed(SEED); noiseSeed(SEED);
const s = Math.min(windowWidth, windowHeight);
createCanvas(s, s);
colorMode(HSB, 360, 100, 100);
background(0, 0, 98);
noStroke();
// Chromie Squiggle inspired hue-cycle along a noise-perturbed path.
const SEGMENTS = 60;
const baseHue = random(360);
const hueSpan = random([180, 240, 320]);
const r = width * 0.05;
let x = width * 0.1;
let y = height * 0.5;
for (let i = 0; i < SEGMENTS; i++) {
const t = i / (SEGMENTS - 1);
const h = (baseHue + t * hueSpan) % 360;
fill(h, 80, 95);
circle(x, y, r * 2);
// Squiggle step: sine modulated by noise
const phase = noise(i * 0.18) * TWO_PI;
y += Math.sin(i * 0.5 + phase) * r * 0.55;
x += r * 1.2;
}
}How it works
Work in a cylindrical colour space (HSL/HSV) where hue is an angle 0–360°: 1. Drive hue from a parameter — e.g. hue = (i / n)·360 across n elements, or (x + t)·k along the canvas/time — keeping saturation and lightness fixed (or on their own gentle curves). 2. Wrap hue modulo 360 so it loops seamlessly; the span and speed set how many rainbow cycles appear. 3. Convert HSL→RGB to draw. Using a perceptual space (Lab/OKLCH) or eased hue steps avoids the muddy/uneven bands that naive HSL can produce. Variations: offset hue per layer, reverse direction, or quantise hue to a few stops for banded palettes instead of smooth spectra.
Parameters
hueStart: number — Starting hue in degrees.hueStep: number — Hue increment applied per element or per frame.saturation: number — Fixed saturation of the cycling palette.lightness: number — Fixed lightness of the cycling palette.cycleSpeed: number — How fast the hue advances over time.
Lineage
Frequently combined with
- Perlin / Simplex Noise · 55 works
- Bezier / Catmull-Rom Splines · 20 works
- Fragment Shader (GLSL) · 17 works
- Flow Field / Vector Field · 11 works
- Marching Squares / Contours · 10 works
- Particle System · 7 works
- Glitch / Datamosh · 6 works
- Audio-Reactive · 6 works
- Quadtree / Recursive Quad Split · 5 works
- Domain Warping · 3 works
- Boids / Flocking · 3 works
- Cellular Automata · 3 works
Works using this algorithm (134)
Last updated 2026-07-16