-
Notifications
You must be signed in to change notification settings - Fork 11
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
Meaning of viewBox should be clearer #15
Comments
You're right that this needs to be explicitly said in the spec. To your specific questions:
That's the intention. I thought that clipping to axis-aligned rectangles is pretty cheap, especially as rasterizers have to do that anyway to avoid overflowing the destination pixel buffer. Let me know if I'm mistaken.
It's must, not may, and different implementations should agree, because (as above) it's a clip. Or am I misunderstanding your question?
Individual path nodes can certainly be outside the viewBox. Entire paths can also be outside of the viewBox, but they should then be entirely clipped out (no-ops).
Aspect ratio is only a hint. Implementations are allowed to draw a "naturally 3:2" IconVG into a 1:1 space. |
There's not always a way to know if the output buffer is axis-aligned, though. Assuming the user wants anti-aliased clipping in the rotated case, this means the IconVG renderer has to pro-actively use a saveLayer-based clip (in Skia terms), which is the expensive kind. |
I may very well be misunderstanding the Skia API, but https://fiddle.skia.org/c/@Canvas_clipRect does a non-axis-aligned rectangular clip while only calling |
Yeah, if you don't have to deal with colour bleed you can do it with only the medium-expensive clips and can skip the saveLayer call. My point is more that if you could avoid clipping entirely you'd be saving a bunch of cycles potentially. Obviously that's a trade-off (and IconVG is not intended to optimize for raw rendering speed above other considerations like file size or convenience). |
I still think I'd like the IconVG viewBox to implicitly clip. (Does SVG do this? I'd have to check...) I certainly want to avoid "different implementations would have different renderings". If clips turn out to be noticably expensive, I suppose that IconVG implementations could make two passes over the vectors (the path nodes). The first pass just calculates a convex hull, which is a very cheap computation. The second pass does the actual rendering but between the two, we could skip the |
Clipping is definitely a reasonable choice. |
(FWIW in the Dart implementation I just made it configurable and defaulted to a hard (fast but no AA) clip.) |
IconVG doesn't blindly follow SVG in all its complexity, but for what it's worth, the SVG 1.1 spec section 14.3.3 The ‘overflow’ and ‘clip’ properties gives 7 bullet points for how
It then goes on to note that, in SVG, |
Out of curiosity, does "the Dart implementation" mean a Dart SVG implementation, or does it mean some sort of Dart/Flutter canvas widget, with programmable 2-D vector graphics but not a full SVG implementation? |
Oh, I just saw #25 |
I definitely wouldn't follow SVG here, clipping and overflow in the CSS/SVG world is order of magnitude more complex than all of IconVG put together... |
It's not clear what exactly the viewBox means.
The text was updated successfully, but these errors were encountered: