built during d3 fun time with kai chang
forked from alecburch's block: color scale
license: mit |
built during d3 fun time with kai chang
forked from alecburch's block: color scale
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
</style> | |
<body> | |
<canvas id="myCanvas" width=960 height=500> | |
<script src="https://d3js.org/d3.v4.0.0-alpha.45.js"></script> | |
<script src="https://d3js.org/d3-hsv.v0.0.js"></script> | |
<script src="https://d3js.org/d3-scale-chromatic.v0.3.js"></script> | |
<script> | |
var canvas = document.getElementById("myCanvas"); | |
var ctx = canvas.getContext("2d"); | |
var width = canvas.width; | |
var height = canvas.height; | |
d3.range(0, width).forEach(function(x) { | |
d3.range(0, width).forEach(function(y) { | |
var myColor = d3.hcl(500 + 360 * x / width, 100, 500 * y / height); | |
ctx.fillStyle = myColor; | |
ctx.fillRect(x, y, 1, 1); | |
}); | |
}); | |
</script> | |