Page 1 of 3

SVG in widgets - any roadmap?

Posted: Mon Aug 22, 2016 5:02 pm
by livfoss
About 10 days ago, I asked about this on the use list but got no bites. It seems to me a pretty important topic so I'm reposting it here.

The LC Conference didn’t reveal any plans for extending the SVG capabilities of widgets in the LC 8 series. Does anyone know if such plans exist, or if on the contrary we are stuck with monochrome etc? The answer will obviously have an effect on developers seeking to make multi-resolution apps. Personally I am hoping to make some fairly photo-realistic coloured SVGs that can be resized without fuss for different sized screens. I'm thinking of fairly small images, perhaps four times the area of a typical icon. Not having this capability dooms one to keep a library of different sized PNGs to fit different screen resolutions, or rely on any available automatic resizing capability, which can often give less than satisfactory results IMO.

Re: SVG in widgets - any roadmap?

Posted: Sun Aug 28, 2016 11:18 pm
by pthirkell
I also have the need for color widgets for a project on which I am working. Inspired by a couple of key sessions at the conference - and keen to contribute towards the 1000 widgets that Kevin would like to see over the next year - I have been working on a color SVG widget. So far it takes a tagged SVG file and parses out the relevant path (plus rect circle ellipse) and associated color information to render the widget. It is resizable - with or without maintaining perspective. I will probably need some help on rotating the image.

What specific functionality are you wanting from the widget? Is it essentially as a static image to display, or as a button (with some sort of hiliting effect, or something else? So far I have implemented standard mouse and drag events.

I don't want to over-promise. If you need near photo-realistic images then this probably won't do the trick. However I do have the set of color business icons from flat-icon working ok. The app I am using is Affinity Designer as this exports clean and well formed tagged SVG data. It is great to be able to take this data and dropped it essentially unchanged onto the widget. Here is a screensnap of the icons that I have working so far:
Any comments or suggestions welcome, particularly in terms of the typical uses expected for color icons along the lines illustrated.

Re: SVG in widgets - any roadmap?

Posted: Mon Aug 29, 2016 8:00 pm
by bn
Hi pthirkell,
that looks very nice. I do not have any suggestions how to improve. My attempts to modify the SVG widget were a lot more modest and I stopped trying to get more involved because of

but unfortunately this has not yet materialized.

Kind regards

Re: SVG in widgets - any roadmap?

Posted: Mon Sep 05, 2016 10:03 pm
by livfoss
In reply to pthirkell, I am encouraged by your experience with color and SVG. I got the idea from the conference sessions that only monochrome graphics were available - maybe I was just wrong!

Although I said that I wanted photorealistic images, I am willing to back off and use some kind of easily recognisable symbolic representations. I need to show a number of states - for example, a light that is off or on, where the colors change but the shape and size of the object stay static. I would hope to do this in a single widget which can be be switched into different states and can also be resized, at least at initialisation time when the app works out what screen real estate it has.

I have to say I am still rather confused about SVG, scaling and widgets. There is a tutorial about the Pie Chart widget, which as far as I can see doesn't use SVG, but is nevertheless resizable, and being constructed entirely of vector objects, doesn't have resolution problems when resized. Would this have been better implemented using SVGs, or have I completely misunderstood something (quite likely)? I also note that in the wider world, a lot of SVGs are in fact icons rather than larger, more complex objects. Is this the way the mother ship thinks of them, or can we have widgets as big as a screen? I wish I'd asked more questions at the conference, but it was all too new then...

Re: SVG in widgets - any roadmap?

Posted: Wed Oct 12, 2016 3:56 am
by pthirkell
I have persevered with my attempts to create multicoloured widgets, because I need them for another project. I realise that it may well have a short "half-life" because, as Bernd helpfully pointed out, it is intended that full SVG support will eventually find its way into the engine. I don't regret the effort however because it has helped me enormously to come to grips with Livecode Builder. Having multi-coloured widgets available also helps to stimulate the imagination in terms of what becomes possible from an interface design point of view.

In response to livfoss, I found that widgets which are essentially pictures (albeit in SVG format) size beautifully to full screen. I have included a few examples in the widget, one of which could be a full screen backdrop for say a slide or presentation. Also, based on your comments, I have included the ability to control the colors of any four paths at runtime. Two examples are provided in the API documentation, using the "controller" widget and the "tiger" widget.

The widget is attached as a zipped .lce file for anyone who might like to try it out. I have tested a little on Mac, but not at all on Windows or Linux. So any feedback on whether it works on other platforms, or about the widget more generally, is welcome.

Ten SVG files are built in as examples. If you use any or all of these in public apps then please comply with the necessary copyright requirements. The source file web links are included in the API documentation. Most of them are free provided properly acknowledged.

Known issues:
1. Rotation only works in a rudimentary fashion. I don't really need this but if it becomes an issue for anyone then let me know.
2. The widget is built to handle SVG exported from the "Affinity Designer" application on Mac (and soon to be Windows as well - currently available for free in beta). It might use SVG files generated by other applications but I haven't tested this at all.
3. Fill-rules, definitions and gradients haven't been implemented. Maybe they could be, but I have to move on to other things.
Postscript ... my zipped .lce file is 286k which exceeds the maximum file size for uploading. Alternative options for posting?

Re: SVG in widgets - any roadmap?

Posted: Wed Oct 12, 2016 10:22 am
by bn
Hi Peter,

that looks fantastic. I am very eager to see how you did it.

Could you just upload the .lcb file? Then one could compile the widget from the source and install it. Any additional material could be posted separately.

Kind regards

Re: SVG in widgets - any roadmap?

Posted: Wed Oct 12, 2016 10:41 am
by pthirkell
OK sure ... good idea!
SVG Color lcb file
(130.38 KiB) Downloaded 339 times

Re: SVG in widgets - any roadmap?

Posted: Wed Oct 12, 2016 1:00 pm
by bn
Hi Peter,

this is very nice. A very good job. Thank you for this.

Some remarks

SVG files that don't work because they use a different format can be imported into Affinity Designer and placed in the upper left corner and then exported from Affinity Designer as SVG. As you mentioned, Gradients are not supported.

Also, when scribbling in Affinity Designer (pen tool works, I could not get the brush tool to work) it is best to place your scribble into the topleft corner.

Again, thanks a lot

Kind regards

Re: SVG in widgets - any roadmap?

Posted: Mon Oct 17, 2016 2:32 pm
by [-hh]
Thanks for this really neat widget.

Because widget packages will easily cross the 250 KB-limit line of the forums I now made a simple "fileSplitAndJoin" utility and added it to the Raspi stacks collection (#82).
("Sample Stacks" would be more comfortable to use, but I have currently problems to upload there).

You can now upload up to three files (zip or image) of length < 250 KB to this forum, for example two splitted parts of the '.lce' and an image. The downloader then has to download once the fileSplitAndJoin-utility and use button "join files".

[ps. Although the lce package is itself a zip one has to use the ending ".zip" for uploading it or the parts (to the forums) ---> use button "add '.zip'" of the utility]

Re: SVG in widgets - any roadmap?

Posted: Fri Oct 21, 2016 9:31 am
by livfoss
This is all very encouraging, and thanks for the tremendous effort. I have not lost interest, but my time has been taken up by much more mundane problems to do with getting a production version of a project fully working cross-platform. When (don't say 'if'!) I get out of that wood, I am hoping to study this material very carefully, since what has already been done probably is enough for the project I'm hoping to turn to next. I am not sure if I will ever have the skills to contribute.

Re: SVG in widgets - any roadmap?

Posted: Tue Oct 25, 2016 12:11 pm
by MaxV
I tried to install the LCE file with livecode 9 or 8.1, but nothing happen...

Colour SVG please? Last pull is a year ago?

Posted: Fri Jan 13, 2017 11:48 am
by frans
I just tried to build the widget as well. It stops with an error ( in 9)
The TIGER image you are displaying in this thread is EXACTLY what I need ( and then some 2100 of that)

11:37 AM: Launching in Test Window
11:37 AM: Error: Community.livecode.thirkell.multicolor is not valid - malformed byte code

Necessary files


seem to be in place but at least in 9 DP4 INDY it is not compiling.Do I need to use COMMUNITY? Seems a bit strange...

I can't find anything wrong with the import module lci either (community.livecode.thirkell.multicolor.lci)

I could REALLY really do with colour SVG now to lighten the burden of a very graphically oriented app. All sizes make the package huge and SVG would slice
that dead weight immediately. Please?

All the best from Berlin

Re: SVG in widgets - any roadmap?

Posted: Fri Jan 13, 2017 3:49 pm
by [-hh]
Peter's SVG widget runs here perfectly in 8.1.2, Indy and Commmunity version.
It does here also NOT run in latest LC 9.0.0-dpx (also after trying several workarounds).

If you tried in LC 9 then uninstall the widget in the extension builder/manager, quit LC 9 and remove all created files from your input folder (where the lcb file resides). Then compile in LC 8.1.2 again.

This is the same with nearly all widgets I made:
They changed again (after 8.1.1) the widget format in LC 9.0.0-dp2.

Now some (simple) widgets run again by recompiling them in LC 9 but then most of them don't work in LC 8 any more.

The problem seems to be located in the OnSave and OnLoad handlers. One has to go thru each single step and try to do workarounds if one finds a not-working-line. Even a documented feature (load image files from resource) doesn't work any more.

See also ... 49#p148949

That's why I stopped working with widgets in LC 9, I don't make new widgets any more before a *stable* LC 9 release.

Re: SVG in widgets - any roadmap?

Posted: Fri Jan 13, 2017 4:55 pm
by frans
Ah.. ok. Thanks for the info. I was under the impression this was so new that it already was for 9. But I will try 8.1.2. Thanks!
I do wish the sprites and colour scalable graphics from the original kickstarter where coming anywhere soon...


Re: SVG in widgets - any roadmap?

Posted: Sat Jan 14, 2017 9:18 am
by pthirkell
I do have a slightly amended LCB script which now runs under LC 9 dp 4 if anyone particularly wants it. However I would recommend waiting unless you really need version 9 for other reasons.

There is a slightly obscure (confirmed) bug in the color picker for LC9 dp 4, but if you only need to display the color widget and not change any of the path colour properties then the amended script should work fine.