Monday, April 13, 2020

HOW TO DRAW A LINE IN HTML ?

<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="CONTENT-TYPE" content="text/html; charset=UTF-8">
        <title>Hello, World!</title> 
       
    </head>
    <body>
        <h1>
            Hello, World!
        </h1>
       
        Here we will study about the canvas tag. It is used for drawing lines, circles, gradients etc on a webpage.
        <br>
       <canvas id="Circle" style="border:solid 2px" height="200" width="200">
           My browser
        </canvas>
       
           <script type="text/javascript">
           
            alert("Welcome to my page.");
            document.write("Hello");
            var c = document.getElementById("Circle");
            var cont1 = c.getContext("2d");
          
            cont1.moveTo(50,50);
            cont1.lineTo(100,100);
          
              
               cont1.moveTo(150,150);
               cont1.lineTo(200,200);
              
               cont1.stroke();
           
           
           
         
           
           
        </script>
       
       
       
       
    </body>
</html>


OUTPUT : 


No comments:

Post a Comment