ctx-dashed-line
draw a dashed line in html5 2d canvas
install
npm install ctx-dashed-line
use
var dashedLine =
api
dashedLine
(ctx
, start
, end
[, dashLength=2
])
ctx
- a CanvasRenderingContext2D (e.g.var ctx = canvas.getContext('2d')
)start
- a 2 component array[x, y]
or object with the shape:{ x: 1, y: 1 }
specifying the start of a line segmentend
- a 2 component array[x, y]
or object with the shape:{ x: 1, y: 1 }
specifying the end of a line segmentdashLength
- optional length of on & off of dash (defaults)
returns ctx
example
as seen in examples/basic.js, run with beefy example/basic.js --live --open
var dashedLine = ;var canvas = document;var ctx = canvas;documentbody; ctxlineCap = "round"; ctx; ; ; ; ctxlineWidth = 2; ctx;
results in: