diffvg icon indicating copy to clipboard operation
diffvg copied to clipboard

There is a problem in the rendering process for gradient colors.

Open hh0525 opened this issue 2 years ago • 5 comments

I initialized 2048 paths, with half of them filled with solid colors, and the other half filled with gradient colors (including linear and radial gradient). I optimized the SVG using L2 loss. When I open the final SVG with a browser like Edge, it appears to be full of color patches as below. iter_499 However, the final PNG rendering result is great. iter_499 I use render_svg.py in diffvg/apps folder to convert SVG to PNG and I get the same result: SVG is poor but PNG is great. What is the problem? I hope someone can help me.

hh0525 avatar Sep 15 '23 03:09 hh0525

Hi, I have the same problem. Did you solve it now?

c1enyang avatar Nov 28 '23 13:11 c1enyang

image I found that the problem came from the color sampling process of forward rendering. The parameter pt passed in this function is the coordinate of the point in the image space (canvas_width*canvas_height), but in fact it should be the relative position of the point in the path, similar to begin and end in linearGradient.

hh0525 avatar Dec 14 '23 10:12 hh0525

image I found that the problem came from the color sampling process of forward rendering. The parameter pt passed in this function is the coordinate of the point in the image space (canvas_width*canvas_height), but in fact it should be the relative position of the point in the path, similar to begin and end in linearGradient.

Great! Can you tell me how to solve the color sampling problem? I am not familiar with this.

c1enyang avatar Dec 24 '23 05:12 c1enyang