js canvas draw polygon

Solutions on MaxInterview for js canvas draw polygon by the best coders in the world

showing results for - "js canvas draw polygon"
Niclas
06 Feb 2019
1var ctx = canvas.getContext('2d');
2ctx.fillStyle = '#f00';
3ctx.beginPath();
4ctx.moveTo(0, 0);
5ctx.lineTo(100,50);
6ctx.lineTo(50, 100);
7ctx.lineTo(0, 90);
8ctx.closePath();
9ctx.fill();