laserpanda
laserpanda

Reputation: 387

Can I draw a line on a html5 canvas with variable widths per segment?

I would like to draw a multiple segment line on a html 5 canvas with variable width per segment.

I tried something like (pseudocode):


beginpath()
setLineWidth(1)
lineTo(0,0)
...
setLineWidth(10)
lineTo(73, 44)

stroke()

but it seems stroke only takes the last linewidth() value? Is there another way?

I tried making every segment its own line, but that turned out really really show when drawing 1000+ segments.

Upvotes: 3

Views: 1305

Answers (2)

rezoner
rezoner

Reputation: 1967

You have to call stroke() on each segment, not at the very end and there is no other possiblity.

Upvotes: 2

CYMA
CYMA

Reputation: 677

Probably will have to make each segment it's own line. That or figure out how to make a custom shape with the same sort of gradient.

Upvotes: 0

Related Questions