// Get a random colour on the above spectrum i(Math.random());
Results will vary depending on the colour space used, play with the options.
When using a hue-based colour space, the hue option sets the logic for how hue values wrap.
Example: Draw the interpolation as a spectrum on a canvas, where each pixel is one step
letv = 0; letincrementBy = 0.01; while (v <= 1) { // Get colour at this interpolation point 0..1 constcolour = fn(v); // Convert to a CSS string ctx.fillStyle = Colour.toCssColour(colour); // Draw a 1px wide rect, and shuffle along to the next x position ctx.fillRect(x, y, 1, h); x += 1; v += incrementBy; }
Returns a function to interpolate between colours, with results as a structured Colour object.
Results will vary depending on the colour space used, play with the options. When using a hue-based colour space, the
hueoption sets the logic for how hue values wrap.Example: Draw the interpolation as a spectrum on a canvas, where each pixel is one step