[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 07:47:00 UTC