[whatwg] Canvas: dash list API

Rik Cabanier cabanier at gmail.com
Sat Dec 22 20:04:52 PST 2012

On Sat, Dec 22, 2012 at 10:04 AM, Ian Hickson <ian at hixie.ch> wrote:

> On Sat, 22 Dec 2012, Anne van Kesteren wrote:
> >
> > Is there not some way we can have a lineDash attribute that returns a
> > manipulatable object that inherits from Array rather than the current
> > Java-like API? I remember this was discussed when getLineDash() and
> > setLineDash() were added, but I think it's worth taking another look at
> > this.
> >
> > (For URLs I want something similar for path segments and I'd rather not
> > introduce get/set methods.)
> What would you want to have happen in the case of a library method that
> saves the context, sets the dash to an internal value, draws a line, saves
> the dash state to an internal value, restores the context, then returns?
> Should the caller, if they then grab the dashed line object from the
> context, get the internal value of the library? Should the restore() call
> mutate the saved dash object?
You are correct. Since linedash is part of the graphics state, its value
can't be a reference to an object.
Having to restore the array at 'restore()' time would be very hard to do
and very confusing for the user.

I agree that get/setLineDash should just handle plain arrays, but an array
property called 'lineDash' is most likely not going to work.

More information about the whatwg mailing list