Skip to content

Commit

Permalink
[blipFill] Fix rotation when drawing stretch (rotWithShape)
Browse files Browse the repository at this point in the history
  • Loading branch information
belozertsev committed Jan 16, 2025
1 parent 130f65a commit da307c6
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions word/Drawing/ShapeDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ CShapeDrawer.prototype =
y: absoluteY,
width: absoluteWidth,
height: absoluteHeight
}
};
}

const isTransparent = (this.UniFill.transparent != null) && (this.UniFill.transparent !== 255);
Expand All @@ -1716,8 +1716,22 @@ CShapeDrawer.prototype =
: this.Graphics.isSupportTextDraw() && !this.Graphics.isTrack();

const oldGlobalAlpha = this.Graphics.m_oContext.globalAlpha;
if (isTransparent && isTransparencySupported)
if (isTransparent && isTransparencySupported) {
this.Graphics.m_oContext.globalAlpha = this.UniFill.transparent / 255;
}

const rotation = this.UniFill.fill.rotWithShape || this.UniFill.fill.rotWithShape === null
? 0
: -this.Shape.getFullRotate();

if (rotation !== 0) {
const centerX = (this.min_x + this.max_x) / 2;
const centerY = (this.min_y + this.max_y) / 2;

this.Graphics.m_oContext.translate(centerX, centerY);
this.Graphics.m_oContext.rotate(rotation);
this.Graphics.m_oContext.translate(-centerX, -centerY);
}

const alpha = undefined; // Not supported in this.Graphics.drawImage yet?
this.Graphics.drawImage(
Expand All @@ -1728,8 +1742,9 @@ CShapeDrawer.prototype =
this.UniFill.fill.canvas
);

if (isTransparent && isTransparencySupported)
if (isTransparent && isTransparencySupported) {
this.Graphics.m_oContext.globalAlpha = oldGlobalAlpha;
}
}

this.Graphics.restore();
Expand Down

0 comments on commit da307c6

Please sign in to comment.