Skip to content

Commit

Permalink
Don't stroke when the current path isn't in the current clip box
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Mar 6, 2024
1 parent 6bb6ce6 commit fe6d0c1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,17 @@ class CanvasExtraState {
this.maxY = 0;
}

isPathInClipBox() {
const {
clipBox: [x0, y0, x1, y1],
minX,
minY,
maxX,
maxY,
} = this;
return !(minX > x1 || maxX < x0 || minY > y1 || maxY < y0);
}

getClippedPathBoundingBox(pathType = PathType.FILL, transform = null) {
return Util.intersect(
this.clipBox,
Expand Down Expand Up @@ -1764,6 +1775,9 @@ class CanvasGraphics {
}

stroke(consumePath = true) {
if (!this.current.isPathInClipBox()) {
return;
}
const ctx = this.ctx;
const strokeColor = this.current.strokeColor;
// For stroke we want to temporarily change the global alpha to the
Expand Down

0 comments on commit fe6d0c1

Please sign in to comment.