Home » SVG 入門教學

[SVG]SVG 基本圖形 - 圓形 circle

<circle> 標籤可以用來產生一個圓形。

1
2
3
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
	<circle cx="60" cy="60" r="50" />
</svg>

cxcy 是指定圓形的中心點,而 r 就是圓形的半徑:

svg-shape-circle-1

也一樣能自訂樣式:

1
2
3
4
5
6
7
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
	<circle cx="60" cy="60" r="50" style="fill:steelblue;stroke:red;stroke-width:10;" />
 
	<circle cx="190" cy="60" r="50" style="fill:steelblue;stroke:red;stroke-width:10;fill-opacity:.5;" />
 
	<circle cx="320" cy="60" r="50" style="fill:steelblue;stroke:red;stroke-width:10;opacity:.5;" />
</svg>

svg-shape-circle-2

筆者將 circle 的屬性整理成一個簡單的表格:

circle 屬性

屬性名稱 屬性說明
cx 圓形中心點 x 軸的座標
cy 圓形中心點 y 軸的座標/td>
r 圓形的半徑
transform 圓形的變形效果,類似 css 中的 transform

[ 標籤: ]

發表迴響