SVG <ellipse>

Het <ellipse> tag kan gebruikt worden om een ellips te maken.

<ellipse> tag

Het <ellipse> tag kan gebruikt worden om een ellips te maken. Een ellips lijkt sterk op een cirkel. Het verschil is dat een ellips verschillende x- en y-stralen heeft, terwijl de x- en y-stralen van een cirkel gelijk zijn.

Kopieer de onderstaande code naar een notitiesbestand, sla het bestand op als "ellipse1.svg". Plaats dit bestand in uw webdirectory:

<?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>

Codeverklaring:

  • Het attribuut cx definieert de x-coördinaat van het middelpunt
  • Het attribuut cy definieert de y-coördinaat van het middelpunt
  • Het attribuut rx definieert de horizontale straal
  • De attribuut ry definieert de verticale straal

View Example

Hier is een voorbeeld dat drie op elkaar gestapelde ellipsen creëert:

<?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>

View Example

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>

View Example