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
Add SVG support (lunasvg) #2026
Conversation
Also changed some minor things with the CreateDocument test code
I'm not sure how to return my custom element CClientVectorGraphic (it's the same as CClientWebBrowser)
Nice!! I think there is no need for new function |
Integrating into the DX related code would not be good for the overall structure of the API.
Not to mention, we're going to have a LOT of functions with the svg* prefix, to manipulate the SVG document and load data. Somehow, Have a look into the code, to get a better understand of the implementation. |
As briefly discussed on Discord, I think the initial plan should be to roll this out with a few basic functions: texture/svg svgCreate(width, height [, string pathOrRawData ])
xmlnode svgGetDocumentXML(svg svgElement)
bool svgSetDocumentXML(xmlnode xmlData) You can create a blank SVG document, supply a file path or read from raw (including xmlnode) data. You can also get the SVG document back as an xmlnode, use the existing xml implementation to edit the xml data, and set it back on the document. The reason for introducing this simple behaviour at first, is because a proper API will take a lot of time and thought, and will probably be quite an addition to the code. Introducing the basics in this PR, and then the API stuff later, is easier on the reviewer(s). We can always deprecate Thoughts? |
…ClientVectorGraphic::LoadFromData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! I have now reviewed the code and overall looks good!
I saw a lot of code style formatting issues, are you running clang-format on your editor? We also have a clang-formatter batch script in the utils folder, which helps with fixing formatting issues to be consistent with the rest of the codebase.
Either way to speed up the process I decided to run clang-format on this PR and push the changes here.
Only one thing bugs me which is that the callback and non-callback code is duplicated, which is not best practice. I would like to see these refactored into a single private function call for example, or something else that doesn't result in duplicating code, thus duplicating work and duplicating amount of potential issues.
The size functions work great, thank you for adding them!
I think once you've refactored the duplicate code, this is ready for a final review and then merge.
Thanks for the review - I've split that code into static, private methods as suggested. In some cases it doesn't cut down the amount of code needed but at least it's more consistent for any future changes. |
I've had to format the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, everything looks good now! 😄
This reverts commit 898fcaf.
This reverts commit 898fcaf.
This reverts commit 7d055fb.
This reverts commit 898fcaf.
…""" This reverts commit 7d055fb.
…ltitheftauto#2380) * Revert "Revert "Add SVG support (lunasvg) (multitheftauto#2026)"" This reverts commit 898fcaf. * Change SharedLib to StaticLib in premake5.lua Co-authored-by: LopSided <40902730+Lpsd@users.noreply.github.com>
I've implemented lunasvg, which gives us the ability to create SVG documents, edit them on the fly, and also load SVG files (from path or raw).
API (for initial release)
callback
is for when SVG has been updated, invoked when texture is available (if update successful).Example usage
Preview of the first example
Preview of the second example
The
svg
element is also derived from CClientTexture, meaning it works with pretty much all dx* functions, includingdxGetTexturePixels
,dxSetTexturePixels
,dxSetPixelColor
, etc - direct manipulation is therefore possible, e.g:(Resolves #1300)