Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Canvas question: dotted/dashed lines?

8 views
Skip to first unread message

Jeremy

unread,
May 31, 2007, 1:41:30 AM5/31/07
to
The canvas element is pretty poorly documented.

I'm trying to make a dotted or dashed line. Is this impossible with
canvas? The apple documentation (under the stroke() method) says that
you can change the "line dash pattern" to affect the stroke. However, I
didn't find any way of setting the dash pattern. You can set an *image*
pattern, but it is not a dash pattern because (at least in Mozilla) the
image is aligned to the canvas' coordinate space rather than the line's.
(I.E. making a dashed line image doesn't create a dashed line because
the line just reveals a "slice" of the dash pattern repeated across the
whole canvas)

Am I making any sense here? :-P

Thanks,
Jeremy

Eric Shepherd

unread,
Jan 20, 2015, 12:50:19 PM1/20/15
to dev-web-d...@lists.mozilla.org, Jeremy
What issues do you have with the canvas documentation? We literally just (within the last week or two) finished a massive overhaul, updating the content, writing docs for everything in the canvas rendering context, and so forth.

The reason you can’t find anything about how to draw a stroked line in a canvas is because there isn’t support for that at this time. You have to create an appropriate canvas pattern object and use that.  For instance: http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas

I hope they update the strokeStyle property to support “dashed” and so forth, though.

-- 
Eric Shepherd
Developer Documentation Lead
Mozilla
Blog: http://www.bitstampede.com/
Twitter: http://twitter.com/sheppy

Eric Shepherd

unread,
Jan 20, 2015, 1:07:09 PM1/20/15
to dev-web-d...@lists.mozilla.org, Jeremy Smith
Weeeeird.

Plus, of course, the reply I sent was wrong. There’s CanvasRenderingContext2D.setLineDash now. :D

-- 
Eric Shepherd
Developer Documentation Lead
Mozilla
Blog: http://www.bitstampede.com/
Twitter: http://twitter.com/sheppy

On January 20, 2015 at 1:03:59 PM, Jeremy Smith (jer...@blazonco.com) wrote:

I'm sure you'll agree that my comments on the documentation make much more sense in the context of May 2007!  Sorry for the confusion.
0 new messages