Possible to draw dashed line using 2d context in Canvas?
-
I've got a Canvas on my window and I'm drawing a line on it:
@
Canvas
{
onPaint:
{
var ctx = getContext("2d");
ctx.reset();
ctx.beginPath();
ctx.strokeStyle = "green";
ctx.moveTo(0, 0);
ctx.lineTo(100, 100);
ctx.stroke();
}
}
@But I would like the line to be dashed, not solid. Is there any way to do this? I tried setting the stroke style to a pattern:
@
var pat = ctx.createPattern("green", Qt.CrossPattern);
ctx.strokeStyle = pat;
@but none of the available patterns result in a good-looking dashed line.
Any suggestions?
Thanks,
Chris