[whatwg] Canvas 2d methods

----- Original Message ----- 
From: "David Hyatt" <hyatt@apple.com>
To: "WHAT Working Group Mailing List" <whatwg at whatwg.org>
Cc: "Ian Hickson" <ian at hixie.ch>; "H?kon Wium Lie" <howcome at opera.com>; 
"Vladimir Vukicevic" <vladimir at pobox.com>; "Andrew Fedoniouk" 
<news at terrainformatica.com>; "Benjamin Joffe" <canvasgame at gmail.com>
Sent: Monday, July 03, 2006 2:02 PM
Subject: Re: [whatwg] Canvas 2d methods


>I don't think it's intuitive to support chaining only on those  methods 
>that happen to return null right now.
>
> dave
> (hyatt at apple.com)
>

Dave, take a look on this from different angle:

Typicall design of drawing surface wrappers (2d contexts) is a set of 
methods -
"graphical stream commands". set pen, set brush, move here, draw up to 
there, etc.
Such command/methods does not need to return anything.  So they can return
context itself to use chained calls.

There are obvious exceptions from this rule (create*** methods).
http://whatwg.org/specs/web-apps/current-work/#the-2d

So I would rephrase "there are methods that happen to return *not*
null right now"

While I am on this....

I think that methods like
CanvasGradient createLinearGradient(x0, y0, x1, y1);

can be changed to
Context  setLinearGradient(x0, y0, x1, y1);

They create gradient brush and set is a current. Why do we need this two
stage process: create then set?

And I think that these CanvasGradient don't need to be seen in script at 
all.
Implementation can cache them if creation of such is expensive in particular 
engine.

Andrew Fedoniouk.
http://terrainformatica.com

Received on Monday, 3 July 2006 14:53:31 UTC