天天看點

SVG <ellipse>

<ellipse> 元素是用來建立一個橢圓:

橢圓與圓很相似。不同之處在于橢圓有不同的x和y半徑,而圓的x和y半徑是相同的:

下面是SVG代碼:

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

<ellipse cx="300" cy="80" rx="100" ry="50"

style="fill:yellow;stroke:purple;stroke-width:2"/>

</svg>

對于Opera使用者:檢視SVG檔案(右鍵單擊SVG圖形預覽源)。

<b>代碼解析:</b>

CX屬性定義的橢圓中心的x坐标

CY屬性定義的橢圓中心的y坐标

RX屬性定義的水準半徑

RY屬性定義的垂直半徑

下面的例子建立了三個累疊而上的橢圓:

&lt;ellipse cx="240" cy="100" rx="220" ry="30" style="fill:purple"/&gt;

&lt;ellipse cx="220" cy="70" rx="190" ry="20" style="fill:lime"/&gt;

&lt;ellipse cx="210" cy="45" rx="170" ry="15" style="fill:yellow"/&gt;

下面的例子組合了兩個橢圓(一個黃的和一個白的):

&lt;ellipse cx="240" cy="50" rx="220" ry="30" style="fill:yellow"/&gt;

&lt;ellipse cx="220" cy="50" rx="190" ry="20" style="fill:white"/&gt;