Round-off error with SVG linear gradient in Chrome?

泄露秘密 提交于 2019-12-12 12:08:13

问题


I'm seeing some issues recently with Chrome to render SVG linear gradient. Have a look at this SVG below:

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<body>
<svg>
  <g>
    <linearGradient id="linearGradient" gradientUnits="userSpaceOnUse" x1="79px" x2="706px" y1="0" y2="0">
      <stop class="" offset="54.54545454545455%" style="stop-color: red;"></stop>
      <stop class="" offset="63.63636363636364%" style="stop-color: red;"></stop>
      <stop class="" offset="63.63636363636364%" style="stop-color: green;"></stop>
      <stop class="" offset="72.72727272727273%" style="stop-color: green;"></stop>
    </linearGradient>
    <path d="M79,241L136,196L193,194L250,212L307,159L364,152L421,339L478,46L535,205L592,134L649,215L706,74"
    style="opacity: 1; fill: none; stroke: url(#linearGradient); stroke-width: 2px;">
    </path>
  </g>
</svg>
</body>
</html>

After loading this html in Chrome(my version is 23.0.1271.64), it is very easy to see a clear 2px error of the linear gradient in the peek, which shows some green color in the left side line segment. In both IE 9 and latest Firefox, the svg is rendered correctly. I think it maybe a bug of Chrome or WebKit. Does anyone know how to workaround? Thanks!

来源:https://stackoverflow.com/questions/13465084/round-off-error-with-svg-linear-gradient-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!