0

I have a basic canvas element fillRect.

How to add dashes to below elements.

ctx.fillStyle = '#40516a';
ctx.fillRect(70, 1, 5, 180);

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML canvas tag.</canvas>

<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = '#40516a';
ctx.fillRect(70, 1, 5, 180);
</script>

</body>
</html>

I have tried below code but not working.

ctx.beginPath();
ctx.setLineDash([5, 15]);

I want output like below.

expected output

rahul.m
  • 5,572
  • 3
  • 23
  • 50

0 Answers0