[whatwg] [canvas] Path object

Ian Hickson ian at hixie.ch
Mon Oct 8 16:29:31 PDT 2012


On Sat, 22 Sep 2012, Elliott Sprehn wrote:
>
> I was looking at the canvas Path API and had some concerns. In 
> particular it's inconsistent with the rest of canvas:
> 
> We already have CanvasGradient and CanvasPattern in the global 
> namespace, so this should probably be called CanvasPath.

The name is based in part on the idea that it should be useful outside of 
Canvas as well. The old names are legacy we can't change.


> We also have createLinearGradient() and createPattern(), but this new 
> thing is "new Path".

As a general rule on the platform as a whole we're moving towards 
constructors. The gradient and pattern objects, again, are a legacy that 
we can't change (we could add redundant constructors as well, but 
generally I recommend against adding redundancy as it doesn't add 
anything useful but does add confusion and implementation costs).


On Tue, 2 Oct 2012, Elliott Sprehn wrote:
>
> What of the fact that this breaks existing pages with <input id="Path"> 
> that access it as just Path? Historically this has been a non-starter 
> for new APIs.

We've added tons of stuff to Window, and I'm sure we'll add more. The 
question is just whether it causes breakage; if it does, we'll change the 
name. That's what implementation testing is for. :-)

As a general rule, capitalised names like Path aren't usually a big deal.


On Tue, 2 Oct 2012, Elliott Sprehn wrote:
> 
> What about unifying all of these as:
> 
> new GraphicsPath()
> new GraphicsLinearGradient()
> new GraphicsRadialGradient()
> new GraphicsPattern()
> 
> and fixing HTML5 canvas to support these new constructors instead?

We could only change Path, since the others are already deployed. We could 
add new constructors, but that would just be new redundancy, and thus 
probably isn't worth it.


> @hixie: How was it decided that this wasn't going to break the web?

It wasn't. That remains to be seen.


On Wed, 3 Oct 2012, Simon Pieters wrote:
>
> $ grep -aPc "\s(?i:(id|name))\s*=\s*(\"|')?Path((\"|')|(\s|>|/))" web200904
> 85

85 out of ~600,000 pages is 0.014%. Not too small (about an order of 
magnitude more than the number of XHTML pages served as XML I found a few 
years ago in Google's index), but still pretty small.

-- 
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