Skip to content

Commit

Permalink
Prevent distortion of area select rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
webfiltered committed Dec 5, 2024
1 parent 38227a9 commit 52a0e20
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/LGraphCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4412,15 +4412,27 @@ export class LGraphCanvas {
}
}

// the selection rectangle
// Area-selection rectangle
if (this.dragging_rectangle) {
const { eDown, eMove } = this.pointer
ctx.strokeStyle = "#FFF"
ctx.strokeRect(
this.dragging_rectangle[0],
this.dragging_rectangle[1],
this.dragging_rectangle[2],
this.dragging_rectangle[3],
)

if (eDown && eMove) {
// Do not scale the selection box
const transform = ctx.getTransform()
const ratio = window.devicePixelRatio
ctx.setTransform(ratio, 0, 0, ratio, 0, 0)

const x = eDown.offsetX
const y = eDown.offsetY
ctx.strokeRect(x, y, eMove.offsetX - x, eMove.offsetY - y)

ctx.setTransform(transform)
} else {
// Fallback to legacy behaviour
const [x, y, w, h] = this.dragging_rectangle
ctx.strokeRect(x, y, w, h)
}
}

// on top of link center
Expand Down

0 comments on commit 52a0e20

Please sign in to comment.