SVG Line with Gradient Stroke Won't Display Straight

前端 未结 3 1373
迷失自我
迷失自我 2020-11-27 20:45

I\'m attempting to replicate an


with SVG. Now, making a straight line with SVG works perfectly, but the second I stroke it with a gradient it will no
3条回答
  •  生来不讨喜
    2020-11-27 21:37

    Robert Longson gives an excellent explanation. But sometimes userSpaceOnUse is a pain, because it spreads the interpolation over the entire canvas, instead of just the line.

    Instead, you could add a tiny amount to the values, to ensure the bbox size is not zero.

    For example,

      
    

    will draw a straight line with gradient.

提交回复
热议问题