Page 2 of 3
Re: SVG Icon - Quick hack
Posted: Mon May 16, 2016 12:41 pm
by pink
thanks James, I haven't started playing with 8.0.1, I'll give it a try later
I am wondering if the svg will fail if it does not end in a "z", just speculating on what might be wrong in the new version
Re: SVG Icon - Quick hack
Posted: Mon May 16, 2016 12:56 pm
by pink
I'm going to do some more testing... I'm changing the end of the import script to this:
Code: Select all
repeat until tStop is true
put char -1 of tNewPath into tChar
switch tChar
case space
case cr
delete char -1 of tNewPath
break
default
put true into tStop
break
end switch
end repeat
Re: SVG Icon - Quick hack
Posted: Mon May 16, 2016 2:36 pm
by jameshale
am wondering if the svg will fail if it does not end in a "z"
I am pretty sure I have tried paths that simply end in a number so no, do not think 'z' is mandatory.
Re: SVG Icon - Quick hack
Posted: Mon May 16, 2016 7:47 pm
by pink
added another card in which you can create a button bar (or rather a group of SVG icons)
Re: SVG Icon - Quick hack
Posted: Mon Jun 20, 2016 9:43 am
by bn
Hi James, Greg,
this seems to work quite well for me for the import of path data from .svg files. Of course it fails with quite some of the more elaborate SVGs.
Code: Select all
on mouseUp
answer file "choose SVG-File"
if it is empty then exit mouseUp
put url ("file:" & it) into tData
set the lineDelimiter to " d=" & quote -- begin of path
set the itemDelimiter to quote -- end of path
repeat with i = 2 to the number of lines of tData
put word 1 to - 1 of item 1 of line i of tData after tCollect -- no problem with trailing spaces or returns
end repeat
replace "m" with cr & cr &"M" in tCollect -- for some svgs it helps to make "M" absolute = capital M
replace comma with space in tCollect -- so it fits into a field in case it is comma delimited
put word 1 to - 1 of tCollect into tCollect -- no problem with returns
put tCollect into field "fSVGData"
end mouseUp
For some SVGs it shows at least something...
Kind regards
Bernd
Re: SVG Icon - Quick hack
Posted: Tue Oct 27, 2020 12:22 pm
by marksmithhfx
Hi, I noticed LC now has an AddIcon handler that requires a name, SVG path and codepoint to import an SVG Icon. I've downloaded a couple of SVG Icon files that have names and paths but none had a codepoint identified in them. Where do I find the information to fill in the codepoint?
Thanks
Mark
Re: SVG Icon - Quick hack
Posted: Tue Oct 27, 2020 5:31 pm
by bn
Hi Mark,
there are a couple of utilities out on Livecodeshare by Brian Milby and Devin Asay.
http://livecodeshare.runrev.com/stack/872/SVG-Icon-Tool
http://livecodeshare.runrev.com/stack/8 ... mily-Maker
http://livecodeshare.runrev.com/stack/8 ... con-Picker
Check those out how to add a SVG-font and manage it.
Kind regards
Bernd
Re: SVG Icon - Quick hack
Posted: Thu Oct 29, 2020 9:41 pm
by marksmithhfx
bn wrote: Tue Oct 27, 2020 5:31 pm
Hi Mark,
there are a couple of utilities out on Livecodeshare by Brian Milby and Devin Asay.
Kind regards
Bernd
Thanks Bernd. Nice set of programs. They will come in handy. I am having a bit of a problem using an imported SVG Icon description and I wonder if anyone here would have time to take a look. I was looking for a +/- icon and found one on the net. Downloaded the file (maybe I should just upload it?) and noticed right away it rendered on my Mac (as the image over the download folder), in an email message when I sent it to myself from one machine to another (poor mans network

) ,,, in the email which was just sending the SVG file it actually rendered it in the message body. Lets see, in LC when I used the code in the
http://lessons.livecode.com/m/4071/l/10 ... -in-my-app lesson. Yup that worked perfectly and in fact I will upload that stack and the customIconData.json file I created for it. There were a few things at the beginning and end of the description I had to take out because it was packaged in html. But that worked fine.
The problem that occurs happens when I compile the code and test. I get nothing on either macOS or iOS and I'm not sure why. Any ideas?
Thanks
Mark
Re: SVG Icon - Quick hack
Posted: Sun Nov 01, 2020 6:21 pm
by marksmithhfx
Can anyone see why the following code would work in development, but not when compiled to Mac or iOS devices?
Code: Select all
on mouseUp
## Load custom icons
put specialFolderPath("resources") & "/customIconData.json" into tSVGDataFile
put jsonToArray(url ("file:" & tSVGDataFile)) into tSVGDataArray
repeat with x = 1 to the number of elements in tSVGDataArray
addIcon tSVGDataArray[x]["name"],tSVGDataArray[x]["path"],tSVGDataArray[x]["codepoint"]
end repeat
end mouseUp
Thanks
(attached archive contains code and json file for SVG)
Re: SVG Icon - Quick hack
Posted: Mon Nov 02, 2020 11:37 am
by marksmithhfx
Hi Jacque,
Any experience with "lock size and position" and resizing for different devices? I've added a few groups to a card consisting of a graphic line, label and widget and to keep them from moving around decided to lock the size and position. Now I'm wondering if they will resize properly. I tried testing on the simulator but I've found the sim to be very finicky (so I avoid it). Today I got the message: Unable to start simulator: 634,0,0,unknown C++ exception 573,263,1,revIPhoneSetSimulartorSDK
Mark
Re: SVG Icon - Quick hack
Posted: Mon Nov 02, 2020 8:56 pm
by jacque
marksmithhfx wrote: Sun Nov 01, 2020 6:21 pm
Can anyone see why the following code would work in development, but not when compiled to Mac or iOS devices?
I did it the easy (or easier) way. I used SVG Icon Tool to create an icon family and exported it as a file. Then I embedded the file in a custom property of the stack, and after the stack launches I do this:
Code: Select all
addIconFamily "FPIcons",the cFPIcons of this stack
setCurrentIconFamily "FPIcons"
That's all I needed to do and it works everywhere, including in the IDE. The icon family that is exported is not json, and the file it writes appears to be binary.
Re: SVG Icon - Quick hack
Posted: Mon Nov 02, 2020 9:06 pm
by jacque
marksmithhfx wrote: Mon Nov 02, 2020 11:37 amAny experience with "lock size and position" and resizing for different devices? I've added a few groups to a card consisting of a graphic line, label and widget and to keep them from moving around decided to lock the size and position. Now I'm wondering if they will resize properly. I tried testing on the simulator but I've found the sim to be very finicky (so I avoid it). Today I got the message: Unable to start simulator: 634,0,0,unknown C++ exception 573,263,1,revIPhoneSetSimulartorSDK
LockLoc only applies to manual resizing, it prevents changes using the mouse. (It also prevents auto-resizing when an image is redrawn on opencard, but that's something different.) It does not interfere at all with resizing by script, so it's safe to use for scripted changes.
I'm not sure why you'd get a build error. It's important to have the chosen simulator fully launched and ready before trying to test though.
Re: SVG Icon - Quick hack
Posted: Wed Nov 04, 2020 11:16 am
by marksmithhfx
jacque wrote: Mon Nov 02, 2020 9:06 pm
I'm not sure why you'd get a build error. It's important to have the chosen simulator fully launched and ready before trying to test though.
Check, I did that. I'll send this to the mothership and see if they can provide any insight.
Mark
Re: SVG Icon - Quick hack
Posted: Wed Nov 04, 2020 11:19 am
by marksmithhfx
jacque wrote: Mon Nov 02, 2020 9:06 pm
LockLoc only applies to manual resizing, it prevents changes using the mouse. (It also prevents auto-resizing when an image is redrawn on opencard, but that's something different.) It does not interfere at all with resizing by script, so it's safe to use for scripted changes.
What about resizing due to fullscreenmode? Would that be affected?
Re: SVG Icon - Quick hack
Posted: Wed Nov 04, 2020 4:44 pm
by jacque
marksmithhfx wrote: Wed Nov 04, 2020 11:19 amWhat about resizing due to fullscreenmode? Would that be affected?
Nope, the limitation is strictly related to user mouse events. Everything else works normally.