Page 1 of 2
Aligning the edge of an image
Posted: Tue Jul 11, 2017 7:15 am
by bidgeeman
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
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 7:21 am
by bidgeeman
SOLVED: set the topleft of image "Card" to 14,14
Thanks
Bidge
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 7:32 am
by richmond62
You don't need to use 'topleft': keep things simple . . . .
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 7:37 am
by bidgeeman
Oh....thank you richmond62. I did not realize you could only use one value
Thanks again
Bidge
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 7:40 am
by bidgeeman
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
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 9:18 am
by jmburnod
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
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 9:29 am
by bidgeeman
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
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 10:36 am
by bidgeeman
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
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 10:51 am
by jmburnod
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
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 10:58 am
by bidgeeman
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
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 12:44 pm
by jmburnod
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
...
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 1:04 pm
by bidgeeman
Wow...Thank you again Jean -Marc

I will study it to try and understand what's going on.
Many thanks for your help!
Bidge
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 4:08 pm
by richmond62
Sometimes I get a feeling that people tend to over-complicate things . . .
https://www.dropbox.com/s/7v28xc2vcq6xh ... e.zip?dl=0
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 5:57 pm
by jmburnod
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
Best regards
Jean-Marc
Re: Aligning the edge of an image
Posted: Tue Jul 11, 2017 7:25 pm
by richmond62
Flexibility often needs complexity...
C'est possible, mais Je cherche chaque chance pour une méthode trop simple,
mais Je suis paresseux
