Aligning the edge of an image

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Aligning the edge of an image

Post by bogs » Tue Jul 11, 2017 8:08 pm

richmond62 wrote:
Flexibility often needs complexity...
C'est possible, mais Je cherche chaque chance pour une méthode trop simple,
mais Je suis paresseux :D
Translation Google wrote:It is possible, but I seek every chance for a method too simple,
But I'm lazy: D
Ok, the french gave me flash-backs to high school, which (temporarily) made me more unstable than I already am mentally, so I took the lazy way out and google'd it :P
Image

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Aligning the edge of an image

Post by bidgeeman » Wed Jul 12, 2017 12:54 am

Well I must agree with you completely being a beginner :)
Thank you again.
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Aligning the edge of an image

Post by bidgeeman » Wed Jul 12, 2017 2:34 am

Hello again.
I have studied your script and attempted to add a forth
image to the group. I managed to do it but for some reason
I have to click twice before the forth image goes into place?
Can someone have a look to see what I have done wrong?

Ideally I would like to add up to 6 images across the top and 6 images
below that can all be adjusted with two margin factor? if possible?
Maybe there is an easier way?

Thanks
Bidge
Attachments
DragWithSpacing.zip
Drag multiple images with spacing
(664 Bytes) Downloaded 219 times

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Aligning the edge of an image

Post by bidgeeman » Wed Jul 12, 2017 4:38 am

Well...after a lot of searching I managed to come up with a rather simple solution :)

Code: Select all

on mouseUp
   set the top of img "W2" to the top of img "W1"
   set the left of img "W2" to (the right of img "W1") + 10
      set the top of img "W3" to the top of img "W2"
      set the left of img "W3" to (the right of img "W2") + 10
      
      set the left of img "W4" to the left of img "W1"
      set the top of img "W4" to (the bottom of img "W1") + 10
      
            set the left of img "W5" to the left of img "W2"
            set the top of img "W5" to (the bottom of img "W2") + 10
            
                        set the left of img "W6" to the left of img "W3"
      set the top of img "W6" to (the bottom of img "W3") + 10
   
end mouseUp
Cheers
Bidge

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Aligning the edge of an image

Post by jmburnod » Wed Jul 12, 2017 9:01 am

Hi Bidge,
attempted to add a forth image to the group
There is no group in your stack and mousedown in cd script is not called because each img catch it
Maybe there is an easier way?
If you want move all controls of a group you maybe could move group instead controls of group
https://alternatic.ch

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Aligning the edge of an image

Post by bidgeeman » Wed Jul 12, 2017 9:06 am

Thank you Jean-Marc.
I managed to get the result without using a group with your help.
Saving a text file that sets the locations, width etc of each image
is now my next hurdle: ( I posted in another thread earlier).
http://forums.livecode.com/viewtopic.php?f=7&t=29485

Cheers
Bidge

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Aligning the edge of an image

Post by jmburnod » Wed Jul 12, 2017 10:14 am

I made your script more flexible but more... complicated :D
Who is the laziest ? 8)

Code: Select all

on mouseUp
   doAlignImg 2,3,10,10 --pNbRow,pNbCol,pMargeH,pMargeV
end mouseUp

on doAlignImg pNbRow,pNbCol,pMargeH,pMargeV
   put the height of img "W1" into tHeight
   put tTlC into depTR
   put pNbRow * pNbCol into tNbTot
   put 10,10 into depTR
   repeat with i = 1 to tNbTot
      put "W" & i into tImg
      set the topleft of img tImg to depTR
      put the topright of img tImg into depTR
      add pMargeH to item 1 of depTR
      put i mod pNbCol into tReste
      if tReste = 0  then
         put 10 into item 1 of  depTR
         add (tHeight + pMargeV) to item 2 of depTR
         next repeat
      end if
      wait 1 milliseconds
   end repeat
end doAlignImg
https://alternatic.ch

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Aligning the edge of an image

Post by Klaus » Wed Jul 12, 2017 10:20 am

Hi David,

when in the script editor, hit TAB from time to time, then you will get these nice indented scripts like the ones from Jean-Marc!
AND we can read them better. :D


Best

Klaus

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Re: Aligning the edge of an image

Post by bidgeeman » Wed Jul 12, 2017 10:21 am

Wow. It astounds me how you can think of such clever ways coding Jean - Marc!!! :shock:
Oh....thank you Klaus :)

Regards
Bidge

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Aligning the edge of an image

Post by jmburnod » Wed Jul 12, 2017 10:31 am

Thanks for the flowers.
I confess a big debt to some mentors of this forum :roll:
https://alternatic.ch

Post Reply