Like this:
function colourGradientor(p, rgb_beginning, rgb_end){ var w = p * 2 - 1; var w1 = (w + 1) / 2.0; var w2 = 1 - w1; var rgb = [parseInt(rgb_beginning[0] * w1 + rgb_end[0] * w2), parseInt(rgb_beginning[1] * w1 + rgb_end[1] * w2), parseInt(rgb_beginning[2] * w1 + rgb_end[2] * w2)]; return rgb; };
where p is a value from 0 to 1 that determines how far the gradient can go, and the color rgb_beginning is the color and rgb_end is the color. Both arrays are [r, g, b], so you will need to convert from hex first. This is a simplified version of the LESS mix function, which, it seems to me, relates to SASS. For a poster, p will be 0.5
Rested Jun 16 '14 at 22:36 2014-06-16 22:36
source share