Picture background increasing slowly in size then switching
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Picture background increasing slowly in size then switching
I am using a new app and on the main screen the background picture slowly zooms in then flips to a new picture that does the same thing. There are three pictures it flips between. It is a really cool effect I wonder if there is an easy way to do this type of thing with livecode?
-
- VIP Livecode Opensource Backer
- Posts: 9633
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Picture background increasing slowly in size then switching
I suspect I am using neanderthal methods in the space age, but import an image to a card with a button. Put this into the button script:
You could easily expand this to cycle three images. I wonder what the right way to do this is?
Craig Newman
Code: Select all
on mouseUp
set the loc of img 1 to "200,200"
set the width of img 1 to 100
set the height of img 1 to 100
put the loc of img 1 into startLoc
repeat 30
lock screen
wait 2
set the width of img 1 to (the width of img 1) + 3
set the height of img 1 to (the height of img 1) + 3
set the loc of img 1 to startLoc
unlock screen
end repeat
flip img 1 horizontal
end mouseUp
Craig Newman
-
- Livecode Opensource Backer
- Posts: 9333
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Picture background increasing slowly in size then switching
Oh, Oh: another of those "one size fits all" phrases.the right way to do this
there are probably half a dozen ways.
-
- VIP Livecode Opensource Backer
- Posts: 9633
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Picture background increasing slowly in size then switching
Richmond.
No.
I just meant that there might be a way to do it properly.
Craig
No.
I just meant that there might be a way to do it properly.
Craig
Re: Picture background increasing slowly in size then switching
Hi mikemc,
Download the compressed stack "infinite_zoom_2014.zip" from this bug report from 2014.
Tell me if it works in your setup and a similar zoom effect is what you are looking for.
http://quality.livecode.com/show_bug.cgi?id=12148
In this stack, the images are reduced to a very small size in the middle of the screen
and they grows in size, depending of user input (mousedown or mouse wheel scroll)
Check the stack script. Expert LiveCode developers in this forum could turn this same
script into a much more simplified and streamlined handler.
Al
Download the compressed stack "infinite_zoom_2014.zip" from this bug report from 2014.
Tell me if it works in your setup and a similar zoom effect is what you are looking for.
http://quality.livecode.com/show_bug.cgi?id=12148
In this stack, the images are reduced to a very small size in the middle of the screen
and they grows in size, depending of user input (mousedown or mouse wheel scroll)
Check the stack script. Expert LiveCode developers in this forum could turn this same
script into a much more simplified and streamlined handler.
Code: Select all
local lfirstCoordinate, lsecondCoordinate, hstackWidth, hstackHeight
on mousedown
repeat until the mouse is up
put the mouseloc into tLocation
-- put tLocation
put "0,0,100,600" into tFirstRectangle
put "700,0,800,600" into tSecondRectangle
if tLocation is within tFirstRectangle then send "rawkeydown 65309" to this card
if tLocation is within tSecondRectangle then send "rawkeydown 65308" to this card
end repeat
end mousedown
on rawkeydown tkey
if tkey is 65308
then
zoomOutimg
else
if tkey is 65309 then zoomInimg
end if
pass rawKeyDown
end rawkeydown
on zoomInimg
put "1|2|4|6|8|2048|1538|1024|770|512|386|256|194|128|98|64|50|32|26|16|14" into tcontrolActualWidth01
put "2|4|6|8|14|2|2048|1538|1024|770|512|386|256|194|128|98|64|50|32|26|16" into tcontrolNextWidth02
put "1|3|4|6|11|1|1536|1154|768|578|386|290|194|146|98|74|50|38|26|20|14" into tcontrolNextHeight02
lock screen
repeat with i = 1 to 10
get the width of control i of this card
-- put "control" && i && "imagen" && char 1 to 2 of the short name of control i of this card && it & "x" & the height of control i of this card & cr after tLog
set the itemdel to "|"
if it is among the items of tcontrolActualWidth01
then
put item itemoffset(it,tcontrolActualWidth01) of tcontrolNextWidth02 into tNextWidth
set the width of control i of this card to tNextWidth
put item itemoffset(it,tcontrolActualWidth01) of tcontrolNextHeight02 into tNextHeight
set the height of control i of this card to tNextHeight
else
answer "ERROR in width:" && it && "of control" && i && "image " & the short name of control i of this card
end if
set the loc of control i of this card to "400,300"
-- put "control" && i && "imagen" && char 1 to 2 of the short name of control i of this card && it & "x" & the height of control i of this card & cr after tLog2
end repeat
if the width of control 1 of this card = "2"
then
-- reduce and move to the top of the pile of images in this card
set the layer of control 1 of this card to the number of controls of this card
set the loc of control (the number of controls of this card) of this card to "400,300"
set the width of control 10 of this card to "2"
set the height of control (the number of controls of this card) of this card to "1"
end if
unlock screen
end zoomInimg
on zoomOutimg
put "1|2|4|6|8|14|16|26|32|50|64|98|128|194|256|386|512|770|1024|1538|2048" into tcontrolActualWidth
put "1|1|2|4|6|8|14|16|26|32|50|64|98|128|194|256|386|512|770|1024|1538" into tcontrolNextWidth2
put "1|1|1|2|4|6|11|12|20|24|38|48|74|96|146|192|290|384|578|768|1154" into tcontrolNextHeight2
lock screen
repeat with i = 1 to 10
get the width of control i of this card
-- put "control" && i && "imagen" && char 1 to 2 of the short name of control i of this card && it & "x" & the height of control i of this card & cr after tLog
set the itemdel to "|"
if it is among the items of tcontrolActualWidth
then
set the width of control i of this card to item itemoffset(it,tcontrolActualWidth) of tcontrolNextWidth2
set the height of control i of this card to item itemoffset(it,tcontrolActualWidth) of tcontrolNextHeight2
else
answer "ERROR in width:" && it && "of control" && i && "image " & the short name of control i of this card
end if
set the loc of control i of this card to "400,300"
-- put "control" && i && "imagen" && char 1 to 2 of the short name of control i of this card && it & "x" & the height of control i of this card & cr after tLog2
end repeat
if the width of control 1 of this card = "1024"
then
set the layer of control (the number of controls of this card) of this card to 1
set the width of control 1 of this card to "2048"
set the height of control 1 of this card to "1536"
set the loc of control 1 of this card to "400,300"
end if
unlock screen
end zoomOutimg
Re: Picture background increasing slowly in size then switching
Thanks for the input I will get some time to
Try this stuff out on the weekend
Try this stuff out on the weekend
Re: Picture background increasing slowly in size then switching
OK I finally got a chance to try Craig's handler and it works but I have a problem accessing other menu options while I am flipping through the picture loop my handler is any ideas
on mouseUp
set the loc of img 1 to "200,200"
set the width of img 1 to 400
set the height of img 1 to 400
put the loc of img 1 into startLoc
repeat 30
lock screen
wait 5
set the width of img 1 to (the width of img 1) + 1
set the height of img 1 to (the height of img 1) + 1
set the loc of img 1 to startLoc
unlock screen
end repeat
set the width of img 1 to 0
set the height of img 1 to 0
set the loc of img 2 to "200,200"
set the width of img 2 to 400
set the height of img 2 to 400
put the loc of img 2 into startLoc
repeat 30
lock screen
wait 5
set the width of img 2 to (the width of img 2) + 1
set the height of img 2 to (the height of img 2) + 1
set the loc of img 1 to startLoc
unlock screen
end repeat
set the width of img 2 to 0
set the height of img 2 to 0
set the loc of img 3 to "200,200"
set the width of img 3 to 400
set the height of img 3 to 400
put the loc of img 3 into startLoc
repeat 30
lock screen
wait 5
set the width of img 3 to (the width of img 3) + 1
set the height of img 3 to (the height of img 3) + 1
set the loc of img 3 to startLoc
unlock screen
end repeat
set the width of img 3 to 0
set the height of img 3 to 0
send "mouseup" to btn "button"
end mouseUp
on mouseUp
set the loc of img 1 to "200,200"
set the width of img 1 to 400
set the height of img 1 to 400
put the loc of img 1 into startLoc
repeat 30
lock screen
wait 5
set the width of img 1 to (the width of img 1) + 1
set the height of img 1 to (the height of img 1) + 1
set the loc of img 1 to startLoc
unlock screen
end repeat
set the width of img 1 to 0
set the height of img 1 to 0
set the loc of img 2 to "200,200"
set the width of img 2 to 400
set the height of img 2 to 400
put the loc of img 2 into startLoc
repeat 30
lock screen
wait 5
set the width of img 2 to (the width of img 2) + 1
set the height of img 2 to (the height of img 2) + 1
set the loc of img 1 to startLoc
unlock screen
end repeat
set the width of img 2 to 0
set the height of img 2 to 0
set the loc of img 3 to "200,200"
set the width of img 3 to 400
set the height of img 3 to 400
put the loc of img 3 into startLoc
repeat 30
lock screen
wait 5
set the width of img 3 to (the width of img 3) + 1
set the height of img 3 to (the height of img 3) + 1
set the loc of img 3 to startLoc
unlock screen
end repeat
set the width of img 3 to 0
set the height of img 3 to 0
send "mouseup" to btn "button"
end mouseUp
Re: Picture background increasing slowly in size then switching
Hi Mike,
1. please use some puncuation marks in your postings and use the "Code display" formatting for your posted scripts. In the formatting row above the entry field: </>
2. add a "... with messages" to all of your WAIT commands:
That should give the engine, and thus the user, time to do other things like accessing a menu during the repeat loop. Otherwise it is completely blocking, as you have experienced.
Best
Klaus
1. please use some puncuation marks in your postings and use the "Code display" formatting for your posted scripts. In the formatting row above the entry field: </>
2. add a "... with messages" to all of your WAIT commands:
Code: Select all
...
lock screen
wait 5 with messages
...
Best
Klaus