【发布时间】:2014-01-27 18:35:04
【问题描述】:
我想用一个源组的所有颜色渐变填充一个矩形。我确信有一个过滤器可以解决这个问题,但我无法构建一个来完成工作。
<svg width="100" height="100">
<defs>
<filter id="f1">
<feBlend in="SourceGraphic" in2="url(#line)"/>
</filter>
</defs>
<g id="line">
<line x1="10" y1="10" x2="20" y2="20" stroke="red"/>
<line x1="20" y1="20" x2="30" y2="10" stroke="orange"/>
<line x1="30" y1="10" x2="40" y2="20" stroke="green"/>
<line x1="40" y1="20" x2="50" y2="10" stroke="blue"/>
</g>
<g id="rect" filter="url(#f1)">
<rect x="10" y="30" width="40" height="40" stroke="black" stroke-width="2"/>
</g>
</svg>
目标是用源线的颜色(红色、橙色、绿色和蓝色)从左到右填充我的矩形。当然,源颜色并不总是相同的 :-) 我已经尝试了几个版本的 feBlend、feFlood 和 feColorMatrix,但没有任何运气。
【问题讨论】:
标签: svg svg-filters