Colours & XML - snoplus/snogoggles GitHub Wiki

Colour Palette

Each colour palette has 10 primary colours [0,9] and then a series of colour stops. Each colour stop has a fractional value and a colour. When a colour is required by a fractional value [0.0, 1.0] the colour returned is the linearly interpolated colour between the two closest colour stops. For example consider 3 colour stops red at 0.0, green at 0.5 and blue at 1.0 the returned colour c for 0.2 is:

c.r = red.r + (0.2 / 0.5) * (blue.r - red.r)
c.g = red.g + (0.2 / 0.5) * (blue.g - red.g)
c.b = red.b + (0.2 / 0.5) * (blue.b - red.b)
c.a = red.a + (0.2 / 0.5) * (blue.a - red.a)