Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<div id="wrapper"></div>
<script>
var count = 30;
var start = 'ffcc00';
var end = '6699cc';
var sR = parseInt(start.slice(0, 2), 16);
var sG = parseInt(start.slice(2, 4), 16);
var sB = parseInt(start.slice(4, 6), 16);
var eR = parseInt(end.slice(0, 2), 16);
var eG = parseInt(end.slice(2, 4), 16);
var eB = parseInt(end.slice(4, 6), 16);
var stepR = (eR - sR) / count;
var stepG = (eG - sG) / count;
var stepB = (eB - sB) / count;
var wrapper = document.getElementById('wrapper');
for (var i = 0; i < count; i++) {
sR += stepR;
sG += stepG;
sB += stepB;
span.innerHTML = '&nbsp;';
span.style.background = 'rgb(' + Math.round(sR) + ',' + Math.round(sG) + ',' + Math.round(sB) + ')';
wrapper.appendChild(span);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment