servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.6k stars 201 forks source link

Gradients without stop points at 1.0 do not render correctly #397

Closed Herschel closed 4 years ago

Herschel commented 4 years ago

Similar to #393, a gradient that has a final stop point <1.0 will not render correctly.

Linear gradient SVG:

<svg width="400" height="400" xmlns="http://www.w3.org/2000/svg"> 
     <linearGradient id="gradient"
                    spreadMethod="pad"
                    x1="0" y1="0" x2="400" y2="0"
                    gradientUnits="userSpaceOnUse">
      <stop offset="25%"  stop-color="#ff0000"/>
      <stop offset="75%" stop-color="#000000"/>
    </linearGradient>

  <rect fill="url(#gradient)"
        x="0" y="0" width="400" height="400"/>
</svg>

Expected:

Screen Shot 2020-07-15 at 7 02 11 PM

Pathfinder:

Screen Shot 2020-07-15 at 7 00 36 PM

Radial gradient SVG:

<svg width="400" height="400" xmlns="http://www.w3.org/2000/svg">

    <radialGradient id="gradient"
                    spreadMethod="pad"
                    cx="200" cy="200" r="100"
                    gradientUnits="userSpaceOnUse">
      <stop offset="25%"  stop-color="#ff0000"/>
      <stop offset="75%" stop-color="#000000"/>
    </radialGradient>

  <rect fill="url(#gradient)"
        x="0" y="0" width="400" height="400"/>
</svg>

Expected:

Screen Shot 2020-07-15 at 7 03 35 PM

Pathfinder:

Screen Shot 2020-07-15 at 7 04 00 PM

Revision f62f853 MacBook AIR 2017 Intel HD 615

Herschel commented 4 years ago

Thank you! 🎉