HTML5 Game - Canvas Shape Club

Creating custom draw club shape

The following code uses bezierCurveTo() method to draw custom shape.

Demo

ResultView the demo in separate window

<html>
    <head>
        <script>
            function draw(context, x, y, width, height){
                context.save();/*ww w.j  av  a  2  s. c  om*/
                let circleRadius = width * 0.3;
                let bottomWidth = width * 0.5;
                let bottomHeight = height * 0.35;
                context.fillStyle = "black";
        
                // top circle
                context.beginPath();
                context.arc(x, y + circleRadius + (height * 0.05), 
                            circleRadius, 0, 2 * Math.PI, false
                );
                context.fill();
                
                // bottom right circle
                context.beginPath();
                context.arc(x + circleRadius, y + (height * 0.6), 
                            circleRadius, 0, 2 * Math.PI, false
                );
                context.fill();
                
                // bottom left circle
                context.beginPath();
                context.arc(x - circleRadius, y + (height * 0.6), 
                            circleRadius, 0, 2 * Math.PI, false
                );
                context.fill();
                
                // center filler circle
                context.beginPath();
                context.arc(x, y + (height * 0.5), 
                            circleRadius / 2, 0, 2 * Math.PI, false
                );
                context.fill();
                
                // bottom of club
                context.moveTo(x, y + (height * 0.6));
                context.quadraticCurveTo(x, y + height, 
                                         x - bottomWidth / 2, y + height
                );
                context.lineTo(x + bottomWidth / 2, y + height);
                context.quadraticCurveTo(x, y + height, 
                                         x, y + (height * 0.6)
                );
                context.closePath();
                context.fill();
                context.restore();

            }
            
            window.onload = function(){
                let canvas = document.getElementById("myCanvas");
                let context = canvas.getContext("2d");
        
                draw(context, canvas.width * 0.2, 70, 75, 100);
            };
        </script>
    </head>
    <body>
        <canvas id="myCanvas" width="600" height="250" style="border:1px solid black;">
        </canvas>
    </body>
</html>