From b1fecac60af1d1b868dcb8c9cc0f8971b87d0a8a Mon Sep 17 00:00:00 2001 From: NiBrc <26893899+NiBrc@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:25:23 +0100 Subject: [PATCH] fixed device scaling ratio as outlined in https://github.com/jacomyal/sigma.js/issues/1399 --- packages/sigma/src/sigma.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/sigma/src/sigma.ts b/packages/sigma/src/sigma.ts index aacc33d8c..95995b97a 100644 --- a/packages/sigma/src/sigma.ts +++ b/packages/sigma/src/sigma.ts @@ -404,8 +404,8 @@ export default class Sigma extends TypedEventEm gl.TEXTURE_2D, 0, gl.RGBA, - this.width / this.pickingDownSizingRatio, - this.height / this.pickingDownSizingRatio, + this.width * this.pixelRatio / this.pickingDownSizingRatio, + this.height * this.pixelRatio / this.pickingDownSizingRatio, 0, gl.RGBA, gl.UNSIGNED_BYTE, @@ -448,7 +448,10 @@ export default class Sigma extends TypedEventEm */ private getNodeAtPosition(position: Coordinates): string | null { const { x, y } = position; - const color = getPixelColor(this.webGLContexts.nodes, this.frameBuffers.nodes, x, y, this.pickingDownSizingRatio); + const canvasX = x * this.pixelRatio + const canvasY = y * this.pixelRatio + + const color = getPixelColor(this.webGLContexts.nodes, this.frameBuffers.nodes, canvasX, canvasY, this.pickingDownSizingRatio); const index = colorToIndex(...color); const itemAt = this.itemIDsIndex[index]; @@ -2115,4 +2118,4 @@ export default class Sigma extends TypedEventEm getCanvases(): PlainObject { return { ...this.elements }; } -} +} \ No newline at end of file