SVG Icon - Quick hack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

pink
Posts: 272
Joined: Wed Mar 12, 2014 6:18 pm

Re: SVG Icon - Quick hack

Post by pink » Mon May 16, 2016 12:41 pm

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
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

pink
Posts: 272
Joined: Wed Mar 12, 2014 6:18 pm

Re: SVG Icon - Quick hack

Post by pink » Mon May 16, 2016 12:56 pm

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
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: SVG Icon - Quick hack

Post by jameshale » Mon May 16, 2016 2:36 pm

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.

pink
Posts: 272
Joined: Wed Mar 12, 2014 6:18 pm

Re: SVG Icon - Quick hack

Post by pink » Mon May 16, 2016 7:47 pm

added another card in which you can create a button bar (or rather a group of SVG icons)
Attachments
SVG Library a6.livecode.zip
(126.03 KiB) Downloaded 354 times
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3990
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: SVG Icon - Quick hack

Post by bn » Mon Jun 20, 2016 9:43 am

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

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: SVG Icon - Quick hack

Post by marksmithhfx » Tue Oct 27, 2020 12:22 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3990
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: SVG Icon - Quick hack

Post by bn » Tue Oct 27, 2020 5:31 pm

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

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: SVG Icon - Quick hack

Post by marksmithhfx » Thu Oct 29, 2020 9:41 pm

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
Attachments
Archive.zip
(5.09 KiB) Downloaded 189 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: SVG Icon - Quick hack

Post by marksmithhfx » 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?

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)
Attachments
Archive.zip
(5.06 KiB) Downloaded 161 times
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: SVG Icon - Quick hack

Post by marksmithhfx » Mon Nov 02, 2020 11:37 am

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: SVG Icon - Quick hack

Post by jacque » Mon Nov 02, 2020 8:56 pm

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.
Last edited by jacque on Mon Nov 02, 2020 9:09 pm, edited 1 time in total.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: SVG Icon - Quick hack

Post by jacque » Mon Nov 02, 2020 9:06 pm

marksmithhfx wrote:
Mon Nov 02, 2020 11:37 am
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 :(
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: SVG Icon - Quick hack

Post by marksmithhfx » Wed Nov 04, 2020 11:16 am

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: SVG Icon - Quick hack

Post by marksmithhfx » Wed Nov 04, 2020 11:19 am

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?
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: SVG Icon - Quick hack

Post by jacque » Wed Nov 04, 2020 4:44 pm

marksmithhfx wrote:
Wed Nov 04, 2020 11:19 am
What about resizing due to fullscreenmode? Would that be affected?
Nope, the limitation is strictly related to user mouse events. Everything else works normally.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”