Last active
August 29, 2015 14:18
-
-
Save mmchugh/e2ef0c6fa36f16484741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rAS = require('request-animation-stream'); | |
var canvas_el = document.getElementById('main-canvas'); | |
var context = canvas_el.getContext('2d'); | |
var render_stream = rAS(true, true); | |
var blue = 0; | |
var red = 0; | |
function render(data) { | |
context.fillStyle = data | |
context.fillRect (10, 10, 235, 480); | |
blue += 5; | |
if (blue > 255) { | |
blue = 0; | |
} | |
context.fillStyle = "rgba(0, 0, " + blue + ", 1)"; | |
context.fillRect (255, 10, 235, 480); | |
} | |
function incrementColour() { | |
red += 5; | |
if (red > 255) { | |
red = 0; | |
} | |
render_stream.write("rgba(" + red + ", 0, 0, 1)"); | |
} | |
render_stream.on('data', render); | |
setInterval(incrementColour, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment