From dbfabb1a6cee26236e18325e302cec45ddf685c9 Mon Sep 17 00:00:00 2001 From: Patricio Gonzalez Vivo Date: Wed, 13 Jun 2018 04:52:57 -0700 Subject: [PATCH] fixing mouse pixel density --- dist/GlslCanvas.es.js | 4 ++-- dist/GlslCanvas.js | 4 ++-- lib/GlslCanvas.js | 4 ++-- package.json | 2 +- src/GlslCanvas.js | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dist/GlslCanvas.es.js b/dist/GlslCanvas.es.js index 8e0fa1a..9cfae8e 100644 --- a/dist/GlslCanvas.es.js +++ b/dist/GlslCanvas.es.js @@ -1316,8 +1316,8 @@ var GlslCanvas = function () { var rect = this.canvas.getBoundingClientRect(); if (mouse && mouse.x && mouse.x >= rect.left && mouse.x <= rect.right && mouse.y && mouse.y >= rect.top && mouse.y <= rect.bottom) { - var mouse_x = mouse.x * this.realToCSSPixels - rect.left; - var mouse_y = this.canvas.height - (mouse.y * this.realToCSSPixels - rect.top); + var mouse_x = (mouse.x - rect.left) * this.realToCSSPixels; + var mouse_y = this.canvas.height - (mouse.y - rect.top) * this.realToCSSPixels; for (var key in this.buffers) { var buffer = this.buffers[key]; diff --git a/dist/GlslCanvas.js b/dist/GlslCanvas.js index 17b8541..94125e0 100644 --- a/dist/GlslCanvas.js +++ b/dist/GlslCanvas.js @@ -1721,8 +1721,8 @@ var GlslCanvas = function () { var rect = this.canvas.getBoundingClientRect(); if (mouse && mouse.x && mouse.x >= rect.left && mouse.x <= rect.right && mouse.y && mouse.y >= rect.top && mouse.y <= rect.bottom) { - var mouse_x = mouse.x * this.realToCSSPixels - rect.left; - var mouse_y = this.canvas.height - (mouse.y * this.realToCSSPixels - rect.top); + var mouse_x = (mouse.x - rect.left) * this.realToCSSPixels; + var mouse_y = this.canvas.height - (mouse.y - rect.top) * this.realToCSSPixels; for (var key in this.buffers) { var buffer = this.buffers[key]; diff --git a/lib/GlslCanvas.js b/lib/GlslCanvas.js index f70f8eb..f3e473b 100644 --- a/lib/GlslCanvas.js +++ b/lib/GlslCanvas.js @@ -1717,8 +1717,8 @@ var GlslCanvas = function () { var rect = this.canvas.getBoundingClientRect(); if (mouse && mouse.x && mouse.x >= rect.left && mouse.x <= rect.right && mouse.y && mouse.y >= rect.top && mouse.y <= rect.bottom) { - var mouse_x = mouse.x * this.realToCSSPixels - rect.left; - var mouse_y = this.canvas.height - (mouse.y * this.realToCSSPixels - rect.top); + var mouse_x = (mouse.x - rect.left) * this.realToCSSPixels; + var mouse_y = this.canvas.height - (mouse.y - rect.top) * this.realToCSSPixels; for (var key in this.buffers) { var buffer = this.buffers[key]; diff --git a/package.json b/package.json index 09d39d2..41131ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "glslCanvas", - "version": "0.1.2", + "version": "0.1.3", "description": "Simple GLSL Fragment Shader Sandbox", "main": "lib/GlslCanvas.js", "module": "dist/GlslCanvas.es.js", diff --git a/src/GlslCanvas.js b/src/GlslCanvas.js index d5b6ccb..ba057c6 100644 --- a/src/GlslCanvas.js +++ b/src/GlslCanvas.js @@ -389,8 +389,8 @@ void main(){ mouse.x && mouse.x >= rect.left && mouse.x <= rect.right && mouse.y && mouse.y >= rect.top && mouse.y <= rect.bottom) { - let mouse_x = (mouse.x * this.realToCSSPixels - rect.left ); - let mouse_y = (this.canvas.height - (mouse.y * this.realToCSSPixels - rect.top)); + let mouse_x = (mouse.x - rect.left ) * this.realToCSSPixels; + let mouse_y = (this.canvas.height - (mouse.y - rect.top) * this.realToCSSPixels); for (let key in this.buffers) { const buffer = this.buffers[key];