Skip to content

Instantly share code, notes, and snippets.

@eeropic
Created January 1, 2018 18:23
Show Gist options
  • Select an option

  • Save eeropic/c1c6a4303d90f49a3b4b198a6a15d81e to your computer and use it in GitHub Desktop.

Select an option

Save eeropic/c1c6a4303d90f49a3b4b198a6a15d81e to your computer and use it in GitHub Desktop.
GIF.js test
var gif = new GIF({
workers: 2,
quality: 10
});
gif.on('finished', function(blob) {
window.open(URL.createObjectURL(blob));
});
var rect=new Path.Rectangle([0,0],[200,200])
rect.fillColor="red"
var myTool=new Tool();
myTool.on({
mousedown(e){
this.path=new Path()
this.path.strokeColor="black"
this.path.strokeWidth=2
},
mousedrag(e){
this.path.add(e.point)
},
mouseup(e){
},
keydown(e){
if(e.key=="1"){
canvas=document.getElementById('canvas');
ctx = canvas.getContext('2d');
gif.addFrame(canvas, {copy: true,delay: 100});
//console.log(ctx.canvas.height)
}
if(e.key=="2"){
gif.render();
console.log('sepp doooo')
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment