[whatwg] Canvas 2d methods

Andrew Fedoniouk news at terrainformatica.com
Mon Jul 3 14:53:31 PDT 2006

----- Original Message ----- 
From: "David Hyatt" <hyatt at 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).

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 
Implementation can cache them if creation of such is expensive in particular 

Andrew Fedoniouk.

More information about the whatwg mailing list