W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2008

[whatwg] Canvas performance issue: setting colors

From: Kristof Zelechovski <giecrilj@stegny.2a.pl>
Date: Sat, 4 Oct 2008 17:02:49 +0200
Message-ID: <A2513EDA5CF74EF3A9F7B2E29E12B2C9@POCZTOWIEC>
In that case, the entries should be more informative: { red: 0, green: 0.3,
blue: 0.6, alpha: 1.0 }.

-----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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:06 UTC