Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a dashed line rectangle in canvas?

I'm tasked to do cropping in canvas and i'm finished with all the logic but one requirement is yet to be finished i.e to draw a dashed rectangle while selecting cropping area like:

strokeRect(x, y, width, height)

How can I draw a dashed rectangle?

like image 461
user1070642 Avatar asked Dec 30 '11 08:12

user1070642


1 Answers

This has been added to the canvas spec, not all browsers have implemented it yet, but here it is.

context.setLineDash([6]);
context.strokeRect(0, 0, 50, 50);
like image 52
Paul Milham Avatar answered Oct 29 '22 15:10

Paul Milham