W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2007

[whatwg] Canvas color serialisation

From: Jordan OSETE <jordan.osete@laposte.net>
Date: Sat, 12 May 2007 10:52:39 +0200
Message-ID: <46458057.6080108@laposte.net>
Ian Hickson wrote :

> On Mon, 16 Apr 2007, Jordan OSETE wrote:
>> 
>> In that case, we could detect if the application tries to set an array 
>> to the properties fillStyle or strokeStyle, and if it is the case, then 
>> it means that the given application is more recent than the change from 
>> string to array, and we can switch to an array-like reading.
>>
[...]
> 
> This seems way, way more complex than necessary. We really want to keep 
> this API as simple as possible.
> 

Hm, i have to admit that...

> It's not clear to me why the author ever needs to read this value. The 
> value, when set, is set by the author's code -- if you need to know what 
> the value is in some more detailed way then just remember what you set it 
> to (e.g. with a wrapper function).

It can be done with a wrapper, but it seems overhead, when the UA can 
just return something easier to read.
In that case, why not always return an array, like Philip Taylor 
suggested? It would allow the user be able to read color values in an 
easy way, and still keep compatibility with this kind of code :

>    var old = context.fillStyle;
>    context.fillStyle = 'green';
>    context.fillRect(0,0,100,100);
>    context.fillStyle = old;

I don't see many reasons to return strings like #xxxxxx or rgba(...) in 
the first place, but if needed, it's way easier for the application to 
convert that array[4] to a rgba(...) or #xxxxxx string than the other 
way around.

Regards,
Jordan Osete
Received on Saturday, 12 May 2007 01:52:39 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:55 UTC