Created
April 29, 2013 16:15
-
-
Save tmcw/5482673 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 Canvas = require('canvas'), | |
fs = require('fs'), | |
pad = require('pad'), | |
canvas = new Canvas(100, 100), | |
ctx = canvas.getContext('2d'); | |
ctx.antialias = 'none'; | |
function line(x) { | |
ctx.globalCompositeOperation = 'source-over'; | |
ctx.beginPath(); | |
ctx.lineTo(x - 100, 0); | |
ctx.lineTo(x, 100); | |
ctx.strokeStyle = '#eee'; | |
ctx.lineWidth = 4; | |
ctx.stroke(); | |
} | |
var i = 0; | |
for (var x = -100; x < 0; x++) { | |
canvas.width = 100; | |
ctx.fillStyle = '#fff'; | |
ctx.fillRect(0, 0, 100, 100); | |
for (var z = x; z < 400; z += 20) { | |
line(z); | |
} | |
fs.writeFileSync('frames/' + pad(15, (i++) + 'frame.png', '0'), canvas.toBuffer()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment