Page 1 of 1

How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 12:47 pm
by Zax
Hello

How can I copy the backgroundPattern from one graphic control to another?

Here is how I populate the backgroundPattern of a first graphic with an image:

Code: Select all

set the backGroundPattern of graphic "Graphic1" to (the id of last image)
delete last image
I would now a second graphic to have the same backgroundPattern as the first, even though the source image has been deleted.
I tried, without success:

Code: Select all

set the backgroundPattern of graphic "Graphic2" to the backgroundPattern of graphic "Graphic1"

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 1:07 pm
by Klaus
Bonjour Zax,

this is not possible!

It is just like the icon of a button, which is also the id of an image.
If you delete the image, close the stack and reopen it, the icon of the button is gone!

Same for a bgpattern, the image is neccessary for the pattern as some kind of "reference".
Means no image, no bgpattern!


Best

Klaus

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 1:11 pm
by Zax
Klaus wrote:
Wed Apr 10, 2024 1:07 pm
this is not possible!
Merci Klaus :)

(I must say that I still preferred the time when you answered me "It's possible, it's Livecode!" :twisted: )

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 1:41 pm
by Klaus
Maybe next time... :-D

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 1:50 pm
by richmond62
Try this:

Code: Select all

on mouseUp
   set the backGroundPattern of grc "rp2" to the backGroundPattern of grc "rp1"
end mouseUp
Of course IF you have deleted the source image (erm, why?) you'll have to do something more sneaky:

Code: Select all

on mouseUp
   import snapshot from grc "rp1"
   set the name of the last image to "xxx"
   set the backGroundPattern of grc "rp3" to id of img "xxx"
end mouseUp

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 1:52 pm
by Klaus
richmond62 wrote:
Wed Apr 10, 2024 1:50 pm
Try this:

Code: Select all

on mouseUp
   set the backGroundPattern of grc "rp2" to the backGroundPattern of grc "rp1"
end mouseUp
We have been there already... 8)

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 1:56 pm
by richmond62
Read the second bit of my posting. 8)

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 2:04 pm
by Zax
Thank you richmond62.

BTW, my script deletes the "last image" because, when in development time, I didn't want to store lots a temporary images in my stack.

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 2:07 pm
by Klaus
richmond62 wrote:
Wed Apr 10, 2024 1:56 pm
Read the second bit of my posting. 8)
That came later than my posting, Sir! 8)

Re: How to copy backgroundPattern of a graphic ?

Posted: Wed Apr 10, 2024 2:33 pm
by richmond62
Your 'problem' Klaus, is that you were too quick off the mark, and I had to stir some food I was cooking between the 2 parts of my message.
--
Here's your punishment: 8)


Spinach Toran


SERVES 2
450 g/| Ib fresh spinach
4 tbsp oil
I small onion, finely chopped
I green chilli, chopped
75 g/3 oz tomatoes, peeled and chopped
75 g/3 oz grated or desiccated coconut
salt

1 Wash the spinach, discard any discoloured leaves and tough stalks, and shake dry. Chop as finely as possible and leave in a colander to drain.
2 Heat the oil in a pan and gently fry the onion and green chilli until the onion is transparent.
3 Add the spinach and tomato, cover tightly and cook on a low heat for 4-5 minutes, shaking the pan occasionally, until the spinach has collapsed.
4 Stir in the coconut and add salt to taste.