add option for discarding partial frames

master
Tomáš Mládek 2019-11-01 11:00:42 +01:00
parent 7ef1778cad
commit 1707379e78
1 changed files with 8 additions and 2 deletions

View File

@ -32,6 +32,10 @@
</label>
<input type="checkbox" v-model="sortDirection" id="sortDirection">
</div>
<div>
<label for="discard">Discard partial frames</label>
<input type="checkbox" v-model="discardPartial" id="discard">
</div>
</div>
</div>
</template>
@ -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