Thanks for the tips!  So here comes my modified version with a
calibration feature, so that one-file-fits-all!

var calibrated=0;
var offsetX=0;
var offsetY=0;
...
alert('Click the upper-left corner for calibration.');
void mousePressed() {
  if(!calibrated){
    // There is a bug in processing the mouseX and mouseY return wrong
    // coordinates depending on the location of the canvas in the
page.
    offsetX=mouseX; offsetY=mouseY; calibrated=1;
  }
  // when the mouse is pressed or dragged draw shortest path to start
of maze
  drawnow();
  strokeWeight(max((n-2)/2,2));
  x=int((mouseX-offsetX)/n);
  y=int((mouseY-offsetY)/n);
  ...

On Jun22, 12:54am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> See these lines:
>
>   x=int((mouseX-20)/
> n);
>   y=int((mouseY-20)/n);
>
> There is a bug in processing the mouseX and mouseY return wrong
> coordinates depending on the location of the canvas in the page. the
> "-20" fixes the offset for me. For you it may be different.
>
> On Jun 21, 11:44 am, Iceberg <iceb...@21cn.com> wrote:
>
>
>
> > Thanks for sharing. But ...
>
> > I put exactly same code on your page to a myapp/controllers/maze.py,
> > even use your version of processing.min.js, processing.init.js,
> > jquery.js, but it just does not work exactly the same as your demo.
> > When I click somewhere in the maze, say coordinate (x,y), my maze
> > reacts as if I am clicking another place at (x+blah, y+sth)
>
> > Did I miss something? Thanks in advance.
>
> > On Jun21, 6:20am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > source is NOW posted on the page
>
> > > On Jun 17, 10:50 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> > > >http://www.web2py.com/mazes

Reply via email to