SVG <ellipse>
- Previous Page SVG Circles
- Next Page SVG Lines
The <ellipse> tag is used to create ellipses.
The <ellipse> tag
The <ellipse> tag is used to create ellipses. Ellipses are similar to circles. The difference is that ellipses have different x and y radii, while circles have the same x and y radii.
Please copy the following code into a text editor, then save the file as "ellipse1.svg". Place this file in your web directory:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"> "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1"> xmlns="http://www.w3.org/2000/svg"> <ellipse cx="300" cy="150" rx="200" ry="80" style="fill:rgb(200,100,50); stroke:rgb(0,0,100);stroke-width:2"/> </svg>
Code Explanation:
- The 'cx' attribute defines the x-coordinate of the center point
- The 'cy' attribute defines the y-coordinate of the center point
- The 'rx' attribute defines the horizontal radius
- The 'ry' attribute defines the vertical radius
The following example creates three stacked ellipses:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"> "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1"> xmlns="http://www.w3.org/2000/svg"> <ellipse cx="240" cy="100" rx="220" ry="30" style="fill:purple"/> <ellipse cx="220" cy="70" rx="190" ry="20" style="fill:lime"/> <ellipse cx="210" cy="45" rx="170" ry="15" style="fill:yellow"/> </svg>
The following example combines two ellipses (one yellow and one white):
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"> "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1"> xmlns="http://www.w3.org/2000/svg"> <ellipse cx="240" cy="100" rx="220" ry="30" style="fill:yellow"/> <ellipse cx="220" cy="100" rx="190" ry="20" style="fill:white"/> </svg>
- Previous Page SVG Circles
- Next Page SVG Lines