Create shapes - smallQuerty/canvas_charts GitHub Wiki

Draw a line

After creating the rectangular canvas area, you must add a JavaScript to do the drawing.

<script>

var c = document.getElementById("myCanvas");

var ctx = c.getContext("2d");

ctx.moveTo(0, 0);

ctx.lineTo(200, 100);

ctx.stroke();

</script>

Draw a circle

<script>

var c = document.getElementById("myCanvas");

var ctx = c.getContext("2d");

ctx.beginPath();

ctx.arc(95, 50, 40, 0, 2 * Math.PI);

ctx.stroke();

</script>

⚠️ **GitHub.com Fallback** ⚠️