【发布时间】:2017-01-30 12:35:23
【问题描述】:
我想使用可在调色板中使用的 SVG 图形绘制 RGB 颜色模型。
渐变的图片可以查看here
- 我曾尝试使用 SVG 绘制渐变,但结果不如预期。
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width=256 height=256 >
<defs>
<linearGradient id='magenta' x1=0% y1=0% x2=100% y2=100%>
<stop offset= 0% stop-color=#FF00FF stop-opacity=1></stop>
<stop offset= 100% stop-color=#FFFFFF stop-opacity=0></stop>
</linearGradient>
<linearGradient id='blue' x1=100% y1=0% x2=0% y2=100%>
<stop offset= 0% stop-color=#0000FF stop-opacity=1></stop>
<stop offset= 100% stop-color=#FFFFFF stop-opacity=0></stop>
</linearGradient>
<linearGradient id='red' x1=0% y1=100% x2=100% y2=0%>
<stop offset= 0% stop-color=#FF0000 stop-opacity=1></stop>
<stop offset= 100% stop-color=#FFFFFF stop-opacity=0></stop>
</linearGradient>
<linearGradient id='black' x1=100% y1=100% x2=0% y2=0%>
<stop offset= 0% stop-color=#000000 stop-opacity=1></stop>
<stop offset= 100% stop-color=#FFFFFF stop-opacity=0></stop>
</linearGradient>
</defs>
<rect x=0 y=0 width=100% height=100% fill="url(#magenta)"></rect>
<rect x=0 y=0 width=100% height=100% fill="url(#blue)"></rect>
<rect x=0 y=0 width=100% height=100% fill="url(#red)"></rect>
<rect x=0 y=0 width=100% height=100% fill="url(#black)"></rect>
</svg>
This post 描述了如何使用 CSS 来完成。我想知道如何使用 SVG 图形绘制这个渐变。
【问题讨论】:
标签: javascript html css svg colors