Browse Source

Remaining examples using streaming apu

v1.x
Tj Holowaychuk 14 years ago
parent
commit
ef6a8fb36d
  1. 10
      examples/clock.js
  2. 10
      examples/globalAlpha.js

10
examples/clock.js

@ -5,7 +5,8 @@
var Canvas = require('../lib/canvas') var Canvas = require('../lib/canvas')
, canvas = new Canvas(320, 320) , canvas = new Canvas(320, 320)
, ctx = canvas.getContext('2d'); , ctx = canvas.getContext('2d')
, fs = require('fs');
function getX(angle) { function getX(angle) {
return -Math.sin(angle + Math.PI); return -Math.sin(angle + Math.PI);
@ -104,4 +105,9 @@ function clock(ctx){
clock(ctx); clock(ctx);
canvas.savePNG(__dirname + "/clock.png"); var out = fs.createWriteStream(__dirname + '/clock.png')
, stream = canvas.createPNGStream();
stream.on('data', function(chunk){
out.write(chunk);
});

10
examples/globalAlpha.js

@ -5,7 +5,8 @@
var Canvas = require('../lib/canvas') var Canvas = require('../lib/canvas')
, canvas = new Canvas(150, 150) , canvas = new Canvas(150, 150)
, ctx = canvas.getContext('2d'); , ctx = canvas.getContext('2d')
, fs = require('fs');
ctx.fillStyle = '#FD0'; ctx.fillStyle = '#FD0';
ctx.fillRect(0,0,75,75); ctx.fillRect(0,0,75,75);
@ -27,4 +28,9 @@ for (i=0;i<7;i++){
ctx.fill(); ctx.fill();
} }
canvas.savePNG(__dirname + '/globalAlpha.png'); var out = fs.createWriteStream(__dirname + '/globalAlpha.png')
, stream = canvas.createPNGStream();
stream.on('data', function(chunk){
out.write(chunk);
});
Loading…
Cancel
Save