-
Notifications
You must be signed in to change notification settings - Fork 3
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
SVGDocument new features #1
Comments
I agree with you 110%!! I ran into the same challenges, and in subsequent work added all that stuff you mentioned. My main challenge will be in how to best introduce all that new stuff. The structures have changed fundamentally, so probably the best thing is to push the current thing off to its own branch/release, and just copy the new stuff over to main here. |
I'm assuming the highest level simple C interface is still good? Also, I added the ability to easily scale things at the document level. |
Scaling the whole SVGDocument is a good solution ( I will add also rotations ... affine transformations). About the 'top' C interface, I think that We need to control where to put the extracted paths, scale them, and maybe redraw them more times I think that the right top API should be a C-transposition of the SVGDocument class
More in detail:
Let me know if you think they are a right and coherent choice. |
This is what I currently do when I drop a file onto my application:
|
So, in this case, I hide the mmap in the createFromFilename() function, as you suggest. You can also see how I get the viewport, which might be different from the "sceneFrame". I then have this SVGCameraView, which handles all the transformation stuff. I can take a general transform, but it has specializations for rotation, pan, and zoom. in my case, I map mouse scroll wheel to zoom, horizontal scroll (logitech mouse) for rotation, and click/drag to movement. I put all this into that camera object because it's was getting messing with the bits and pieces all over, and really at the end of the day, you're just trying to create a matrix to apply to the context. From there, you should be able to draw into an BLContext, without a care in the world. If it's messed up, then that's the caller's fault. I think I've got all the goodness in hand. Just need to figure out the best way to put it out into the world. |
Hi William, sorry, but I'm not sure I understood the last code snippet. What is the parameter I thought createFromFile() should only require a filename, just as createFromData() required just a stream of bytes.. Regarding SVGDocument, from the point of view of integration with Blend2d, I would simplify or hide all those details on the internal XML structure (such as ..getElement() .. ), and expose only the relevant information to 'frame' the drawing in a canvas (BLContext). Can you just sketch the top interface (*.h)? Where is the connection with Blend2d and in particulare with BLContext? |
Let me stop right here. I was sharing an internal interface of my current project, which isn't the final interface I would use here. The appFontHandler is an artifact of how my current project is setup. The previous version did not have any font handling support at all, so, this object showed up. At the very least you need to specify a directory where fonts you want to use live, or something like that. Perhaps it's hidden with an #ifdef. In my context, the following happens 'per frame' void onFrame(const FrameCountEvent& fce)
} Basically CameraView->draw() is where the action occurs.
But that's layers upon layers. I'll have to simplify that down to a BLContext thing, instead of IRenderSVG, although that's removing a lot of simplification. Please don't take these examples as final. I need to think about what the interfaces will really look like, as I have a lot to port over. |
Many thanks William, take your time. |
Thanks for svg2b2d, it's well integrated with Blend2d, but I'm thinking about two small things
, currently missing, that could be useful for better positioning or framing a picture on a canvas.
Class SVGDocument should provide some methods returning the viewbox() and the boundingbox().
The width(), height(), viewbox() and bbox() methods should always return a meaningful
(computed) result, even if these attributes are not set.
(* I know boundingbox is not an SVG attribute, but it is useful for sizing the canvas *)
Test case 1: tiger.svg
https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg
has the following header ( ... missing width, height)
<svg id="svg2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 900" version="1.1">
and methods width(), height() returns 100.0 100.0
Therefore, when rendered (doc.draw(..)), nothing is drawn.
This attched file <mobj.svg>,
has the following header
here width(), height() return 523.288029 , 147.097199
I suppose they are scaled, but the bad thing is that in this 'viewBox' the true picture (moby)
is much more smaller. there's a lot of white/unused space around the picture
Therefore the measurement of the bounding box would be needed to size the canvas better.
The text was updated successfully, but these errors were encountered: