Solved How to draw dashed line in Canvas
-
This code draws a solid line:
Canvas { id: canvas onPaint: { var ctx = canvas.getContext('2d') ctx.strokeStyle = "red" ctx.lineWidth = 4 ctx.lineCap = "round" ctx.lineJoin = "round" ctx.setLineDash = [ 1, 4 ] ctx.beginPath() ctx.moveTo(2, canvas.height / 2) ctx.lineTo(canvas.width - 2, canvas.height / 2) ctx.stroke() } }
what I further have to set after
setLineDash
? -
-
Ups, you're right. I didn't notice that because I received no warnings/error at compile-time nor at run-time!