Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created February 6, 2013 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/4723800 to your computer and use it in GitHub Desktop.
Save tmcw/4723800 to your computer and use it in GitHub Desktop.
making the gif for bigclicker
var Canvas = require('canvas'),
fs = require('fs'),
pad = require('pad'),
canvas = new Canvas(200,200),
ctx = canvas.getContext('2d');
ctx.antialias = 'none';
function line(x) {
ctx.globalCompositeOperation = 'source-over';
ctx.beginPath();
ctx.lineTo(x, 0);
ctx.lineTo(x + (100 * (Math.sqrt(2)/3)), 100);
ctx.lineTo(x, 200);
ctx.strokeStyle = '#fff';
ctx.lineWidth = 2;
ctx.stroke();
}
function mask() {
radius = 100;
ctx.fillStyle = '#000';
ctx.globalCompositeOperation = 'destination-atop';
ctx.beginPath();
ctx.arc(radius, radius, radius * 0.95, 0, Math.PI*2, true);
ctx.closePath();
ctx.fill();
}
var i = 0;
for (var x = -60; x < -20; x++) {
canvas.width = 200;
for (var z = x; z < 200; z += 20) {
line(z);
}
mask();
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