Make a loading gif with gifsicle, node-canvas, and graphicsmagick.
Created
March 13, 2013 16:38
-
-
Save tmcw/5153896 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
TOGIF = gm mogrify -format gif | |
all: anim.gif | |
*.pre.png: loading.js | |
node loading.js | |
*.pre.gif: *.pre.png | |
$(TOGIF) *.pre.png | |
anim.gif: *.pre.gif | |
gifsicle -d10 --loop *.pre.gif > anim.gif |
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
{ | |
"name": "img", | |
"version": "0.0.0", | |
"description": "ERROR: No README.md file found!", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": "", | |
"author": "", | |
"license": "BSD", | |
"dependencies": { | |
"canvas": "~1.0.1", | |
"pad": "0.0.4" | |
} | |
} |
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'), | |
pad = require('pad'), | |
fs = require('fs'); | |
var w = 10, h = 10; | |
var c = new Canvas(w, h); | |
var ctx = c.getContext('2d'); | |
ctx.strokeStyle = '#C5CBCE'; | |
ctx.lineWidth = 2; | |
for (var i = 0; i < 10; i++) { | |
ctx.fillStyle = '#E2E2E2'; | |
ctx.fillRect(0, 0, 10, 10); | |
ctx.beginPath(); | |
ctx.moveTo(i - 10, 0); | |
ctx.lineTo(i, 10); | |
ctx.stroke(); | |
ctx.beginPath(); | |
ctx.moveTo(i, 0); | |
ctx.lineTo(i + 10, 10); | |
ctx.stroke(); | |
fs.writeFileSync(pad(3, i, '0') + '.pre.png', c.toBuffer()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment