Skip to content

Instantly share code, notes, and snippets.

Last active April 25, 2017 16:26
What would you like to do?
Lab Color Space Animation
<!DOCTYPE html>
<meta charset="utf-8">
<canvas id="painting" width=960 height=500>
<script src=""></script>
var canvas = document.getElementById("painting");
var ctx = canvas.getContext("2d");
d3.timer(function(elapsed) {
d3.range(0, canvas.width).forEach(function(x) {
var l = 65;
var a = -100+200*x/canvas.width
var b = 100*Math.sin(elapsed/600)
ctx.fillStyle = d3.lab(l,a,b)
ctx.fillRect(x, 0, 1, canvas.height)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment