paint-order - SVG: Scalable Vector Graphics 编辑

The paint-order attribute specifies the order that the fill, stroke, and markers of a given shape or text element are painted.

Note: As a presentation attribute, paint-order can be used as a CSS property.

As a presentation attribute, it can be applied to any element but it has effect only on the following ten elements: <circle>, <ellipse>, <line>, <path>, <polygon>, <polyline>, <rect>, <text>, <textPath>, and <tspan>

Usage notes

Valuenormal | [ fill || stroke || markers ]
Default valuenormal
Animatablediscrete
normal
This value indicates that the fill will be painted first, then the stroke, and finally the markers.
[ fill || stroke || markers ]
The order of these three keywords indicates the order in which the painting happens, from left to right. If any of the three painting components is omitted, they will be painted in their default order after the specified components. For example, using stroke is equivalent to stroke fill markers.

Example

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
  <linearGradient id="g" x1="0" y1="0" x2="0" y2="1">
    <stop stop-color="#888"/>
    <stop stop-color="#ccc" offset="1"/>
  </linearGradient>
  <rect width="400" height="200" fill="url(#g)"/>
  <g fill="crimson" stroke="white" stroke-width="6" stroke-linejoin="round"
     text-anchor="middle" font-family="sans-serif" font-size="50px" font-weight="bold">
    <text x="200" y="75">stroke over</text>
    <text x="200" y="150" paint-order="stroke" id="stroke-under">stroke under</text>
  </g>
</svg>

The example would be rendered as follows:

An image showing how the paint-order example looks in a UA that supports the paint-order property.

The stroke under effect could be achieved via the following CSS property:

#stroke-under {
  paint-order: stroke;
}

Specifications

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2
The definition of 'paint-order' in that specification.
Candidate RecommendationInitial definition

Browser compatibility

BCD tables only load in the browser

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

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

发布评论

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

词条统计

浏览:57 次

字数:4521

最后编辑:7年前

编辑次数:0 次

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