Skip to content

Instantly share code, notes, and snippets.

@syntagmatic
Last active January 30, 2017 02:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save syntagmatic/97f4c653539f910a2f80c36647768bd3 to your computer and use it in GitHub Desktop.
Save syntagmatic/97f4c653539f910a2f80c36647768bd3 to your computer and use it in GitHub Desktop.
Lab Color Space
<!DOCTYPE html>
<meta charset="utf-8">
<style>
</style>
<body>
<canvas id="painting" 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("painting");
var ctx = canvas.getContext("2d");
d3.range(0, canvas.width).forEach(function(x) {
d3.range(0, canvas.height).forEach(function(y) {
ctx.fillStyle = d3.lab(65, -100+200*x/canvas.width, -100+200*y/canvas.height);
ctx.fillRect(x, y, 1, 1);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment