SVG语法标签属性解释手册

1. SVG元素模块

Animation.Module animate animateColor animateTransform animateMotion set mpath
剪裁模块clipPath
颜色轮廓模块 color-profile
条件处理模块switch
光标模块cursor
扩展性模块foreignObject
过滤器模块filter feFlood feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feFlood feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset feSpecularLighting feTile feTurbulence feDistantLight fePointLight feSpotLight feFuncR feFuncG feFuncB feFuncA
Font.Module fontfont-face glyph missing-glyph hkern vkern font-face-src font-face-uri font-face-format font-face-name definition-src
梯度模块 linearGradientradialGradientstop
Hyperlink.Modulea
图像模块

 

image
标记模块marker
遮罩模块mask
阵列模块pattern
脚本模块script
造型模块path rect circle line polyline polygon ellipse
结构模块 svg g defs desc title metadata symbol use
样式模块style
文本模块 text tspan tref textPath altGlyph altGlyphDef altGlyphItem glyphRef
视图模块view


2.SVG解释的元素

2.1 超链接模块

元素

属性

描述

a Core.attrib, Conditional.attrib, Style.attrib, transform, target, GraphicalEvents.attrib, Presentation.attrib, External.attrib, XLinkReplace.attrib 联结一组图元, 以链接属性(本地或非本地 URI)。该链接在可视化过程中处于非活动状态,但每次转换到 CGM 时都保存该链接。
2.2 图像模块

元素

属性

内容模型

image

Core.attrib, XLinkEmbed.attrib, Conditional.attrib, Style.attrib, External.attrib, GraphicalEvents.attrib, preserveAspectRatio, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, Profile.attrib, Viewport.attrib, transform, x, y, width, height

描述通过外部文件链接(相对路径或绝对路径)或通过 base64 编码(这种情况下,可以读取的格式有:BMP、JPEG、TIFF 或 PNG)定义的矢量图像或位图图像。
支持外部位图图像链接,但不支持矢量图像链接。
2.3 标记模块

元素

属性

内容模型

marker

Core.attrib, External.attrib, Style.attrib,Presentation.attrib, viewBox,preserveAspectRatio,refX, refY,markerUnits, markerWidth, markerHeight, orient

通过标记属性定义一组重用作标记的图元。
不考虑 markerUnits 属性,它被视为与属性 userSpaceOnUse 相同。
不考虑 orient 属性,标记不按照路径段定向。应用标记时始终不定向。
2.4 阵列模块

元素

属性

内容模型

pattern

Core.attrib, XLink.attrib, Conditional.attrib , External.attrib, Style.attrib, Presentation.attrib, viewBox, preserveAspectRatio, patternTransform, x, y, width, height, patternUnits 定义一组重用于填充或绘制造型的图元。
不考虑 patternUnits 属性,它被视为与属性 userSpaceOnUse 相同。
仅解释用位图阵列定义的阵列。不识别用向量元素集定义的阵列。
因此,阵列元素的子级应为 <image> 类型。这样可以读取
包含填充纹理的工程制图文档。
2.5 造型模块

元素

属性

内容模型

path

Core.attrib, Conditional.attrib, External.attrib, Style.attrib, transform, d, pathLength, GraphicalEvents.attrib, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, Marker.attrib

定义造型的轮廓。它由圆弧、椭圆弧、直线、三次贝塞尔曲线<!--webbot bot="HTMLMarkup" startspan --><!--webbot bot="HTMLMarkup" endspan -->和二次贝塞尔曲线<!--webbot bot="HTMLMarkup" startspan --><!--webbot bot="HTMLMarkup" endspan -->组成。此轮廓可以是封闭的或开放的。更多信息可参见“SVG中Path路径指令教程”

rect

Core.attrib, Conditional.attrib, Style.attrib, GraphicalEvents.attrib, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, x, y, width, height, rx,ry,transform

定义矩形。
不解释圆角。

circle

Core.attrib, Conditional.attrib, Style.attrib, GraphicalEvents.attrib, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, cx, cy, r, transform

定义圆。

line

Core.attrib, Conditional.attrib, Style.attrib, GraphicalEvents.attrib, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, x1, y1, x2, y2, transform

定义直线。

ellipse

Core.attrib, Conditional.attrib, Style.attrib, GraphicalEvents.attrib, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, cx, cy, rx, ry, transform

定义椭圆。

polyline

Core.attrib, Conditional.attrib, Style.attrib, GraphicalEvents.attrib, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, points, transform

定义折线。
如果折线处于开放模式,则仅绘制轮廓,不填充折线。

 

polygon

Core.attrib, Conditional.attrib, Style.attrib, GraphicalEvents.attrib, Paint.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, points, transform

定义多边形

2.6 结构模块

元素

属性

内容模型

svg

Core.attrib, Conditional.attrib, Style.attrib, x, y, width, height, viewBox, preserveAspectRatio, zoomAndPan, version, baseProfile, contentScriptType, contentStyleType, External.attrib, Presentation.attrib, GraphicalEvents.attrib, DocumentEvents.attrib

编组 SVG 图像。

g

Core.attrib, Conditional.attrib, Style.attrib, External.attrib, Presentation.attrib, GraphicalEvents.attrib, transform

将具有相同属性的一个或多个元素编组在一起。

defs

Core.attrib, Conditional.attrib, Style.attrib, External.attrib, Presentation.attrib, GraphicalEvents.attrib, transform

定义要重用的元素组。它的子级因此是参考元素。

desc

Core.attrib, Style.attrib

描述元素。

title

Core.attrib, Style.attrib

指示元素的标题。

symbol

Core.attrib, Style.attrib, External.attrib, viewBox, preserveAspectRatio, Presentation.attrib, GraphicsElementEventAttrs

定义一组要重用的元素。

use

Core.attrib, Style.attrib, Conditional.attrib, transform,x, y, width, height, XLinkEmbed.attrib, Presentation.attrib, GraphicsElementEventAttrs

参考一组预定义元素以便显示它。

2.7 文本模块

元素

属性

内容模型

text Core.attrib, Conditional.attrib, External.attrib, Style.attrib, transform, x, y, dx,dy,rotate, textLength,lengthAdjust, GraphicalEvents.attrib,Paint.attrib, Font.attrib, Opacity.attrib, Graphics.attrib, Cursor.attrib, Filter.attrib, Mask.attrib, GraphicalEvents.attrib, Clip.attrib, TextContent.attrib, Text.attrib 定义文本。

文本颜色是笔画颜色定义的颜色,如果没有明确定义笔画颜色,则使用填充颜色。


三、SVG模块属性

3.1 动画属性集

集合名称

集合属性

Animation.attrib

XLink.attrib

AnimationAttribute.attrib

attributeName, attributeType

AnimationTiming.attrib

begin, dur, end, min, max, restart, repeatCount, repeatDur, fill

AnimationValue.attrib

calcMode, values, keyTimes, keySplines, from, to, by

AnimationAddtion.attrib

additive, accumulate

3.2 动画事件属性模块

集合名称

集合属性

AnimationEvents.attrib

onbegin, onend, onrepeat, onload

3.3 剪裁属性集

集合名称

集合属性

Clip.attrib

clip-path, clip-rule

3.4 条件处理属性集

集合名称

集合属性

Conditional.attrib

requiredFeatures, requiredExtensions, systemLanguage

3.5 容器属性模块

集合名称

集合属性

Container.attrib

enable-background

3.6 内核属性模块

集合名称

集合属性

Core.attrib

id, xml:base, xml:lang, xml:space

3.7 光标属性集

集合名称

集合属性

Cursor.attrib

cursor

3.8 文档事件属性模块

集合名称

集合属性

DocumentEvents.attrib

onunload, onabort, onerror, onresize, onscroll, onzoom

3.9 外部资源要求属性模块

集合名称

集合属性

External.attrib

externalResourcesRequired

3.10 梯度属性集

集合名称

集合属性

Gradient.attrib

stop-color, stop-opacity

3.11 图形元素事件属性模块

集合名称

集合属性

GraphicalEvents.attrib

onfocusin, onfocusout, onactivate, onclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onload

3.12 图形属性模块

集合名称

集合属性

Graphics.attrib

display, image-rendering, pointer-events, shape-rendering, text-rendering,visibility

3.13 过滤器属性集

集合名称

集合属性

Filter.attrib

filter

FilterColor.attrib

color-interpolation-filters

FilterPrimitive.attrib

x, y, width, height, result

FilterPrimitiveWithIn.attrib

FilterPrimitive.attrib, in

3.14 标记属性集

集合名称

集合属性

Marker.attrib

marker-start, marker-mid, marker-end

3.15 遮罩属性集

集合名称

集合属性

Mask.attrib

mask

3.16 不透明属性模块

集合名称

集合属性

Opacity.attrib

opacity, stroke-opacity, fill-opacity

3.17 涂料属性模块

集合名称

集合属性

Paint.attrib

color, fill, fill-rule, stroke, stroke-dasharray, stroke-dashoffset, stroke-linecap, stroke-linejoin, stroke-miterlimit, stroke-width, color-interpolation, color-rendering

3.18 样式属性集

集合名称

集合属性

Style.attrib

style, class

3.19 文本属性集

集合名称

集合属性

Text.attrib

writing-mode

TextContent.attrib

alignment-baseline, baseline-shift, direction, dominant-baseline, glyph-orientation-horizontal, glyph-orientation-vertical, kerning, letter-spacing, text-anchor, text-decoration, unicode-bidi, word-spacing

Font.attrib

font-family, font-size, font-size-adjust, font-stretch, font-style, font-variant, font-weight

3.20 视口属性模块

集合名称

集合属性

Viewport.attrib

clip, overflow

  视口属性更多的文章请浏览:"SVG格式图形显示的坐标系统规则"

3.21 XLink 属性模块

集合名称

集合属性

XLink.attrib

xlink:type, xlink:href, xlink:role, xlink:arcrole, xlink:title, xlink:show, xlink:actuate

XLinkRequired.attrib

xlink:type, xlink:href, xlink:role, xlink:arcrole, xlink:title, xlink:show, xlink:actuate

XLinkEmbed.attrib

xlink:type, xlink:href, xlink:role, xlink:arcrole, xlink:title, xlink:show, xlink:actuate

XLinkReplace.attrib

xlink:type, xlink:href, xlink:role, xlink:arcrole, xlink:title, xlink:show, xlink:actuate

四、SVG解释的属性

4.1 内核属性模块

集合名称

集合属性

id图形图元的标识符。
4.2 图形属性模块

集合名称

集合属性

display显示或隐藏图形图元。

仅解释值“none”。

4.3 标记属性集

集合名称

集合属性

marker-start在图元的第一个点绘制标记。
marker-mid在图元的每个其它点(即除第一个点和最后一个点)绘制标记。
marker-end在图元的最后一个点绘制标记。
4.4 不透明属性模块

集合名称

集合属性

opacity定义图元的透明度。
只有能够另存为光栅图像的格式才可以管理透明度。因此,不显示透明度。
而且,即使当另存为光栅图像时,透明度也不支持嵌套。
stroke-opacity定义图元轮廓的透明度。
只有能够另存为光栅图像的格式才可以管理透明度。因此,不显示透明度。
而且,即使当另存为光栅图像时,透明度也不支持嵌套。
fill-opacity定义图元填充的透明度。
只有能够另存为光栅图像的格式才可以管理透明度。因此,不显示透明度。
而且,即使当另存为光栅图像时,透明度也不支持嵌套。
4.5 涂料属性模块

集合名称

集合属性

color 定义颜色。<color> 类型符合 sRGB 空间中定义的颜色的 CSS2 规格。该属性支持 [CSS2-color-types] 中定义的几种语法(有关详细信息,请访问 w3c.org Internet 站点),还支持一个关键字列表,列表中的每个关键字与一种颜色关联。

支持的数字颜色规格语法有:#rgb 或 #rrggbb 或 rgb(R, G, B) 或 rgb(R%, G%, B%)。

下面是使用不同的语法指定相同颜色的示例:

EM { color:#f00 } /* #rgb */

EM { color:#ff0000 } /* #rrggbb */

EM { color:rgb(255,0,0) } /* integer range 0 - 255 */

EM { color:rgb(100%, 0%, 0%) } /* float range 0.0% - 100.0% */

fill定义填充类型。
支持“none”、“current-color”值或颜色。
不支持梯度。
fill-rule定义填充多边形时使用的算法。
仅支持“nonzero”算法。
不支持“evenodd”算法。
stroke定义如何绘制元素。
支持“none”、“current-color”值或颜色。
不支持阵列和梯度。
stroke-dasharray定义为得到点线所应用的阵列。
stroke-linecap定义绘制轮廓时在轮廓的末尾使用的造型:round, square 等。
以向量格式保存时包括此属性。但是,不支持显示和以光栅格式保存它。
stroke-linejoin定义绘制折线的角时使用的造型:round, miter 等。
以向量格式保存时包括此属性。但是,不支持显示和以光栅格式保存它。
stroke-width定义笔画宽度。
以向量格式保存时包括此属性。但是,使用细宽度可以描绘非常粗的笔画。
4.6 样式属性集

集合名称

集合属性

style将所有属性编组在一起。
4.7 文本属性集

集合名称

集合属性

letter-spacing定义每个字符之间使用的间距。
TrueType 字体显示不支持该属性,因此也不支持大量的生成器(离散化)。
text-anchor定义文本对齐方式。
font-family定义字体系列的名称。
仅正确解释第 5 版支持的字体,否则使用默认字体。更多信息...
font-size定义文本高度。
高度必须定义为长度或百分比。
font-weight定义是使用粗体还是普通样式呈现文本。
TrueType 字体显示不支持该属性,因此也不支持大量的生成器(离散化)。
4.8 XLink 属性模块

集合名称

集合属性

xlink:href定义链接。为链接元素或定义光栅图像解释该属性。
xlink:show定义如何显示链接指向的资源。
4.9 变换属性

  分析和处理变换属性。应用下面的变换:

  • matrix(<a> <b> <c> <d> <e> <f>),以六个值的变换矩阵形式指定变换
  • translate(<tx> [<ty>]),通过 txty 指定平移
  • scale(<sx> [<sy>]),通过 sxsy 指定缩放操作
  • rotate(<rotate-angle> [<cx> <cy>]),指定绕给定点旋转 <rotate-angle> 度
  • skewX(<skew-angle>),指定沿 x 轴的扭曲变换
  • skewY(<skew-angle>),指定沿 y 轴的扭曲变换。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值