Lines In the Canvas

  • Lines are drawn with four basic commands
  • <canvas id="Lines" width="100" height="100" style="border:1px solid black;"></canvas>
    
    <script>
    "use strict"
    const canvas  = document.getElementById("Lines");
    const ctx = canvas.getContext("2d");
    
    ctx.beginPath();
    ctx.moveTo(10,10);
    ctx.lineTo(canvas.width-10, canvas.height-10);
    ctx.stroke();
    </script>