I'd like to create a shape gradiently filled with visible light spectrum colors - from red to blue. I am using Inkscape. When I try to specify gradient from red to blue - it chooses a weird color path. Any help would be appreciated


1 Answer 1


This has to do with the algorithm that InkScape and other graphics programs use to create gradients, namely (pseudo-code):

var gradient = []
var firstColor, secondColor, steps
for i in range(steps):
  p = i/steps
  R = firstColor.R * p + secondColor.R * (1 - p)
  G = firstColor.G * p + secondColor.G * (1 - p)
  B = firstColor.B * p + secondColor.B * (1 - p)

The spectrum of visible light doesn't work this way though, because real world color isn't RGB. RGB is a method to trick the eyes to see many colors with few colors, just like CMYK.

Now technically, your question has no answer, because...

Color displays (e.g. computer monitors and televisions) cannot reproduce all colors discernible by a human eye. Colors outside the color gamut of the device, such as most spectral colors, can only be approximated.

But let's say you want to make the approximation in InkScape. Unfortunately, you can only do this by making a big gradient with all of the colors, the SVG standard has no flag for "visible light gradients".

Using this image from Wikipedia...

spectrum edited in inkscape

You can move the two control points around until they only show the gradient from red to blue :)

new spectrum

Alternatively, you could use the Gradient Editor to flip the order of the colors and delete all the colors before and after red and blue.


Not the answer you're looking for? Browse other questions tagged or ask your own question.