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
Value | auto | optimizeSpeed | optimizeQuality |
---|---|
Default value | auto |
Animatable | Yes |
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论