I have been experimenting with html5 quite a bit lately to see what I can build. In doing so I have looked at alot of examples especially from http://www.beautyoftheweb.com. In alot of the examples it seems like people that have created these applications can keep track of the elements on the canvas. However, I cannot seem to figure out how to keep a reference to an element on the canvas. Is it possible or are they doi开发者_JS百科ng something else to find the element. For example if I take an image and put it on the canvas I have no reference to that element except by doing canvas.getImageData(). If it is possible to keep a reference to an element it would be great if someone could give me an example of how to do so or a link to a tutorial would be great. If its not possible how are they doing it?
thanks in advance for any help.
Everyone has to write their own code to remember whats drawn and how to interact with it. (Or else use a libarary).
I've actually written two tutorials on precisely this subject. They should be enough to get your started:
Making and Moving Selectable Shapes on an HTML5 Canvas: A Simple Example
Selectable Shapes Part 2: Resizable, Movable Shapes on HTML5 Canvas
精彩评论