2

Possible Duplicate:
How do I get the coordinates of a mouse click on a canvas element?

I have yet another question regarding the html5 canvas. I've been making several cool projects with this feature in Javascript, but I'm now looking for ways to use the mouse to make the canvas more interactive. All I need is a simple way to set a variable to either the mouse's x value, or its y value.

Thanks!

Community
  • 1
  • 1
dualCore
  • 609
  • 4
  • 9
  • 13
  • 1
    http://stackoverflow.com/questions/55677/how-do-i-get-the-coordinates-of-a-mouse-click-on-a-canvas-element http://dev.opera.com/articles/view/html5-canvas-painting/ – Bakudan Dec 26 '11 at 01:13

1 Answers1

2

HTML5 Canvas is just a drawing plane and there is no display list. To add, remove, place objects using x,y and other properties first you need to define classes for containers and objects that can be added to the containers. Either you have to develop it yourself or you can use any one of the libraries available.

http://easeljs.com/

http://www.kineticjs.com/

A few months before I also started developing one library for the same purpose. I faced a lot of performance issues, so waiting for some free time to optimize my code. You can find the library here https://github.com/tracevipin/exsprite and some demos here http://www.exsprite.com/demos/

Diode
  • 24,570
  • 8
  • 40
  • 51