Hot and throbbing.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
richmond62
- Livecode Opensource Backer

- Posts: 10220
- Joined: Fri Feb 19, 2010 10:17 am
Hot and throbbing.
One of the kids I teach asked how to make an image resize when the mouse was over it.
So I went, inevitably, for the easiest solution I could think of with this script
inside the image:
on mouseEnter
set the width of me to 150
set the height of me to 150
end mouseEnter
on mouseLeave
set the width of me to 120
set the height of me to 120
end mouseLeave
The kid was perfectly happy with that.
HOWEVER . . .
I noticed something interesting:
If the image is UNLOCKED it expands and contracts from it centre, while
if the image is LOCKED it expands and contracts from its top-left hand corner.
I don't know if this is documented anywhere (???) .
AND, I wonder if there is a way to force the image to expand and contract from another of its corners?
So I went, inevitably, for the easiest solution I could think of with this script
inside the image:
on mouseEnter
set the width of me to 150
set the height of me to 150
end mouseEnter
on mouseLeave
set the width of me to 120
set the height of me to 120
end mouseLeave
The kid was perfectly happy with that.
HOWEVER . . .
I noticed something interesting:
If the image is UNLOCKED it expands and contracts from it centre, while
if the image is LOCKED it expands and contracts from its top-left hand corner.
I don't know if this is documented anywhere (???) .
AND, I wonder if there is a way to force the image to expand and contract from another of its corners?
- Attachments
-
- PULSE.livecode.zip
- Here's my example.
- (19.06 KiB) Downloaded 173 times
Re: Hot and throbbing.
You can play withrichmond62 wrote: AND, I wonder if there is a way to force the image to expand and contract from another of its corners?
Then you can change 1 to 4 of any corners..the rect of image
Best,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
richmond62
- Livecode Opensource Backer

- Posts: 10220
- Joined: Fri Feb 19, 2010 10:17 am
Re: Hot and throbbing.
"set the rectangle of object to left,top,right,bottom"
Thanks, that's super.
Thanks, that's super.
Re: Hot and throbbing.
Although unlikely in this particular situation, watch out for esoteric changes to the rect that brings the edge to the other side of the mouse position, triggering another mouseEnter or mouseLeave which changes the rect again, which ... etc etc. Temporarily locking messages might be needed.
Re: Hot and throbbing.
Using the rect needs to make some calculations. I prefer this:
########CODE#######
on mouseEnter
lock screen
put the loc of me into temp
set the width of me to 150
set the height of me to 150
set the loc of me to temp
unlock screen
end mouseEnter
on mouseLeave
lock screen
put the loc of me into temp
set the width of me to 120
set the height of me to 120
set the loc of me to temp
unlock screen
end mouseLeave
#####END OF CODE#####
########CODE#######
on mouseEnter
lock screen
put the loc of me into temp
set the width of me to 150
set the height of me to 150
set the loc of me to temp
unlock screen
end mouseEnter
on mouseLeave
lock screen
put the loc of me into temp
set the width of me to 120
set the height of me to 120
set the loc of me to temp
unlock screen
end mouseLeave
#####END OF CODE#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Hot and throbbing.
YepUsing the rect needs to make some calculations. I prefer this:
Re: Hot and throbbing.
And what's more, this way you can also choose the direction of expansion by setting (say) the bottomRight to temp. Given the difference between the points, that will jump a little further, so put (say) the bottomRight into temp first.
