Loading colour SVGs

A forum to share your demonstrations stacks, fun stacks, games, etc.
Post Reply
User avatar
tperry2x
Posts: 3208
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Loading colour SVGs

Post by tperry2x »

I apologise if I'm drastically late to the party, but I didn't realise I could load colour SVGs in with:

Code: Select all

set the text of image "test" to drawingSvgCompile(url ("file:test.svg"))
It's not perfect, but at least loads things in colour:
demo.png
demo.png (26.6 KiB) Viewed 2281 times
drawingSVGTest.7z
(27.86 KiB) Downloaded 85 times
User avatar
richmond62
Posts: 4830
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Loading colour SVGs

Post by richmond62 »

I wonder how that compares with importing the same SVG image via the menu?
https://richmondmathewson.owlstown.net/
User avatar
richmond62
Posts: 4830
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Loading colour SVGs

Post by richmond62 »

What is also obvious (in case I didn't know about that about 6 years ago) is that not all SVG images are 'equal', as your one gets 'b*ggered' when imported into a stack, while mine does not:
-
Screenshot 2024-12-08 at 18.34.05.png
Screenshot 2024-12-08 at 18.34.05.png (236.95 KiB) Viewed 2236 times
-
On my stack (which is your stack using my SVG) the SVG on the left has been imported using your method, and the one in the middle by using the 'import' menu item, the one on the right is a PNG version of the SVG.

I have put "those purple things" there to see how transparency is dealt with.

With your SVG, OXT inverts white.

------------
https://forums.livecode.com/viewtopic.p ... 1&start=15
Attachments
DrawingSVGTest_R.oxtstack.zip
(26.1 KiB) Downloaded 83 times
test.svg.zip
(2.08 KiB) Downloaded 82 times
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3208
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Loading colour SVGs

Post by tperry2x »

richmond62 wrote: Sun Dec 08, 2024 4:26 pm With your SVG, OXT inverts white.
Yes, it does - but to be clear, this isn't an SVG I created - one that comes from another app which is in the main package repositories. I purposefully chose this one (as others will render fine), but I wanted to show everyone that although this method exists, it's not perfect. - obviously can't understand all the nuances of SVG files.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Loading colour SVGs

Post by OpenXTalkPaul »

tperry2x wrote: Sat Dec 07, 2024 9:17 pm I apologise if I'm drastically late to the party, but I didn't realise I could load colour SVGs in with:

Code: Select all

set the text of image "test" to drawingSvgCompile(url ("file:test.svg"))
It's not perfect, but at least loads things in colour:
demo.png
drawingSVGTest.7z
Yeah you are late, this has been discussed on these forums several times previously, this particular method was built into the image object (which I think was a mistake to not make it separate from 'image' in a new 'SVG control' object).
This aspect of SVG support has some limitations. For one thing It doesn't support text+font use in source SVG. It will still try to render the SVG but the text will be missing. That means you have to convert text to outline in the source art before importing it with drawingSvgCompile. Another limitation is that there's no drawingSvgDecomple, so no easy way to extract the graphics back into SVG XML that could be exported as an .svg file. Also you may have rendering/redraw issues with this binary 'compiled' SVG data in an image control. it be rendered looking like a corrupt raster-image (for commercial printing people, it looks like a TIFF file corruption from the old magneto-optical drives :lol: ) . IIRC using the syntax 'prepare image tMyImage' ahead of time avoids this rendering issue.

There is also a community developed Extension Widget that supports setting an SVG XML property that gets interpreted and rendered using the builder canvas library. That supports color, and using the original more user-readable freindly SVG XML, and it's community developed so it could be extended to support more SVG specifications without having to rebuild the engines ever time it's updated. Also for retro-users it works fine on LC Community vers. 8 of the engine.

There was a stack built years before that which should work on really old versions of the engine, that would import/convert SVG (and iirc AI or EPS files too) by rebuilding vector drawings data as a whole lot of graphic shapes layered on top of each other in a group/. A brilliant concept and execution really but a bit slow and hard to deal with.

Single basic SVG path-drawing strings can be used with the SVG Icon Widget. That doesn't help much for using color SVG files that contain gradients blends and such.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Loading colour SVGs

Post by OpenXTalkPaul »

richmond62 wrote: Sun Dec 08, 2024 9:50 am I wonder how that compares with importing the same SVG image via the menu?
If you look at the revMenuBar source scripts you can see it is exactly the same method, which is that it uses the Drawing Library (which additionally relies on engine code changes that were made in the 'image controls' objects in order to add the color SVG support).
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests