Home▸Animals & Their World▸Cuttlefish Camouflage Lab (2D)

Cuttlefish Camouflage Lab (2D)

Interactive 2D cuttlefish chromatophore lab: a gradient-descent pigment controller chases the reef's sampled colour under the animal in real time, scored with the redmean colour-difference formula, across a procedurally generated sand/coral/rock/kelp reef.

Animals & Their World2DModerate60 FPS⇄ 3D version
2d-cuttlefish-camouflage-lab ↗ Open standalone

This 2D top-down companion drives a real closed-loop chromatophore controller rather than a decorative colour slider: three pigment channels — yellow, red-brown and black, layered over a pale iridophore base — are adjusted every frame by a gradient-descent step that pushes the cuttlefish's rendered skin colour toward whatever colour a procedurally generated reef shows directly underneath it. Match quality is scored with the redmean formula, a low-cost approximation of perceptual colour difference used in real image-processing pipelines, so the on-screen percentage reflects an actual colour-space distance rather than an arbitrary number. Turning up reaction speed closes the gap faster after the cuttlefish drifts across a patch boundary; turning up swim speed forces it to cross boundaries more often, so the controller is constantly re-adapting instead of settling.

⚙ Under the hood

A gradient-descent chromatophore controller (three pigment channels over a pale base) chases the reef colour sampled directly under the cuttlefish, scored each frame with the redmean perceptual colour-difference formula, across a procedurally generated sand/coral/rock/kelp reef built from a coarse random grid with bilinear interpolation.

Canvas 2DCuttlefish CamouflageChromatophoresRedmean Colour DistanceGradient Descent Control

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)