-
Notifications
You must be signed in to change notification settings - Fork 93
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
Rasterizer doesn't render transparencies inside shapes #28
Comments
Thanks for opening this issue, I'm looking into it. |
The problem seems to stem from the fact that the rasterizer treats every subpath as being completely unrelated to the previous ones, without taking into account that SVG imposes certain fill rules for cases where subpaths overlap. I have no idea yet how to fix this, but it definitely needs attention. Thanks again for reporting the problem! |
Really unfortunate since this is quite an important requirement. It would have been so nice to be able to do this without phantom.js :/ I've tried to come up with a way to calculate the inner space and redraw a transparent layer over it, but that's rather difficult and won't even solve all cases. It's far easier to make the final transformation step with a nodejs tool like svg2png. |
I came across this issue and though I'd post my solution to rendering the PNG, using Imagick:
Hope that helps someone. Cheers |
Fixes #28. The time has finally come that I understand how scanline algorithms work and was able to implement this by referencing an existing implementation in the SerenityOS path renderer. I did a lot of work to adapt that code to PHP and get it to perform as well as possible. Note that for some images rendering still takes ages, but that is not due to PathRenderer, rather the BezierApproximator does not yet take scale into account and oftentimes generates curves with waaaaay too many segments. I have done benchmarks and this rendering algorithm is insanely efficient for what it does. If anything can be optimized, it is probably the looping over and transforming of each point during preparation.
This will probably come as a surprise to everyone involved (myself included), but I finally implemented this. See PR #136. I'd thank you for your patience, but I doubt this is still useful to any of the original participants of this discussion. Still it will hopefully benefit people that ran into this more recently! |
* feat: Implement path rendering that respects fill-rule! :) Fixes #28. The time has finally come that I understand how scanline algorithms work and was able to implement this by referencing an existing implementation in the SerenityOS path renderer. I did a lot of work to adapt that code to PHP and get it to perform as well as possible. Note that for some images rendering still takes ages, but that is not due to PathRenderer, rather the BezierApproximator does not yet take scale into account and oftentimes generates curves with waaaaay too many segments. I have done benchmarks and this rendering algorithm is insanely efficient for what it does. If anything can be optimized, it is probably the looping over and transforming of each point during preparation. * fix(tests): Fix SVGPathTest still checking for rendering via polygon * fix(phpcs): Use 'elseif' instead of 'else if' * fix: Remove vertex special treatment from PathRenderer This turned out to not be necessary and rather problematic in my tests.
Tried rasterizing this search icon SVG. Ended up with this:
Is this a limitation of the GD rendering library?
The text was updated successfully, but these errors were encountered: