Created
July 2, 2012 23:51
-
-
Save tmcw/3036472 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'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var _ = require('./underscore.string.js'); | |
var post_dir = '/Users/tmcw/Sites/tmcw.github.com/_posts/'; | |
var posts = fs.readdirSync(post_dir); | |
var txt = posts.filter(function(f) { | |
return f.indexOf('.md') !== -1; | |
}).map(function(p) { | |
return fs.readFileSync(path.join(post_dir, p), 'utf8'); | |
}); | |
var w = 640, | |
h = 280; | |
var c = new Canvas(w, h); | |
var ctx = c.getContext('2d'); | |
ctx.fillStyle = '#fff'; | |
ctx.fillRect(0, 0, w, h); | |
ctx.fillStyle = '#000'; | |
ctx.font = '5pt Helvetica'; | |
ctx.globalAlpha = 0.1; | |
txt.map(function(t) { | |
var pts = _.chop(t, 200); | |
if (pts) pts.map(function(p, i) { | |
ctx.fillText(p, 5, 10 + i * 4); | |
}); | |
}); | |
fs.writeFileSync('posts.png', c.toBuffer()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment