SVG - 圆形



<circle> 元素用于绘制以中心点和给定半径为参数的圆形。

声明

以下是<circle>元素的语法声明。我们只展示了主要属性。

<circle
   cx="x-axis co-ordinate"
   cy="y-axis co-ordinate"
   r="length" >   
</circle>

属性

序号 名称及描述
1 cx − 圆心在 x 轴上的坐标。默认为 0。
2 cy − 圆心在 y 轴上的坐标。默认为 0。
3 r − 圆的半径。

示例

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

输出

在 Chrome 浏览器中打开 textSVG.htm。您可以使用 Chrome/Firefox/Opera 直接查看 SVG 图像,无需任何插件。Internet Explorer 9 及更高版本也支持 SVG 图像渲染。

具有透明度的圆形

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

输出

在 Chrome 浏览器中打开 textSVG.htm。您可以使用 Chrome/Firefox/Opera 直接查看 SVG 图像,无需任何插件。Internet Explorer 9 及更高版本也支持 SVG 图像渲染。

svg_shapes.htm
广告

© . All rights reserved.