How to create Linear in XML

In this article I have describe about example of Linear in XML
  • 1920

Read about SVG here

Create a linear in SVG

The <linearGradient> element is defining linear gradient, it is use <defs> element in gradient in SVG.

Linear is require id attributes.

Define <linearGradient> in a circle.

Example

<?xml version="1.0" encoding="utf-8" ?>

<html>

  <body>

    <svg xmlns="http://www.w3.org/2000/svg" version="1.1">

      <defs>

        <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">

          <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />

          <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />

        </linearGradient>

      </defs>

      <rect x="50" y="20" width="150" height="150" fill="url(#grad1)" />

    </svg>

  </body>

</html>

 

Output

 SVG Linear.jpg

Define the code

  • XML define the namespace and version use the program.
  • <linearGradient> is define the linear in a rectangle.
  • stop process is define range of linear
  • <rect> is create a circle shape and style is show the color of the rectangle.
  • The <rect> element links the element to the (#grad1)

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.