From 0312b1c97f9aa5303b60b7adb31dd6e2413260bd Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Thu, 25 Nov 2010 09:58:18 -0800 Subject: [PATCH] ray example using toBuffer() --- examples/ray.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/ray.js b/examples/ray.js index 266214b..93b325a 100644 --- a/examples/ray.js +++ b/examples/ray.js @@ -79,9 +79,7 @@ ctx.translate(243,0); render(1); console.log('Rendered in %s seconds', (new Date - start) / 1000); -var out = fs.createWriteStream(__dirname + '/ray.png') - , stream = canvas.createPNGStream(); - -stream.on('data', function(chunk){ - out.write(chunk); -}); \ No newline at end of file +canvas.toBuffer(function(err, buf){ + if (err) throw err; + fs.writeFile(__dirname + '/ray.png', buf); +});