Sunday, March 22, 2015

Explain Linear in SVG

As like radial linear is also a kind of gradient in SVG, now to define a gradient I would say that a gradient is  a smooth transition which occurs from a color to another color. <linearGradient> element is used  for the purpose of defining and describing the linear gradient,  <linearGradient> element should be nested with some tags like <defs>.



Example:

 <!DOCTYPE html>  
 <html>  
 <head lang="en">  
   <meta charset="UTF-8">  
   <title>Nirajan Ghimirey’s Workshop  </title>  
 </head>  
 <body>  
 <h1>Example for Linear </h1>  
 <svg height="200" width="400">  
   <defs>  
     <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">  
       <stop offset="0%" style="stop-color:rgb(58, 175, 255);stop-opacity:1" />  
       <stop offset="100%" style="stop-color:rgb(33, 228, 255);stop-opacity:1" />  
     </linearGradient>  
   </defs>  
   <ellipse cx="200" cy="70" rx="85" ry="55" fill="url(#grad1)" />  
 </svg>  
 <svg height="200" width="400">  
   <defs>  
     <linearGradient id="grad2" x1="0%" y1="0%" x2="0%" y2="100%">  
       <stop offset="0%" style="stop-color:rgb(101, 166, 255);stop-opacity:1" />  
       <stop offset="100%" style="stop-color:rgb(33, 228, 255);stop-opacity:1" />  
     </linearGradient>  
   </defs>  
   <ellipse cx="200" cy="70" rx="85" ry="55" fill="url(#grad2)" />  
 </svg>  
 </body>  
 </html> 



No comments:

Post a Comment