Showing posts with label SVG. Show all posts
Showing posts with label SVG. Show all posts

13 Sept 2016

Animation in HTML using CSS

HTML Code:


 <!----------------------------------------------  
 Author: Qaidjohar  
 Creation Date: 13/09/16  
 Logical Comment: Animation Using CSS - HTML file  
 ----------------------------------------------->  
   
 <html>  
 <head>  
 <title>Animation using CSS</title>  
 <link rel="stylesheet" type="text/css" href="html_animation_post.css">  
 </head>  
     
 <body>  
 <!-------------------main div---------------------------->  
 <div class="main">  
     
 <!-------------------header div---------------------------->  
 <div class="header">  
 <h1>Animation in HTML using CSS</h1>  
 </div>  
     
 <!-------------------container div---------------------------->  
 <div class="container">  
 <div class="go">  
   <svg height="100%" width="100%">  
     <rect height="100px" width="10px" x="55" y="250" fill="black"/>  
     <polygon points="20,210 30,200 100,200 110,210 110,240 100,250 30,250 20,240" fill="white" stroke="black" stroke-width="2px"/>  
     <polygon points="30,220 80,220 80,210 100,225 80,240 80,230 30,230" fill="red"/>  
   </svg>  
 </div>  
     
 <div class="ball">  
   <svg height="120px" width="120px">  
     <circle cx="60" cy="60" r="58px" fill="yellow" stroke="darkorange" stroke-width="3px"/>  
     <circle cx="80" cy="40" r="12px" fill="black"/>  
     <ellipse rx="4px" ry="5px" cx="85" cy="40" fill="grey"/>  
     <ellipse rx="30px" ry="8px" cx="80" cy="90" fill="pink" stroke="darkorange" stroke-width="2px"/>  
   </svg>  
 </div>  
     
 <div class="road">  
   <svg height="50px" width="100%">  
     <rect height="40px" width="127px" x="13" y="0" fill="brown" stroke="darkred" stroke-width="3px"/>   
     <rect height="40px" width="140px" x="150" y="0" fill="brown" stroke="darkred" stroke-width="3px"/>  
     <rect height="40px" width="140px" x="300" y="0" fill="brown" stroke="darkred" stroke-width="3px"/>   
     <rect height="40px" width="140px" x="450" y="0" fill="brown" stroke="darkred" stroke-width="3px"/>  
     <rect height="40px" width="140px" x="600" y="0" fill="brown" stroke="darkred" stroke-width="3px"/>  
     <rect height="40px" width="140px" x="750" y="0" fill="brown" stroke="darkred" stroke-width="3px"/>  
     <rect height="40px" width="140px" x="900" y="0" fill="brown" stroke="darkred" stroke-width="3px"/>   
   </svg>  
 </div>  
 </div>  
     
 <!-------------------footer div---------------------------->  
 <div class="footer">  
 <h3>(: Keep calm and love Open Source :)</h3>  
 </div>  
 </div>  
 </body>  
 </html>  

CSS code:


 /**********************************************  
 Author: Qaidjohar  
 Creation Date: 13/09/16  
 Logical Comment: Animation Using CSS - CSS file  
 **********************************************/  
   
 *  
 {  
      margin:0px;  
      padding:0px;  
 }  
   
 .main  
 {  
      height:550px;  
      width:1000px;  
   margin-left: 183px;  
 }  
   
 .header  
 {  
      height:100px;  
      width:100%;  
      background-color:chocolate;  
 }  
   
 h1  
 {  
      color:aqua;  
      text-align:center;  
      line-height:100px;  
 }  
   
 .container  
 {  
      height:400px;  
      width:100%;  
      background-color:burlywood;  
 }  
   
 .go   
 {  
   height: 400px;  
   width: 130px;  
   float: left;  
 }  
   
 .ball  
 {  
   height: 120px;  
   width: 120px;  
   position: absolute;  
   margin-top: 230px;  
   margin-left: 200px;  
   animation: animBall 1.5s infinite;  
 }  
   
 .road  
 {  
   height: 50px;  
   width: 1000px;  
   position: absolute;  
   margin-top: 350px;  
   animation: animRoad 0.5s infinite;  
 }  
   
 .footer  
 {  
      height:50px;  
      width:100%;  
      background-color:chocolate;  
 }  
   
 h3  
 {  
      text-align:center;  
      line-height:50px;  
   color:darkred;  
 }  
   
 @keyframes animRoad  
 {  
   100% {margin-left: -10px;}    
 }  
   
 @keyframes animBall  
 {  
   25%{margin-left: 300px;margin-top: 130px; transform: rotate(90deg);}  
   50%{margin-left: 400px;margin-top: 30px; transform: rotate(180deg);}  
   75%{margin-left: 500px;margin-top: 130px; transform: rotate(270deg);}  
   100%{margin-left: 600px;margin-top: 230px; transform: rotate(360deg);}  
 }  

Output:


23 Aug 2016

Scalar Vector Graphics

Using SVG tag in HTML, one can draw various shapes like rectangle, circle, ellipse and polygon in web page. Below is one demonstration of SVG tag including HTML file, CSS file and output image:

HTML File:


 <!----------------------------------  
 Author: Qaidjohar  
 Creation Date: Aug 23,2016  
 Logical Comment: HTML file for SVG Demo  
 ----------------------------------->  
   
 <html>  
 <head>  
 <title>SVG Demo</title>  
 <link rel="stylesheet" type="text/css" href="../css/blog_svg.css">  
 </head>  
 <body>  
 <!-------------------------Main Div-------------------------------->  
 <div class="main">  
 <!-------------------------Header Div------------------------------>  
 <div class="header">  
 <h1>Scalar Vector Graphics</h1>  
 </div>  
 <!-------------------------Container Div--------------------------->  
 <div class="container">  
 <svg height=100% width=100%>  
 <!----------------------Mountain and Sun--------------------------->  
 <polygon points="0,500 125,250 250,500" fill="brown" stroke="orange" stroke-width="3px"/>  
 <circle cx="365" cy="322" r="50px" fill="yellow"/>  
 <polygon points="187,375 250,250 375,375 312,500 250,500" fill="brown" stroke="orange" stroke-width="3px"/>  
 <polygon points="312,500 437,250 500,500" fill="brown" stroke="orange" stroke-width="3px"/>  
 <!-------------------------House----------------------------------->  
 <rect height="125px" width="60px" x="625" y="375" fill="cyan" stroke="black" stroke-width="2px"/>  
 <rect height="125px" width="190px" x="685" y="375" fill="cyan" stroke="black" stroke-width="2px"/>  
 <polygon points="625,375 655,312 685,375" fill="pink" stroke="black" stroke-width="2px"/>  
 <circle cx="655" cy="353" r="13px" fill="black"/>  
 <ellipse rx="5px" ry="8px" cx="662" cy="353" fill="grey"/>  
 <polygon points="655,312 845,312 875,375 685,375" fill="pink" stroke="black" stroke-width="2px"/>  
 <rect height="50px" width="30px" x="640" y="450" fill="grey" stroke="black" stroke-width="2px"/>  
 <rect height="25px" width="25px" x="720" y="410" fill="grey" stroke="black" stroke-width="2px"/>  
 <rect height="25px" width="25px" x="805" y="410" fill="grey" stroke="black" stroke-width="2px"/>  
 <!-------------------------Tree------------------------------------>  
 <rect height="63px" width="25px" x="927" y="437" fill="brown"/>  
 <polygon points="900,437 937,400 980,437" fill="green"/>  
 <polygon points="900,417 937,380 980,417" fill="green"/>  
 <polygon points="900,395 937,355 980,395" fill="green"/>  
 </svg>  
 </div>  
 <!-------------------------Footer Div-------------------------------->  
 <div class="footer">  
 <p>(: Open Source :)</p>  
 </div>  
 </div>  
 </body>  
 </html>  
   

CSS File:


 /*  
 Author: Qaidjohar  
 Creation Date: Aug 23,2016  
 Logical Comment: CSS file for SVG Demo  
 */  
   
 *  
 {  
      margin:0px;  
      padding:0px;  
 }  
   
 body  
 {  
      background-color:pink;  
 }  
 .main  
 {  
      height:650px;  
      width:1000px;  
      margin-left:183px;  
 }  
   
 .header  
 {  
      height:100px;  
      width:1000px;  
      background-color:black;  
 }  
   
 h1  
 {  
      color:yellow;  
      text-align:center;  
      line-height:90px;  
 }  
   
 .container  
 {  
      height:500px;  
      width:1000px;  
        
 }  
   
 svg  
 {  
      background-color:#AAAAFF;  
 }  
   
 .footer  
 {  
      height:50px;  
      width:1000px;  
      background-color:grey;  
 }  
   
 p  
 {  
      color:white;  
      text-align:center;  
      line-height:50px;  
      font-size:20px;  
 }  

Output: