[whatwg] Canvas color serialisation
jordan.osete at laposte.net
Sat May 12 01:52:39 PDT 2007
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.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 to a rgba(...) or #xxxxxx string than the other
More information about the whatwg