實例 1
lt;ellipse> 元素是用來創(chuàng)建一個橢圓:
橢圓與圓很相似。不同之處在于橢圓有不同的x和y半徑,而圓的x和y半徑是相同的:
下面是SVG代碼:
實例
<!DOCTYPE html> <html> <body> <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> </body> </html>
運(yùn)行實例 ?
點擊 "運(yùn)行實例" 按鈕查看在線實例
對于Opera用戶:查看SVG文件(右鍵單擊SVG圖形預(yù)覽源)。
代碼解析:
CX屬性定義的橢圓中心的x坐標(biāo)
CY屬性定義的橢圓中心的y坐標(biāo)
RX屬性定義的水平半徑
RY屬性定義的垂直半徑
實例 2
下面的例子創(chuàng)建了三個累疊而上的橢圓:
下面是SVG代碼:
實例
<!DOCTYPE html> <html> <body> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <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> </body> </html>
運(yùn)行實例 ?
點擊 "運(yùn)行實例" 按鈕查看在線實例
對于Opera用戶:查看SVG文件(右鍵單擊SVG圖形預(yù)覽源)。
實例 3
下面的例子組合了兩個橢圓(一個黃的和一個白的):
下面是SVG代碼:
實例
<!DOCTYPE html> <html> <body> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <ellipse cx="240" cy="50" rx="220" ry="30" style="fill:yellow" /> <ellipse cx="220" cy="50" rx="190" ry="20" style="fill:white" /> </svg> </body> </html>
運(yùn)行實例 ?
點擊 "運(yùn)行實例" 按鈕查看在線實例
對于Opera用戶:查看SVG文件(右鍵單擊SVG圖形預(yù)覽源)。