Fix slice sometimes crashing with 0 width/height segments

master
Will Toohey 8 years ago
parent 0400358f7f
commit c83509a79c
  1. 8
      src/js/HuesCanvas.js

@ -247,16 +247,16 @@ class HuesCanvas {
for (let i = 0; i < this.slices.x.count; i++) { for (let i = 0; i < this.slices.x.count; i++) {
let xSegment = this.slices.x.segments[i]; let xSegment = this.slices.x.segments[i];
let sliceXDistance = this.slices.x.distances[i] * this.sliceDistance; let sliceXDistance = this.slices.x.distances[i] * this.sliceDistance;
let segmentBitmapWidth = Math.round(xSegment * bitmap.width); let segmentBitmapWidth = Math.ceil(xSegment * bitmap.width);
let segmentDrawWidth = Math.round(xSegment * drawWidth); let segmentDrawWidth = Math.ceil(xSegment * drawWidth);
let bitmapYOffset = 0; let bitmapYOffset = 0;
let drawYOffset = 0; let drawYOffset = 0;
for (let j = 0; j < this.slices.y.count; j++) { for (let j = 0; j < this.slices.y.count; j++) {
let ySegment = this.slices.y.segments[j]; let ySegment = this.slices.y.segments[j];
let sliceYDistance = this.slices.y.distances[j] * this.sliceDistance; let sliceYDistance = this.slices.y.distances[j] * this.sliceDistance;
let segmentBitmapHeight = Math.round(ySegment * bitmap.height); let segmentBitmapHeight = Math.ceil(ySegment * bitmap.height);
let segmentDrawHeight = Math.round(ySegment * drawHeight); let segmentDrawHeight = Math.ceil(ySegment * drawHeight);
this.offContext.drawImage(bitmap, this.offContext.drawImage(bitmap,
bitmapXOffset, bitmapYOffset, // subsection x, y bitmapXOffset, bitmapYOffset, // subsection x, y

Loading…
Cancel
Save