开发者

Region selection in canvas

I'm setting up an experimental html5 website using canvas. I am drawing 3 circles all next to each other and all I want to know is how to be able to select them.

I'd like them to become links, in a way. Not tags, since everything's gonna be created using javascript.

Something like 开发者_开发技巧kinetic JS : http://www.kineticjs.com/, but without the extra library.

I have found some scripts that are using ghost canvas and contexts, but the examples are for dragging and stuff. I only want to be able to select my shape and execute some code.

Thank you!


I am thinking you might want to look into the IsPointInPath() method. It will help you figure out whether or not the mouse clicked on your canvas object.

See Detect mouseover of certain points within an HTML canvas?


if you are talented in xml i suggest you to use canvas + SVG (http://www.w3schools.com/svg/)

And follow this simple example. http://jsvectoreditor.googlecode.com/svn/trunk/index.html

regarding to SVG and Canvas , the differences are obvious, as you can load bitmaps in SVG, and you can draw lines using the canvas API. However, creating the image may be easier using one technology over the other, depending on whether your graphic is mainly line-based or more image-like.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜