gradientUnits - SVG: Scalable Vector Graphics 编辑

The gradientUnits attribute defines the coordinate system used for attributes specified on the gradient elements.

Two elements are using this attribute: <linearGradient> and <radialGradient>

linearGradient

For <linearGradient>, gradientUnits defines the coordinate system used for the attributes x1, y1, x2, and y2.

ValueuserSpaceOnUse | objectBoundingBox
Default valueobjectBoundingBox
AnimatableYes
userSpaceOnUse
This value indicates that the attributes represent values in the coordinate system that results from taking the current user coordinate system in place at the time when the gradient element is referenced (i.e., the user coordinate system for the element referencing the gradient element via a fill or stroke property) and then applying the transform specified by attribute gradientTransform.
Percentages represent values relative to the current SVG viewport.
objectBoundingBox
This value indicates that the user coordinate system for the attributes is established using the bounding box of the element to which the gradient is applied and then applying the transform specified by attribute gradientTransform.
Percentages represent values relative to the bounding box for the object.
With this value and gradientTransform being the identity matrix, the normal of the linear gradient is perpendicular to the gradient vector in object bounding box space (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box). When the object's bounding box is not square, the gradient normal which is initially perpendicular to the gradient vector within object bounding box space may render non-perpendicular relative to the gradient vector in user space. If the gradient vector is parallel to one of the axes of the bounding box, the gradient normal will remain perpendicular. This transformation is due to application of the non-uniform scaling transformation from bounding box space to user space.

radialGradient

For <radialGradient>, gradientUnits defines the coordinate system used for the attributes cx, cy, r, fx, fy, and fr.

ValueuserSpaceOnUse | objectBoundingBox
Default valueobjectBoundingBox
AnimatableYes
userSpaceOnUse
cx, cy, r, fx, fy, and fr represent values in the coordinate system that results from taking the current user coordinate system in place at the time when the gradient element is referenced (i.e., the user coordinate system for the element referencing the gradient element via a fill or stroke property) and then applying the transform specified by attribute gradientTransform.
objectBoundingBox
for <radialGradient>: the user coordinate system for attributes cx, cy, r, fx, fy, and fr is established using the bounding box of the element to which the gradient is applied (see Object bounding box units) and then applying the transform specified by attribute gradientTransform.
With this value and gradientTransform being the identity matrix, the rings of the radial gradient are circular with respect to the object bounding box space (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box). When the object's bounding box is not square, the rings that are conceptually circular within object bounding box space will render as elliptical due to application of the non-uniform scaling transformation from bounding box space to user space.

Specifications

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2
The definition of 'gradientUnits for <radialGradient>' in that specification.
Candidate RecommendationNo change
Scalable Vector Graphics (SVG) 2
The definition of 'gradientUnits for <linearGradient>' in that specification.
Candidate RecommendationNo change
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'gradientUnits for <radialGradient>' in that specification.
RecommendationInitial definition for <radialGradient>
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'gradientUnits for <linearGradient>' in that specification.
RecommendationInitial definition for <linearGradient>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:110 次

字数:8534

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文