HTML Canvas Circle

Description

HTML Canvas Circle

View in separate window

<html>
    <head>
        <script>
            window.onload = function(){
                var canvas = document.getElementById("myCanvas");
                var context = canvas.getContext("2d");
                /*from w  ww . j a v a 2s . c o  m*/
                context.arc(canvas.width / 2, 
                            canvas.height / 2, 
                            70, 
                            0, 
                            2 * Math.PI, 
                            false);
                context.fillStyle = "red";
                context.fill();
                context.lineWidth = 5;
                context.strokeStyle = "black";
                context.stroke();
            };
        </script>
    </head>
    <body>
        <canvas id="myCanvas" width="600" height="250" style="border:1px solid black;">
        </canvas>
    </body>
</html>



PreviousNext

Related