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

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

Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 7:15 am

Hi.
I'm a bit stuck with how to go about this one. LC Images seem to be resized from the center of origin, so I need to be able to resize a business card sized image but still have it's left edge stay at the same location. Can anyone suggest a way to do this?

I can't get "set the left loc of image "Card" to 20,20" to work?

Thanks
Bidge

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

Re: Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 7:21 am

SOLVED: set the topleft of image "Card" to 14,14
Thanks
Bidge

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Aligning the edge of an image

Post by richmond62 » Tue Jul 11, 2017 7:32 am

ShakeIt.png
ShakeIt.livecode.zip
Here's the stack
(83.11 KiB) Downloaded 192 times
You don't need to use 'topleft': keep things simple . . . .

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

Re: Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 7:37 am

Oh....thank you richmond62. I did not realize you could only use one value :)

Thanks again
Bidge

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

Re: Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 7:40 am

It gets harder now :)......I have a gap between the two images I would like to stay the same. How can I keep these images side by side and maintain the gap if the images are resizable?

Bidge

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Aligning the edge of an image

Post by jmburnod » Tue Jul 11, 2017 9:18 am

Hi Bidge,
You can play with location as you want.
In your case probabily something like that

Code: Select all

put the topright of img 1 into tTR
put 24 into tMargin
add tMargin to item 1 of tTR
set the topleft of img 2 to tTR
Best regards
Jean-Marc
https://alternatic.ch

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

Re: Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 9:29 am

Hi Jean -Marc.

EDIT: Ahhh...I got it. I put the script into the card and it worked! Is there a way to do this with a group of two or more objects?
Thank you Jean-Marc :)



Thank you again. I put your script directly into a drag gable group of two images "W" and "E" and nothing happened?
Tried adjusting the margin numeric value but nothing. I probably am in error :)

Code: Select all

   
on mouseDown
grab me
put the topright of img "W" into tTR
put 84 into tMargin
add tMargin to item 1 of tTR
set the topleft of img "E" to tTR
end mouseDown
Cheers
Bidge

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

Re: Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 10:36 am

Hi.
This works great. I can't stop playing with the "Side" margins value but i don't know how to set a horizontal margin for the bottom so a 3rd image can be placed with a similar margin that can be altered?

Many thanks
Bidge

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Aligning the edge of an image

Post by jmburnod » Tue Jul 11, 2017 10:51 am

Hi
I quickly made a stack with two imgs in a locked group using
grab and mousemove.
If your group is not locked you have to consider that group is resized automaticaly
Here is the script group

Code: Select all

local sMyImg,sOtherImg,sMargin
on mouseDown
   put the short name of the target into sMyImg
      if sMyImg = "W" then
      put "E" into sOtherImg
   else 
      put "W" into sOtherImg
   end if
   put 84 into sMargin
   grab the target
end mouseDown

on mousemove
   doMoveOther
end mousemove

on doMoveOther 
   if sMyImg =  empty then exit doMoveOther
   if sMyImg = "W" then
      put the topright of img "W" into tTR
      add sMargin to item 1 of tTR
      set the topleft of img sOtherImg to tTR
   else
      put the topleft of img "E" into tTL
      subtract sMargin from item 1 of tTL
      set the topright of img sOtherImg to tTL
   end if
end doMoveOther
Attachments
stMoveTogetherInGrp001.zip
(4.98 KiB) Downloaded 185 times
https://alternatic.ch

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

Re: Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 10:58 am

Thanks so much for that Jean -Marc.
It is wonderful learning what can be done with Livecode :)

I managed to get three images aligned, the first two alisgned side by side with a margin as per your first example.
The 3rd image is sitting beneath the 1st image which is perfect but I need to
understand how to be able to insert a margin at the bottom so that there is a space that can be adjusted all around the images?
My code based on yours.

Code: Select all

on mouseDown
   put the topright of image "W1" into tTR
   put the bottomright of image "W1" into tTR2
put 34 into tMargin
add tMargin to item 1 of tTR
set the topleft of img "W2" to tTR
set the topright of img "W3" to tTR2
end mouseDown


Many thanks again
Bidge

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Aligning the edge of an image

Post by jmburnod » Tue Jul 11, 2017 12:44 pm

Hi,
You may try this (no tested)

Code: Select all

...
add 34 to item 2 of tTR2
set the topright of img "W3" to tTR2
...
https://alternatic.ch

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

Re: Aligning the edge of an image

Post by bidgeeman » Tue Jul 11, 2017 1:04 pm

Wow...Thank you again Jean -Marc :)
I will study it to try and understand what's going on.

Many thanks for your help!
Bidge

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Aligning the edge of an image

Post by richmond62 » Tue Jul 11, 2017 4:08 pm

Sometimes I get a feeling that people tend to over-complicate things . . .
Shake2.jpg
https://www.dropbox.com/s/7v28xc2vcq6xh ... e.zip?dl=0

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Aligning the edge of an image

Post by jmburnod » Tue Jul 11, 2017 5:57 pm

Hi Richmond,
Sometimes I get a feeling that people tend to over-complicate things . . .
As each time we search a flexible way. Flexibility often needs complexity...
I see each time I used a "simple way" in a large stack I need to rewrite it using params, functions, variables and customprop. I win a lot of lines and develop my capacities to think globaly a project.
Further, updates are easier 8)
Best regards
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Aligning the edge of an image

Post by richmond62 » Tue Jul 11, 2017 7:25 pm

Flexibility often needs complexity...
C'est possible, mais Je cherche chaque chance pour une méthode trop simple,
mais Je suis paresseux :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”