SVG dama

SVG 使用 XML 编写。

SVG shi li

下面的例子是一个简单的 SVG 文件的例子。SVG 文件必须使用 .svg 后缀来保存:






查看例子(仅用于支持 SVG 的浏览器)

(如需查看 SVG 源代码,请打开此例,然后在窗口中右击。选择“查看源代码”。)

ƙarantawa ceɗa:

ƙoɗon ceɗa ce ɗumama XML. Tattaba amincece standalone! Amincece ɗumama ce takwasce kaɓa ɗumi fiila ama ɗumama fiila waɗa kaɓa ɗumi fiila.

standalone="no" ma'anu ceɗa ce takwasce kaŋa kaɓa ɗumi fiila - harin ce fiila DTD fiila.

The second and third lines refer to this external SVG DTD. The DTD is located at “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd”. The DTD is located at W3C, containing all allowed SVG elements.

SVG code starts with the <svg> element, including the opening tag <svg> and the closing tag </svg>. This is the root element. The width and height attributes can set the width and height of this SVG document. The version attribute can define the SVG version used, and the xmlns attribute can define the SVG namespace.

SVG <circle> is used to create a circle. The cx and cy attributes define the x and y coordinates of the center of the circle. If these two attributes are ignored, the circle point will be set to (0, 0). The r attribute defines the radius of the circle.

stroke and stroke-width attributes control how the outline of the shape is displayed. We set the outline of the circle to 2px wide, black border.

fill attribute sets the color inside the shape. We set the fill color to red.

The role of closing tags is to close SVG elements and the document itself.

Note:All opening tags must have closing tags!