Clarification on CanvasGradient Behaviour

Hi,

As we continue to review the HTML5 Canvas 2D Context Specification [1] we came across an issue that needs clarification in Section 5 Colors and styles. 

What is the expected behaviour when a CanvasGradient object is modified after it gets assigned? Does the drawing use the parameters of the gradient at the time of assignment or at the time of drawing?

In the following example, will the stops added in lines 6 and 7 appear in the gradient drawn in line 9? Can the spec clarify this point?

0 var gradient = ctx.createLinearGradient(0,0,0,150);
1 gradient.addColorStop(0, 'blue');
2 gradient.addColorStop(.5, 'white');
 
3 //assign gradient to fill style
4 ctx.fillStyle = gradient;
 
5 //add additional stops after assignment
6 gradient.addColorStop(.5, 'red');
7 gradient.addColorStop(1, 'white');

8 // draw shapes
9 ctx.fillRect(10,10,130,130);


Thank you,
Jatinder

[1] http://dev.w3.org/html5/2dcontext/

Jatinder Mann | Microsoft Program Manager | jmann@microsoft.com

Received on Wednesday, 3 March 2010 16:43:34 UTC