W3C home > Mailing lists > Public > public-canvas-api@w3.org > January to March 2010

Clarification on CanvasGradient Behaviour

From: Jatinder Mann <jmann@microsoft.com>
Date: Wed, 3 Mar 2010 16:42:51 +0000
To: "public-canvas-api@w3.org" <public-canvas-api@w3.org>
Message-ID: <EAACC9DF6817544486F0D0ADA05CA4280F50E5CE@TK5EX14MBXC111.redmond.corp.microsoft.com>

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,

[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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:31:49 UTC