Skip to main content
100%

Rainbows are Harmful

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Aug 8, 2012

This example uses a rainbow color scale to recolor an existing image, demonstrating how the popular hue-cycling ramp distorts perceptual ordering. It loads a bitmap via an HTML `Image` object, draws it to a Canvas, and then reads its pixel data with `getImageData`. The code remaps each pixel’s red channel using `d3.scale.linear` with an HSL interpolation from 0 to 360 degrees, then writes the new RGB values back with `putImageData`. The result visibly replaces the original colors with a smooth but misleading spectrum, illustrating the scale’s perceptual non-uniformity.

AI-generated description
gpl-3.0 Licensed

Similar vizzes