Skip to content

Commit

Permalink
🐛 Fix custom framerate and download name
Browse files Browse the repository at this point in the history
  • Loading branch information
WenheLI committed Feb 20, 2019
1 parent 483c718 commit 7b620f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p5.gif",
"version": "1.0.1",
"version": "1.0.2",
"scripts": {
"build": "npx grunt",
"lint": "npx eslint ./src/*.js ./src/components/*.js"
Expand Down
8 changes: 4 additions & 4 deletions src/components/Capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class Capture {
left: 0,
width: -1,
height: -1,
framerate: 10
framerate: 5
};
config = {};
frames = [];
Expand All @@ -28,7 +28,7 @@ export default class Capture {
}

get delay() {
return Math.max(parseInt(1000 / this.settings.framerate, 10), 50);
return Math.max(parseInt(1000 / this.settings.framerate, 10), 30); //limit the framerate below 30
}

/**
Expand All @@ -41,7 +41,7 @@ export default class Capture {
if (!this.settings.canvas) throw P5GIFError("cannot find such canvas");
if (this.settings.width < 0 || this.settings.width > this.settings.canvas.width) this.settings.width = this.settings.canvas.width;
if (this.settings.height < 0 || this.settings.height > this.settings.canvas.height) this.settings.height = this.settings.canvas.height;
if (this.settings.framerate > 15) this.settings.framerate = 20;
if (this.settings.framerate > 30) this.settings.framerate = 30;
this.settings.context = this.settings.canvas.getContext("2d");
}

Expand Down Expand Up @@ -120,7 +120,7 @@ export default class Capture {
let {left, top, width, height} = that.settings;
if (stopAfterFrame <= 0 || stopAfterFrame > that.frames.length) that.frames.push(that.settings.context.getImageData(left, top, width, height).data);
}, {
tickIntv: this.delay,
tickIntv: that.delay,
infinite: true
}).start();
return this;
Expand Down

0 comments on commit 7b620f7

Please sign in to comment.