Skip to content

Commit

Permalink
fixed device scaling ratio as outlined in
Browse files Browse the repository at this point in the history
  • Loading branch information
NiBrc committed Jan 17, 2024
1 parent a4a6893 commit b1fecac
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/sigma/src/sigma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ export default class Sigma<GraphType extends Graph = Graph> 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,
Expand Down Expand Up @@ -448,7 +448,10 @@ export default class Sigma<GraphType extends Graph = Graph> 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];

Expand Down Expand Up @@ -2115,4 +2118,4 @@ export default class Sigma<GraphType extends Graph = Graph> extends TypedEventEm
getCanvases(): PlainObject<HTMLCanvasElement> {
return { ...this.elements };
}
}
}

0 comments on commit b1fecac

Please sign in to comment.