[whatwg] Dashed strokes on <canvas>

On 09/05/07, David Flanagan <david at davidflanagan.com> wrote:
> Philip,
>
> You have a reasonable point. I still think that an implementation would
> be trivial, but you're right that there is more complexity for the
> specification than simply defining one more method API.  On the other
> hand, I think it is legitimate to take the SVG-Tiny route and leave
> specific rendering details to the implementation.  After all, you're not
> specifying line and curve drawing algorithms down to the pixel, are you?

It's true that nothing is being specified down to individual pixels,
since there's not even a guarantee that one canvas pixel will
correspond to one device pixel (e.g. on very-high-resolution displays
that could use more device pixels and no antialiasing). But I think
I'd be happier if everything other above the level of pixels was
defined exactly (which it isn't at the moment, but I'm considering
that to be a bug - e.g. the curve drawing section should give the
equation for computing the points on the curve, though not the
algorithm for subdividing and rasterising) and implemented predictably
everywhere. I don't know precisely where a sensible limit would be and
how much it could be relaxed in practice, though.

>  > There are other missing features that people are actively implementing
>  > workarounds for, like drawing text, which is a good indicator of
>  > demand. Are there examples where people are currently fighting against
>  > the lack of dashed lines?
>
> The problem of layering text on top of a canvas is a solvable one, so
> people are solving it.  I don't think that dashed lines can really be
> worked around. If there is no native support, they're not worth doing.
> To me the killer use-case for dashed lines is this: displaying multiple
> data series in a line chart that will be printed in black-and-white.
> People have been using dashed lines for that since Rene Descartes
> invented the coordinate system!

http://canvex.lazyilluminati.com/misc/dash.html [not guaranteed
bug-free] - it's easy enough and not particularly inefficient when
you're just drawing straight lines, or drawing curves that can be
easily split into straight lines, and when you don't want anything
fancy, which seems like it'd be enough for drawing lines on graphs.
Are there serious problems or limitations with this approach that
would make native support worth the cost?

>      David

-- 
Philip Taylor
excors at gmail.com

Received on Wednesday, 9 May 2007 16:50:24 UTC