Skip to content

Commit ddd054a

Browse files
authored
Merge pull request #171 from frifrafry/paintbucket-scale-fix
Bugfix: paintBucket on scaled (zoomed) canvas
2 parents af06768 + 1a54ad4 commit ddd054a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

js/paintBucket.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default class PaintBucket {
2323

2424
handleMouseDown(event) {
2525
const mainClass = event.target.classList[0];
26+
const scale = this.main.getScale();
2627
if (mainClass === 'ptro-crp-el') {
2728
this.init();
2829
this.colorLayerData = this.ctx.getImageData(0, 0, this.canvasWidth, this.canvasHeight);
@@ -33,9 +34,15 @@ export default class PaintBucket {
3334
}
3435

3536
this.active = true;
36-
const ptX = (event.clientX - this.main.elLeft()) + this.main.scroller.scrollLeft;
37-
const ptY = (event.clientY - this.main.elTop()) + this.main.scroller.scrollTop;
38-
this.paintAt(ptX, ptY);
37+
const cord = [
38+
(event.clientX - this.main.elLeft()) + this.main.scroller.scrollLeft,
39+
(event.clientY - this.main.elTop()) + this.main.scroller.scrollTop,
40+
];
41+
const cur = {
42+
x: cord[0] * scale,
43+
y: cord[1] * scale,
44+
};
45+
this.paintAt(cur.x, cur.y);
3946
}
4047
}
4148

0 commit comments

Comments
 (0)