Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Color and colorspaces
Last updated at 6:30 pm UTC on 19 May 2022
In short: The right color space to use for interpolating colors is CIELAB (aka L-a-b or LAB or Lab), which is carefully designed to be perceptually uniform. RGB is dramatically non-uniform, do not interpolate in that color space because you're in for a world of hurt. Unfortunately, while HSV/HSL is more uniform than RGB in the colorful dimensions, it isn't truly uniform either in the black-and-white dimension, so it's not a good bet. If you do the math in the CIELAB space you don't need to think about gamma correction, that will just confuse the issue.

Tools

Example D3 code plus explanations from Mike Bostock at https://bl.ocks.org/mbostock/3014589
Observable notebook with some examples and analysis of interpolation in different color spaces from Zan Armstrong at https://observablehq.com/@zanarmstrong/comparing-interpolating-in-different-color-spaces

Interactive demo from Carlos Scheidegger at https://cscheid.net/projects/color-interpolation/
LAB/Lch color gradient generator at https://davidjohnstone.net/lch-lab-colour-gradient-picker
Older but in-depth post from Gregor Aisch (with a lot of commentary from experts below) at https://www.vis4.net/blog/2011/12/avoid-equidistant-hsv-colors/

In long:

For more on color here's the three relevant videos from my visualization course. The third one goes a bit into the question of color spaces in the first seven minutes, but it might make more sense if you watch the first one to establish some basics first. The second one is mostly focused on the issue of colorblindness.


Info provided courtesy of Professor Tamara Munzner, Department of Computer Science, University of British Columbia