It appears that Safari and Chrome behave differently when doing a drawImage

with coordinates that are outside the source. Chrome appears to draw the
piece of the image that is within the area specified on the drawImage and within
the source. Safari bails and draws nothing if (I think) any of the corners are outside
the source.
This commit is contained in:
philip
2020-04-03 21:54:42 +00:00
parent 6e2d8cc266
commit 665a8275f6

View File

@@ -314,13 +314,7 @@ export function render(width, height, pixelRatio,
context.scale(sourceResolution / pixelRatio,
-sourceResolution / pixelRatio);
const sourceTriangleExtent = boundingExtent(source);
const topLeftX = Math.floor((sourceTriangleExtent[0] - sourceDataExtent[0]) * stitchScale);
const topLeftY = Math.floor((sourceDataExtent[3] - sourceTriangleExtent[3]) * stitchScale);
const width = Math.ceil((sourceTriangleExtent[2] - sourceTriangleExtent[0]) * stitchScale) + 2;
const height = Math.ceil((sourceTriangleExtent[3] - sourceTriangleExtent[1]) * stitchScale) + 2;
context.drawImage(stitchContext.canvas, topLeftX, topLeftY, width, height, topLeftX, topLeftY, width, height);
context.drawImage(stitchContext.canvas, 0, 0);
context.restore();
});