[翻译svg教程]svg中的circle元素

svg中的<circle> 元素,是用来绘制圆形的,例如html

<svg xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">

    <circle cx="40" cy="40" r="24" style="stroke:#006600; fill:#00cc00"/>

</svg>

 

效果以下svg

image

属性说明 cx,cy 设定圆心,r设定半径3d

圆形的边框

能够经过设置样式设置圆形的边框code

例如 xml

<circle cx="40" cy="40" r="24"
    style="stroke:#006600;
           stroke-width: 3;
           fill:#00cc00"/>
属性说明 stroke             边框的颜色
        stroke-width       边框的宽度
        fill               填充的颜色
效果以下
image
固然能够经过   属性设置边框为虚线 stroke-dasharray
例如
<circle cx="40" cy="40" r="24"
    style="stroke:#006600;
           stroke-width: 3;
           stroke-dasharray: 10 5;
           fill:#00cc00"/>
效果以下 
image
也能够禁用边框 例如
<circle cx="40" cy="40" r="24"
    style="stroke: none;
           fill:#00cc00"/>
效果
image

圆形的填充

style 中的fill 属性用于设置圆形如何填充,若是不想圆形被填充能够把fill设置为nonehtm

例如 这是一个不填充的效果 blog

<circle cx="40" cy="40" r="24"
    style="stroke: #00600;
           fill:none"/>

image

这是一个填充颜色的例子 ip

<circle cx="40" cy="40" r="24"
    style="stroke: #660066;
           fill: #00ff00"/>

image

还能够经过fill-opacity来设置透明度ci

例如两个圆部分重叠在一块儿get

<circle cx="40" cy="40" r="24"
    style="stroke: #660000;
           fill: #cc0000" />
<circle cx="64" cy="40" r="24"
    style="stroke: #000066;
           fill: #0000cc"
           fill-opacity: 0.5/>
image
相关文章
相关标签/搜索