Skip to content

Commit

Permalink
fixing mouse pixel density
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciogonzalezvivo committed Jun 13, 2018
1 parent 1f48bb8 commit dbfabb1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dist/GlslCanvas.es.js
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions dist/GlslCanvas.js
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions lib/GlslCanvas.js
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
4 changes: 2 additions & 2 deletions src/GlslCanvas.js
Expand Up @@ -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];
Expand Down

0 comments on commit dbfabb1

Please sign in to comment.