SVG <ellipse>元素

<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.html -

<html>
   <title>SVG橢圓形</title>
   <body>

      <h1>簡單SVG橢圓形圖片</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網路流覽器中打開testSVG.html。 您可以使用Chrome/Firefox/Opera直接查看SVG圖像,無需任何插件。 Internet Explorer 9及更高版本還支持SVG圖像呈現。

不透明度示例

<html>
   <title>SVG橢圓形</title>
   <body>

      <h1>簡單SVG橢圓形圖片</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>

在流覽器中打開上述代碼,顯示效果如下 -


上一篇: SVG形狀 下一篇: SVG文本