<canvas id="mycanvas" width="500" height="500"></canvas> <script> let canvas = document.getElementById('mycanvas') if (canvas.getContext) { let ctx = canvas.getContext('2d') ctx.beginPath() let triangle = new Path2D() triangle.moveTo(100, 100) triangle.lineTo(400, 100) triangle.lineTo(200, 200) triangle.lineTo(100, 100) let other = new Path2D() other.moveTo(400, 200) other.lineTo(400, 400) other.lineTo(200, 200) other.lineTo(400, 400) other.lineTo(500, 200) let p = new Path2D("M100 100 h 80 v 80 h -80 Z") ctx.fillStyle ='#e74478' ctx.fill(other) ctx.stroke(triangle) ctx.fill(p) } </script>