Skip to content

Instantly share code, notes, and snippets.

@jhnsnc
Created March 15, 2017 18:43
Show Gist options
  • Save jhnsnc/d9ab68ac31b5ef007684df7851d2a9bf to your computer and use it in GitHub Desktop.
Save jhnsnc/d9ab68ac31b5ef007684df7851d2a9bf to your computer and use it in GitHub Desktop.
function colorInterpolate(t) {
var color1 = 0xffcc00;
var color2 = 0x0066ff;
var r = Math.floor((color2>>16)*t + (color1>>16)*(1-t));
var g = Math.floor((color2>>8&0xff)*t + (color1>>8&0xff)*(1-t));
var b = Math.floor((color2&0xff)*t + (color1&0xff)*(1-t));
return '#' + ((1<<24)+(r<<16)+(g<<8)+b).toString(16).slice(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment