ClickFunc: function (me, evnt) { // the actual location of the click var x = evnt.clientX; var y = evnt.clientY; console.log("(x,y)", x,y); var Ax = me.x; var Ay = me.y; var Bx = this.canvas.width+me.x; var By = this.canvas.height+me.y; console.log("Canvas", Ax, Ay, Bx, By); var Lx = -1; var Ly = -1; var Ux = 1; var Uy = 1; var xp, yp; // do the transformation we discussed. xp = Lx + (x-Ax)*(Ux-Lx)/(Bx-Ax); yp = Ly + (By-y)*(Uy-Ly)/(By-Ay); this.gl.uniform1f(this.xoff, xp); this.gl.uniform1f(this.yoff, yp); this.Redisplay(); }