Category Color Generator

(note: d3.jab("white") = {J: 100, a: 0, b: 0})

Allowed colors:

Slow hex codes

Status

Some example constraints

// All colours with integer J.a.b. values
function constraint({J, a, b}) { 
  return true;
}

// Constant distance to a given colour:
function constraint({J, a, b}) {   
  var centre = d3.jab(120, 20, 20); // J, a, b
  var dist = jab_dist(centre, d3.jab(J, a, b));
  return (75 < dist && dist < 76);
}

// other functions..
return 30*30 < a*a+b*b ; // No greys
return a + b < 10; // no red
return J < 30; // dark
return 80 < J; // light
return jab_dist(d3.jab(J, a, b), d3.jab("blue")) < 50; // blues
return jab_dist(d3.jab(J, a, b), d3.jab("red")) < 50; // reds
return jab_dist(d3.jab(J, a, b), d3.jab("#00ff00")) > 70; // no greens
return rgb().r > 230; // Strong red channel
  

About

Click Start to generate a continuous sequence of distinct colours for diagrams.

You can alter the "constraint" function to filter colours before the selection process starts.

Sampling is done in the CIECAM02-UCS color space so that perceptually different colours are equally spaced. The sampler always chooses the next colour to be as far as possible from all the previously sampled colours.

Bibliography:

  1. bl.ocks.org/mbostock/310c99e53880faec2434
    For introducing the idea of perceptual color
  2. medialab: iwanthue
    Generating fixed-size palettes of optimal colours using the LAB colour space. Spacing done with repulsive forces or kNN clustering.
  3. colorcodehex and Lab color space for the description of the LAB color spaces.
  4. Low-discrepancy sequence Methods for nice multidimensional sampling
  5. Piotr Migdal's infinite color generator for the idea of sampling all possible colors (instead of just certain slices of lightness).
  6. Matthew Sarsby's colour picking by simulation only works for up to about 12 colours (20 was reaaaaaaaly slow).
  7. Martin Ankerl's HSV + Golden Ratio intervals is quite good (although limited to a single brightness)