From 7b620f7882eb2497bcb39596d7204c7d4c751c33 Mon Sep 17 00:00:00 2001 From: WenheLi Date: Wed, 20 Feb 2019 13:06:11 -0500 Subject: [PATCH] :bug: Fix custom framerate and download name --- package.json | 2 +- src/components/Capture.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 5520a85..198ea19 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/components/Capture.js b/src/components/Capture.js index 0e5e715..72011b1 100644 --- a/src/components/Capture.js +++ b/src/components/Capture.js @@ -17,7 +17,7 @@ export default class Capture { left: 0, width: -1, height: -1, - framerate: 10 + framerate: 5 }; config = {}; frames = []; @@ -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 } /** @@ -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"); } @@ -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;