Skip to content

Instantly share code, notes, and snippets.

@benfletcher
Created March 23, 2017 00:57
Show Gist options
  • Save benfletcher/7948f83a0b62079861f2d639bf8049f8 to your computer and use it in GitHub Desktop.
Save benfletcher/7948f83a0b62079861f2d639bf8049f8 to your computer and use it in GitHub Desktop.
Temporal dithering
var swatch = document.createElement('div');
swatch.style.width = 500;
swatch.style.height = 500;
document.body.appendChild(swatch);
function turnRed() {
swatch.style.backgroundColor = 'red';
requestAnimationFrame(turnBlue);
}
function turnBlue() {
swatch.style.backgroundColor = 'blue';
requestAnimationFrame(turnRed);
}
requestAnimationFrame(turnRed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment