Remove the CanvasGraphics.getCanvasPosition method

This old method, which is only used with the `imageLayer` functionality, is essentially just a re-implementation of the existing `Util.applyTransform` method.
This commit is contained in:
Jonas Jenwald 2022-08-25 12:58:44 +02:00
parent 14e8167df9
commit 3c8aeb445a

View File

@ -3067,11 +3067,14 @@ class CanvasGraphics {
); );
if (this.imageLayer) { if (this.imageLayer) {
const position = this.getCanvasPosition(0, -height); const [left, top] = Util.applyTransform(
[0, -height],
getCurrentTransform(this.ctx)
);
this.imageLayer.appendImage({ this.imageLayer.appendImage({
imgData, imgData,
left: position[0], left,
top: position[1], top,
width: rWidth, width: rWidth,
height: rHeight, height: rHeight,
}); });
@ -3109,11 +3112,14 @@ class CanvasGraphics {
1 1
); );
if (this.imageLayer) { if (this.imageLayer) {
const position = this.getCanvasPosition(entry.x, entry.y); const [left, top] = Util.applyTransform(
[entry.x, entry.y],
getCurrentTransform(this.ctx)
);
this.imageLayer.appendImage({ this.imageLayer.appendImage({
imgData, imgData,
left: position[0], left,
top: position[1], top,
width: w, width: w,
height: h, height: h,
}); });
@ -3309,14 +3315,6 @@ class CanvasGraphics {
} }
} }
getCanvasPosition(x, y) {
const transform = getCurrentTransform(this.ctx);
return [
transform[0] * x + transform[2] * y + transform[4],
transform[1] * x + transform[3] * y + transform[5],
];
}
isContentVisible() { isContentVisible() {
for (let i = this.markedContentStack.length - 1; i >= 0; i--) { for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
if (!this.markedContentStack[i].visible) { if (!this.markedContentStack[i].visible) {