From 1707379e78152fd3814ce4333b1e42a97b31a894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Fri, 1 Nov 2019 11:00:42 +0100 Subject: [PATCH] add option for discarding partial frames --- src/components/Player.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Player.vue b/src/components/Player.vue index 3242b19..c121505 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -32,6 +32,10 @@ +
+ + +
@@ -55,6 +59,7 @@ export default { fullscreen: false, sortBySize: false, sortDirection: false, + discardPartial: false, position: 0, tmp_ctx: null, animation_id: null, @@ -68,7 +73,8 @@ export default { computed: { frames: function () { if (this.image === null) return 0; - return Math.ceil((this.image.width - this.offset[0]) / this.width) * Math.ceil((this.image.height - this.offset[1]) / this.height); + const roundFn = this.discardPartial ? Math.floor : Math.ceil; + return roundFn((this.image.width - this.offset[0]) / this.width) * roundFn((this.image.height - this.offset[1]) / this.height); }, canvas_height: function () { return this.height * this.zoom; @@ -81,7 +87,7 @@ export default { let sequence = []; for (let pos = 0; pos < this.frames; pos++) { - let wb = Math.ceil((this.image.width - this.offset[0]) / this.width); // width_blocks + let wb = (this.discardPartial ? Math.floor : Math.ceil)((this.image.width - this.offset[0]) / this.width); // width_blocks let x = this.offset[0] + (pos % wb) * this.width; // x offset let w = x + this.width < this.image.width ? this.width : this.image.width - x; // frame width let y = this.offset[1] + Math.floor(pos / wb) * this.height; // y offset