eugeneware / gifencoder

Server side animated gif generation for node.js
Other
472 stars 49 forks source link

Dispose not disposing frames #9

Closed Nickstr closed 7 years ago

Nickstr commented 8 years ago
var gif = new GifEncoder(420, 240);
var canvas = new Canvas(420, 240);
var ctx = canvas.getContext('2d');

gif.start();
gif.setRepeat(0); 
gif.setDelay(500);
gif.setTransparent('#000000');
gif.setDispose(2)

ctx.fillStyle = 'yellow';
ctx.fillRect(43, 34, 100, 100);
gif.addFrame(ctx);

ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 100, 100);
gif.addFrame(ctx);

ctx.fillStyle = 'blue';
ctx.arc(150,150,50,0,Math.PI*2,true);
ctx.fill();
gif.addFrame(ctx);

gif.finish();

Result: 192 168 99-1

I expected it to dispose frames when it goes to the next one and only show 1 shape per frame.

heikkipora commented 7 years ago

@Nickstr You must clear the canvas between frames to have the desired effect.