[whatwg] Canvas performance issue: setting colors

Hi,

With the increasing speed of javascript engines, some other  
performance issues are starting to become apparent. Take this demo for  
example:

http://playground.q42.nl/animatie/blobs/sjoerd/blobscolor.html

A large percentage of the time goes into building color strings for  
setting the strokeStyle, which the browser then has to take apart  
again. This is a very unnecessary performance hit. (Btw, on my Mac  
this runs faster under Google Chrome in VMware than natively in the  
latest Webkit nightly.)

I think the canvas api should get 2 new methods:

   CanvasColor createRGBAColor(in float r, in float g, in float b, in  
float a)
   CanvasColor createHSLAColor(in float h, in float s, in float l, in  
float a)

CanvasColor objects could be opaque, or maybe they have a toString  
method that returns the CSS serialization. The strokeStyle, fillStyle  
and shadowColor attributes should accept these objects, and probably  
the addColorStop method as well. Using CSS color strings should still  
work obviously. On getting these attributes the serialization must  
still be returned like it is now.

greetings,
--
Sjoerd Visscher
sjoerd at w3future.com

Received on Monday, 29 September 2008 15:24:22 UTC