SVG - 橢圓



<ellipse> 元素用於繪製橢圓,使用中心點和兩個半徑。

宣告

以下是<ellipse>元素的語法宣告。我們只顯示了主要屬性。

<ellipse
   cx="x-axis co-ordinate"
   cy="y-axis co-ordinate"
   
   rx="length" 
   ry="length" >    
</ellipse>

屬性

序號 名稱和描述
1 cx − 橢圓中心的 x 座標。預設為 0。
2 cy − 橢圓中心的 y 座標。預設為 0。
3 rx − 橢圓的 x 軸半徑。
4 ry − 橢圓的 y 軸半徑。

示例

testSVG.htm
<html>
   <title>SVG Ellipse</title>
   <body>
   
      <h1>Sample SVG Ellipse Image</h1>
      <svg width="800" height="800">
         <g>
            <text x="0" y="15" fill="black" >Ellipse #1: Without opacity.</text>
            
            <ellipse cx="100" cy="100" rx="90" ry="50" 
            stroke="black" stroke-width="3" fill="rgb(121,0,121)"></ellipse>
         </g> 
      </svg>
   
   </body>
</html>

輸出

在 Chrome 瀏覽器中開啟 textSVG.htm。您可以使用 Chrome/Firefox/Opera 直接檢視 SVG 圖片,無需任何外掛。Internet Explorer 9 及更高版本也支援 SVG 圖片渲染。

具有透明度的橢圓

<html>
   <title>SVG Ellipse</title>
   <body>
      
      <h1>Sample SVG Ellipse Image</h1>
      
      <svg width="800" height="800">
         <g>
            <text x="0" y="15" fill="black" >Ellipse #2: With opacity </text>
            
            <ellipse cx="100" cy="100" rx="90" ry="50" 
            style="fill:rgb(121,0,121);stroke-width:3;
            stroke:rgb(0,0,0);stroke-opacity:0.5;opacity:0.5"></ellipse> 
         </g>
      </svg>
   
   </body>
</html>

輸出

在 Chrome 瀏覽器中開啟 textSVG.htm。您可以使用 Chrome/Firefox/Opera 直接檢視 SVG 圖片,無需任何外掛。Internet Explorer 9 及更高版本也支援 SVG 圖片渲染。

svg_shapes.htm
廣告