Re: [whatwg] isPointInPath on Path object

On Thu, 20 Sep 2012, Dirk Schulze wrote:
> 
> The interface of CanvasRenderingContext2D currently has a function 
> called isPointInPath() with a Path object as input [1]. I wonder why 
> this needs to be on the context interface. Wouldn't it make more sense 
> on the interface of Path object itself? If an implementation really 
> needs a context to get a point on a path it, it can create it on it's 
> own.

I don't think it would make _more_ sense, but I agree that it would make 
equal amounts of sense.

In practice you're pretty much always going to have a context around when 
you want to check this, because the reason you'd use it is to see where I 
mouse click landed on a canvas. And you're going to want the Path object 
transformed as per the transform on the canvas, generally speaking.


> The only situation that might be reasonable would be a transform on the 
> Canvas that an author want to cover in the Path. But for the rare case 
> where this matters, you can create a new Path object, add your path with 
> the transform and call isPointInPath.

Yeah, you could do that too.


> Furthermore, a transform() function that applies to a Path object seems 
> to be useable as well.

You can create a new Path, then add another Path to it while applying a 
transform, using the addPath() method.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 21 September 2012 00:12:28 UTC