Triangle with curved bottom
<!doctype html> <html> <head> <title>Drawing a spaceship</title> </head>/*from w ww . ja v a 2 s . c om*/ <body> <h1>Drawing a spaceship</h1> <canvas id="balls" width="400" height="400"></canvas> <script> let context = document.getElementById("balls").getContext("2d"); function draw_ship(ctx, radius) { ctx.save(); ctx.strokeStyle = "white"; ctx.fillStyle = "rgba(0, 0, 0, 0.25)"; ctx.lineWidth = 0.5; ctx.beginPath(); ctx.arc(0, 0, radius, 0, 2 * Math.PI); ctx.stroke(); ctx.fill(); ctx.lineWidth = 2; ctx.strokeStyle = "white"; ctx.fillStyle = "black"; let angle = 0.5 * Math.PI / 2; let curve = 0.5; ctx.beginPath(); ctx.moveTo(radius, 0); ctx.lineTo( Math.cos(Math.PI - angle) * radius, Math.sin(Math.PI - angle) * radius ); ctx.quadraticCurveTo(radius * curve - radius, 0, Math.cos(Math.PI + angle) * radius, Math.sin(Math.PI + angle) * radius ); ctx.closePath(); ctx.fill(); ctx.stroke(); ctx.restore(); } context.translate(300, 300); draw_ship(context, 100); </script> </body> </html>