[whatwg] proposed canvas 2d API additions

Ian Hickson ian at hixie.ch
Thu Apr 30 16:21:12 PDT 2009


On Sat, 28 Feb 2009, JustFillBug wrote:
> On 2006-04-26, Ian Hickson <ian at hixie.ch> wrote:
> > On Mon, 24 Apr 2006, Vladimir Vukicevic wrote:
> >> >
> >> > Assuming nobody has any problem with:
> >> >
> >> >    boolean isPointInPath(in float x, in float y);
> >> >
> >> > ...then I'll add that to the spec when you reply to this mail.
> >> 
> >> Sure, isPointInPath sounds fine.
> >
> > Added.
> >
> >> We can always add isPointInStrokedPath if we ever want to bother with 
> >> that (which is where the "...Fill" bit came from in my API, because the 
> >> region covered by a stroked path and that covered by a filled path are 
> >> different, even though testing for a hit against a filled region would 
> >> by far be the common case).
> >
> > We can also call the other one isPointOnPath(), if we want to keep the 
> > method names reasonably short. I'm not sure we'll ever need to add it, 
> > though. Getting people to click on a line is generally silly.
> 
> We do have a need of isPointOnPath() for editing Bezier lines 
> interactively (on a font editing interface). When people want to add a 
> new point on an already existing curve, we have to know if the click is 
> on path. besides, we need double click on the curve to pickup the whole 
> path and then drag on the line to move the whole path.
> 
> So I dig up a 2006 post...
> 
> Of course it's hard to get people click on a line precisely. But we can 
> check isPointOnPath for an 5x5 square instead to make the operation 
> easier.
> 
> Doing point on curve in javascript is painful. And since checking 
> isPointInPath() already need to detect the on edge case, this shouldn't 
> be too much a burdern on the browser developers.
> 
> So please conside add the isPointOnPath() call to the function.

On Sat, 28 Feb 2009, Philip Taylor wrote:
> 
> (Or maybe we could add a convertStrokeToPath() function, which replaces 
> the current path with a path representing the outline of what you'd get 
> if you stroked the current path, and then use isPointInPath on it.)

I haven't added either of these yet, because, as Philip pointed out in a 
part of his e-mail that I haven't quoted above, there are workarounds that 
can be done to approximate the results.

I expect that when we introduce explicit Path objects we will include 
features like convertStrokeToPath() and so forth which will make this far 
easier to do.

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


More information about the whatwg mailing list