JavaScript EditorFree JavaScript Editor     Perl Manuals 



Main Page

9.11. Translating Coordinates

When you set up a callback and use the Ev('x') and/or Ev('y') arguments to find out where the user clicked, you must translate that information into Canvas coordinates (Ev is explained in Chapter 15, "Anatomy of the MainLoop"). To do this, use the canvasx and canvasy methods:

$x = $canvas->canvasx(screenx [, gridspacing ]);
$y = $canvas->canvasy(screeny [, gridspacing ]);

Each method takes an optional gridspacing argument; the Canvas coordinate value will be rounded to the nearest value to fit the grid.






JavaScript EditorJavaScript Formatter     Perl Manuals


©