Page 7 of 18

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 7:15 am
by Zax
Is there a way to import as control by script?
If I use the menu File -> Image as Control -> Image File, .svg file are imported without any problem. But I'm unable to import the same .svg file with the import command :(

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 8:14 am
by richmond62
Mmmm . . .
-
SShot 2022-08-18 at 10.12.04.png
-
C'est un crôt . . . :?

Code: Select all

on mouseUp
   answer file "Select image:"
   if the result is not cancel then
      set the lockscreen to true
      import paint from file it
      set the name of the last control to "XYZ"
      wait 5 ticks
      set the lockscreen to false
   end if
end mouseUp
Ce code fonctionne avec les images PNG! Et des JPGs, GIFs et (possiblement) BMPs.

Le problème réside dans le mot 'paint'. Les images SVGs n'ont pas 'paint', ils ont des lignes.

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 8:39 am
by richmond62
SShot 2022-08-18 at 10.37.09.png
-

Code: Select all

on mouseup
   answer file "select an SVG image"
   put it into XYZ
   create image
   put it into ABC
   set the text of ABC to drawingSvgCompileFile(XYZ)
end mouseup
This is SLOW, so wait. 8)

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 8:44 am
by richmond62
SShot 2022-08-18 at 10.39.52.png
-
And how the !@#$%^&*( did Richmond know what to look for in the Dictionary?

Café ! Tu peux dormir quand tu es mort ! :D

OBVIOUSLY this will NOT import SVG images that contain font components successfully.

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 10:18 am
by stam
That is a very interesting command Richmond, thank you for highlighting it...

This could be very useful for my own purposes, but I'm slightly concerned about the disclaimer at the end of the API:
Note: The drawing binary format is not currently considered stable and is subject to change until the end of the RC cycle for 9. At present it is advised that SVG files be compiled as needed when developing in the IDE, and then compiled ahead-of-time when building a standalone.
And of course, i'd have to remember to include XML for the standalone ;)

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 10:26 am
by richmond62
What Zak has not told us is whether he wants to use this in a standalone, or simply
for his own uses in the IDE.

Oh, and THIS is from LC 10 DP-4, so I would not hold my breath:
-
SShot 2022-08-18 at 12.24.44.png
-
Oh, and as my licence [very kindly supplied by LiveCode for educational purposes] is going 'poof' in 2 weeks time,
I. at least, am "learning to live with" Livecode 9.6.3. Community, at least until someone somewhere manages to
produce a 'continuation' Open Source version, or LiveCode themselves offer a 'RevMedia reborn' version.

My stack works with LC 10-dp 4:
-
SShot 2022-08-18 at 12.32.53.png

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 10:36 am
by Zax
Merci beaucoup richmond :) Une fois de plus, vous êtes d'une aide précieuse !

It works great. I looked at the Dictionnary before posting but didn't find this command.
I made a loop based on your script to import all .svg files in a folder an dit works great :)

I'm using LC 9.6.8 with a License (don't remember which one, it's a kind of "middle" licence: not the biggest but one I paid).
I'm planning to build a standalone.

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 10:40 am
by richmond62
1. Open the Dictionary.

2. Search for 'SVG':
-
SShot 2022-08-18 at 12.39.20.png
-
Ce n'est pas difficile. 8)

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 10:42 am
by richmond62
I made a loop based on your script to import all .svg files in a folder an dit works great
?:
-
SShot 2022-08-18 at 12.41.59.png

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 10:49 am
by Zax
richmond62 wrote: Thu Aug 18, 2022 10:40 am 1. Open the Dictionary.
2. Search for 'SVG':
I searched "image" :(

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 10:58 am
by richmond62
I searched "image"
I, first of all, looked at the image stuff, and then realised that an SVG file does not contain 'paint'.

That is why, earlier on, I tried a standard import image script and ended up looking un peu fou. :?

SVGs are Vector Images, and as a result, are treated differently.

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 12:03 pm
by richmond62
"To use this function in a standalone, you must include the XML extension."

It would be just great if someone could explain how to do that . . .
-
SShot 2022-08-18 at 14.02.23.png
-
?

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 12:29 pm
by Klaus
Hi Richmond,

I think they mean the "SVG Icon Drawing Library", which has a separate entry in the list of Inclusions.


Best

Klaus

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 12:40 pm
by richmond62
Thank you very much, Klaus, for
the help. 8)

Re: Create a button's icon with a part of a big image?

Posted: Thu Aug 18, 2022 12:58 pm
by richmond62
Oh, wait a big fat moment . . .

SVG icons are one thing,

and importing SVG images might be another.