首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SVG梯度单元与梯度变换--不相同的梯度

SVG梯度单元与梯度变换--不相同的梯度
EN

Stack Overflow用户
提问于 2021-12-16 13:52:12
回答 1查看 99关注 0票数 2

我试图找出从梯度转换到梯度单位的转换。我得到了不同的梯度分布。为什么?

代码语言:javascript
复制
<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>

这两个梯度并不相同:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-16 14:01:37

因为矩形的左侧和右侧之间的距离并不等于旋转45度时从一个角到另一个角的距离。

  1. 左侧和右侧相隔270个单元(默认x2为100%,其他默认为0%)。

  1. 的拐角270号*√2单位与

相隔

因此,在旋转变换是距离不变的情况下,x1、y1和x2、y2之间的距离是不同的。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70380172

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档