-
Notifications
You must be signed in to change notification settings - Fork 362
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
Support for percentage coordinates #21
Comments
@xandev can you check if the recent changes fixed your problem and close the issue accordinly? |
Now it's looks like this http://i.imgur.com/8l8qsHw.png |
How should I interpret that image? :) The original on left, and nanosvg rendered at right? That is, it does not work yet? |
Exactly. As you can see rectangle has been cut and gradient still isn't working. |
Dunno what is causing cut, but it was fine before update. |
It's probably this one: I have to refresh that logic and see what is causing the problem. |
Yes, probably the calculation of the view box is wrong. However, reverting 46e8b78#diff-a5adee86dee0bb074ce7e3cfa42ec19bR2525 probably won't be enough. And now to the percentage coordinates: Yes, something still seems to be missing. |
I looked into the view box logic and I think I found the source of the bug. "p->viewMinx" and "p->viewMiny" are set to 0 when no view box was set in the SVG document. In this case they should be set to "-bounds[0]" and "-bounds[1]". EDIT: I just realized that these odd edges might occur because the view box doesn't take into account the outline width and the rendered image is cropped? EDIT 2: Added some code in "nsvg__imageBounds" to include the stroke width when computing the image bounds, and now it works. I'll send a pull request for all the changes soon. |
I'd really like to hear your feedback on these changes before I open a pull request: chrismile@abc2d41 |
I have to dive into the bounds issue properly. I remember that there was some things I could not implement properly because not all the information was not available at the time parseFloat was called. |
I'm looking into this right now, will take a little while, though. I'll take bits and pieces from your CL. I tested quikly how the image bounds are calculated on different viewers. Chrome considers outline on right/bottom of the image, but not on left/tip edges. OSX preview does not consider the outline at all. I think your proposal is better, though. Unless there's a spec saying otherwise. If you define the viewport, then those bounds will be used. |
The bounding box computation seems to be inconsistent across different browsers.
I agree with you, I guess a view box including the object stroke is more useful as a standard behaviour. The standard behavior one would probably expect from a bounding box encompassing the whole renderable area is a boundig box including the stroke. I mean, a user who wants to rasterize all visible objects will probably expect not to have clipped object strokes. It would also look very odd if e.g. Inkscape decided to not include strokes in the bounding box. But of course a bounding box without the stroke is somethings that makes sense, too. I think that for example percentage coordinates for gradients always refer to this box without the stroke included. |
NanoSVG does not properly support percentage coordinates.
At least percentage coordinates should be supported in gradient definitions.
SVG Example
The text was updated successfully, but these errors were encountered: