TLDR;
Here is the Codepen;
Prerequisites
- Basic understanding of the Canvas API supported on all modern browsers.
- Javascript
- HTML
Let's code
Create a canvas element in your HTML file or panel if using an online editor.
Create or open a javascript panel so we can draw our triangle
Left comments on each line that describes what each line does but for some further reading checkout this MDN documentation
![](https://cdn.sanity.io/images/cyvlslus/production/df7a830c986804b131cf7ad0dd865f6e84b60562-710x688.png?w=800)