color-rendering - SVG: Scalable Vector Graphics 编辑

Obsolete

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

The color-rendering attribute provides a hint to the SVG user agent about how to optimize its color interpolation and compositing operations.

color-rendering takes precedence over color-interpolation-filters. For example, assume color-rendering: optimizeSpeed and color-interpolation-filters: linearRGB. In this case, the SVG user agent should perform color operations in a way that optimizes performance, which might mean sacrificing the color interpolation precision as specified by through the linearRGB value for color-interpolation-filters.

Note: As a presentation attribute, color-rendering can be used as a CSS property.

As a presentation attribute, it can be applied to any element but it only has an effect on the following 29 elements: <a>, <animate>, <animateColor>, <circle>, <clipPath>, <defs>, <ellipse>, <foreignObject>, <g>, <glyph>, <image>, <line>, <linearGradient>, <marker>, <mask>, <missing-glyph>, <path>, <pattern>, <polygon>, <polyline>, <radialGradient>, <rect>, <svg>, <switch>, <symbol>, <text>, <textPath>, <tspan>, and <use>

html, body, svg {
  height: 100%;
}
<svg viewBox="0 0 480 200" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <radialGradient id="gradient" cx="0.5" cy="0.5" r="0.5" fx="0.35" fy="0.35" fr="5%">
      <stop offset="0%" stop-color="white"/>
      <stop offset="100%" stop-color="darkseagreen"/>
    </radialGradient>
  </defs>

  <circle cx="100" cy="100" r="100" fill="url(#gradient)" color-rendering="optimizeQuality" />
  <text x="45" y="50%" color-rendering="optimizeQuality">quality-optimized</text>

  <circle cx="100" cy="100" r="100" color-rendering="optimizeSpeed" fill="url(#gradient)"
      style="transform: translateX(240px);" />
  <text x="290" y="50%" color-rendering="optimizeSpeed">speed-optimized</text>
</svg>

Usage notes

Valueauto | optimizeSpeed | optimizeQuality
Default valueauto
AnimatableYes
auto
Indicates that the user agent shall make appropriate tradeoffs to balance speed and quality, but quality shall be given more importance than speed.
optimizeSpeed
Indicates that the user agent shall emphasize rendering speed over quality. For RGB display devices, this option will sometimes cause the user agent to perform color interpolation and compositing in the device RGB color space.
optimizeQuality
Indicates that the user agent shall emphasize quality over rendering speed.

Browser compatibility

BCD tables only load in the browser

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

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

发布评论

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

词条统计

浏览:123 次

字数:6412

最后编辑:7 年前

编辑次数:0 次

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