[whatwg] Dashed strokes on <canvas>

Ian Hickson ian at hixie.ch
Mon May 7 22:06:55 PDT 2007

On Wed, 17 May 2006, David Flanagan wrote:
> What surprises me about the omission of dashed lines is that every 
> graphics API I'm familiar with (Xlib, PostScript, Java 2D) supports 
> dashed lines. Unless there is some important platform out there that 
> does not support them in the underlying graphics library, it seems to me 
> that it would have been trivial to add dashed lines to the API.
> And, I can't think of any simple or efficient way to simulate dashed 
> lines without having them in the API.  And while dashed lines may not be 
> a high-use feature, I wouldn't say they're infrequently used.  For 
> example: when drawing a line chart with multiple lines which is intended 
> to be printed on a black-and-white laser printer.

There are many styles that aren't supported -- dashes aren't an exception. 
For example, there's no support for having defined markers repeated around 
the stroke. Similarly, we don't havenative  support for rounded corners, 
or for many shapes (e.g. circles).

You can do dashed lines using paths. Without more demand for this feature, 
it's not clear that it's worth us putting it into the language.

On Sat, 20 May 2006, Peter Hall wrote:
> Flash is an example of a platform that does not support dashed lines in 
> its drawing API. Dashed lines created in the Flash Authoring tool are 
> actually exported into a swf as a series of short curves.
> However, this is a huge limitation, when it comes to drawing lines 
> dynamically, so I don't think one platform's omission of the feature is 
> a good argument anyway.

There apparently isn't much demand for it for Flash either.

> It is a reasonable and worthwhile goal to natively support emulation of 
> all style attributes that are specifiable in CSS.

Why? CSS' styles are the result of a pretty arbitrary set of decisions in 
committee meetings. (I know, I've been on the CSSWG for ~7 years.)

On Sat, 20 May 2006, Peter Hall wrote:
> >
> > Correct, it doesn't have stroke styles other than gradients, patterns, 
> > and solid colours. It was an intentional omission since it was not 
> > considered a high-use feature. (Similarly, text is not available in 
> > Canvas; you have to overlay HTML if you want to mix text with the 
> > graphics.)
> May I assume that the inclusion of gradients is solely because they are 
> implemented for fills aleady?

Pretty much, I think.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list