Non-linear interpolation for colour gradients


#1

Is there a way to change the interpolation of a colour gradient? I know I can add extra colour stops but that doesn’t help much. As far as I can see the interpolation is done in ColourGradient::createLookupTable(). I’d love to be able to supply a lambda for this. But anything would be great. What would be the best approach to do this?


#2

What do you mean that it doesn’t help much to add extra gradient stops? If you add enough, you can approximate any curve like that!


#3

Yes, that’s correct. But it’s not really elegant and seems to be a bit too much.


#4

Not sure what you think is wrong with it! The way all rendering engines work is that the gradients are supplied as just a sequence of colours. Whether that’s generated by lots of linear stops or generated by an equation really makes no difference to the result.