Re: hit testing and retained graphics

On Jul 1, 2011, at 1:14 PM, Edward O'Connor wrote:

> 
> 
> Here's a sketch of a simple-as-possible path object for enhanced hit
> testing support in <canvas> that may be more palatable to implementors.
> Suppose the 2d context API had a method to get the current path. An
> author calls this method after drawing some path onto the <canvas> and
> squirrels away the returned object foo. Later on, in a click handler on
> the <canvas>, the author can call foo.isPointInPath(x,y) to see if the
> click has happened in that path. Some things to note about this
> proposal:

Interesting idea. Explicit Path objects would be a useful addition to the canvas API beyond hit testing. For example, you could easily construct a path and reuse for drawing multiple time. This would require the ability to stroke or fill paths given a path object in addition to the hit testing support.

Personally I think it was an oversight in the original canvas API that it only has a current path and not path objects. Many other graphics APIs (including CoreGraphics, the API that inspired canvas) have explicit objects for paths.

Regards,
Maciej

Received on Saturday, 2 July 2011 00:22:09 UTC