我想弄清楚從gradienttransform 到gradientunits 的轉換。我得到了不同的梯度分布。為什么?
<svg width="540" height="540" xmlns="http://www.w3.org/2000/svg" >
<defs>
<linearGradient id="linear1" gradientTransform="rotate(45 0.5 0.5)" spreadMethod="pad">
<stop offset="0%" stop-color="gold"/>
<stop offset="100%" stop-color="blue"/>
</linearGradient>
<linearGradient id="linear2" x1="0%" y1="0%" x2="100%" y2="100%" spreadMethod="pad">
<stop offset="0%" stop-color="gold"/>
<stop offset="100%" stop-color="blue"/>
</linearGradient>
</defs>
<rect fill="url(#linear1)" x="0" y="0" width="270" height="270" />
<rect fill="url(#linear2)" x="0" y="270" width="270" height="270" />
</svg>
這兩個漸變不一樣:


uj5u.com熱心網友回復:
因為當你將矩形旋轉 45 度時,它左右邊之間的距離不等于一個角到對角的距離。
左側和右側相距 270 個單位(默認 x2 為 100%,其他默認為 0%)。
角相距 270 * √2 個單位
因此,鑒于旋轉變換是距離不變的,x1,y1 和 x2,y2 之間的距離在每種情況下都是不同的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/384996.html
上一篇:在C#中正確使用WPF繪制圖形圖
下一篇:SVG中的可訪問圖表
