Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSVG_PAINT_RADIAL_GRADIENT #3

Closed
brummer10 opened this issue Nov 4, 2021 · 2 comments
Closed

NSVG_PAINT_RADIAL_GRADIENT #3

brummer10 opened this issue Nov 4, 2021 · 2 comments

Comments

@brummer10
Copy link

Hi there
First, it's a really nice implementation for using nanosvg within cairo. Thanks for that.
I like to use it to add support for SVG in my X11 widget toolkit https://github.com/brummer10/libxputty
Therefore I ported it to plain C. However, I noticed a issue within your C++ version as well, with radial gradients and I don't know how to solve it. As a example, I use this one: https://freesvg.org/monarch-butterfly-2-variation-2
Unfortunately the radial gradients seems to didn't work, as all colours been presented as plain colour.
It works well for linear gradients by the way. Do you've any idea how to solve that?

regards
hermann

@brummer10
Copy link
Author

So, I found the issue.
First we need to implement the pull request memononen/nanosvg#164 for nanosvg, then we need to change line 126 in caironanosvg.cpp to

pat = cairo_pattern_create_radial(g.fx * -r, g.fy * -r, 0.,
              t[4], t[5], r);

that makes all radial gradients shine!

@user1095108
Copy link
Owner

I long suspected there might be issues with radial gradients. Now that you have spotted the error, I'll put your fix into CairoWidget and qtnanosvg, thank you. Previously, I only made a "best-effort" as regards radial gradients, as seemingly, there are problems within nanosvg itself and I use it only for generating icons, which means the .svgs I render are rather simple and usually contain no radial gradients. Even with radial gradients supported, nanosvg is rather incomplete, there is no filter support, for example. I am hoping for some other .svg library to emerge, but until then nanosvg will have to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants