HTML
All you need to know about HTML
Canvas
Last updated
All you need to know about HTML
Last updated
/*HTML*/
<body>
<canvas id="canvas1"></canvas>
<script src="index.js"></script>
</body>
/*index.js*/
const canvas = document.getElementById('canvas1')
// for JS Intellisense use below line
const canvas = /** @type {HTMLCanvasElement} */ (document.querySelector('#canvas1'))
// canvas API 2D
const ctx = canvas.getContext('2d')
// canvas API 3D
// const ctx = canvas.getContext('webgl')
console.log(ctx)
ctx.beginPath() // imagine, putting pencil on paper before drawing