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

RE: Clarification on CanvasGradient Behaviour

From: Jatinder Mann <jmann@microsoft.com>
Date: Thu, 4 Mar 2010 18:38:07 +0000
To: "'pjt47@cam.ac.uk'" <pjt47@cam.ac.uk>
CC: "'public-canvas-api@w3.org'" <public-canvas-api@w3.org>
Message-ID: <EAACC9DF6817544486F0D0ADA05CA4280F5127CC@TK5EX14MBXC111.redmond.corp.microsoft.com>
Philip Taylor wrote:
> I don't see anything in the spec that is explicit about this, so I agree 
> it would be nice to clarify it. It may be best if you could file a bug 
> (<http://www.w3.org/Bugs/Public/enter_bug.cgi?component=HTML5%20spec%20bugs&product=HTML%20WG>) 
> to ensure that the editor sees it and responds to it.

Thanks Philip. I have opened Bug 9189 to track this issue (http://www.w3.org/Bugs/Public/show_bug.cgi?id=9189).

I have another related issue. This same section of the spec is not clear about the expected behaviour when the addColorStops are added in the wrong order by offset. In the following example, lines 2 and 3 are placed in the wrong order:
 
0 var gradient = ctx.createLinearGradient(0,0,0,150);
1 gradient.addColorStop(0, 'darkblue');
2 gradient.addColorStop(.5, '#00ABEB');
3 gradient.addColorStop(.25, 'blue');
4 gradient.addColorStop(1, 'white');
 
5  // assign gradient to fill style
6 ctx.fillStyle = gradient;
 
7 // draw shape
8 ctx.fillRect(10,10,130,130);
 
I have noticed that Firefox, Safari, Chrome and Opera all draw the image as if the colour stops were added in the correct order. Should the spec clarify this behaviour?

Thanks,
Jatinder

-----Original Message-----
From: Philip Taylor [mailto:pjt47@cam.ac.uk] 
Sent: Wednesday, March 03, 2010 9:23 AM
To: Jatinder Mann
Cc: public-canvas-api@w3.org
Subject: Re: Clarification on CanvasGradient Behaviour

Jatinder Mann wrote:
> 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?

Test case: 
http://philip.html5.org/tests/canvas/suite/tests/2d.gradient.object.update.html

It looks like the latest versions of Firefox, Opera, Safari and 
Konqueror agree that the gradient is drawn based on the stops that are 
present at the time of drawing (which is the behaviour the test 
expects). Only Chrome disagrees and uses the stops at the time of 
assignment.

I don't see anything in the spec that is explicit about this, so I agree 
it would be nice to clarify it. It may be best if you could file a bug 
(<http://www.w3.org/Bugs/Public/enter_bug.cgi?component=HTML5%20spec%20bugs&product=HTML%20WG>) 
to ensure that the editor sees it and responds to it.

-- 
Philip Taylor
pjt47@cam.ac.uk
Received on Thursday, 4 March 2010 18:38:50 UTC

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