[whatwg] Canvas performance issue: setting colors

In that case, the entries should be more informative: { red: 0, green: 0.3,
blue: 0.6, alpha: 1.0 }.
Chris

-----Original Message-----
From: whatwg-bounces@lists.whatwg.org
[mailto:whatwg-bounces at lists.whatwg.org] On Behalf Of Philipp Serafin
Sent: Saturday, October 04, 2008 4:47 PM
To: Oliver Hunt; whatwg at whatwg.org
Subject: Re: [whatwg] Canvas performance issue: setting colors

>
> <thinking out loud>
> Just had a thought (no idea how original) -- how about if fillStyle were
> able to accept a 3 or 4 number array? eg. fillStyle = [0, 0.3, 0.6, 1.0] ?
>
> That might work well if people are using arrays as vectors/colours
> </thinking out loud>

Instead of an array, we could also use a generic, "duck-typed"
javascript object:
fillStyle = {r:0, g:0.3, b: 0.6, a:1.0};
This would seem a little clearer semantically, I think, since arrays
are after all supposed to represent a list of semantically identical
values. (Yes, I know many web frameworks and JSON interfaces are
already using them differently, but I still things it's something else
if we include this pattern in an official language spec.)
This would also make it easy shift to a real "color" or "style" object
later, if we wanted to.

Received on Saturday, 4 October 2008 08:02:49 UTC