Economy-x-Talk - Sample Scripts
ClickCentral
Geoff Johnson-Brett, July 2003.
_____________________________
Click anywhere INSIDE the picture to move it to the centre of the card, and return its subsequent rect.
Move the image back to its parking place with the button "Reset". On leaving the card the picture will be parked automatically.
To prove that the script works in other positions, you may select and drag the picture anywhere within the rectangle in which it now resides.
[The script of sampleStacks limits the area available for this demonstration].
You may replace the picture with any other small picture, if you wish.
on closeCard
parkPict
end closeCard
on parkPict
lock screen
choose select tool
doMenu "Select" with commandKey
doMenu "opaque"
drag from 300,200 to 120,350
choose browse tool
end parkPict
on clickCentral
lock screen
put round((the width of cd window)/2) & "," ¬
& round((the height of cd window)/2) into midCard
--Establishes the centre point of the card, whatever its size
choose select tool
doMenu "Select" with commandKey
doMenu "Copy Picture"
drag from the clickLoc to 0,0
-- Select the picture tightly, copy it, then drag it completely
-- to the top left corner [so its topLeft is at 0,0]
-- Now borrow some of the functionality of 'Picture' XCMD to get
--the size of the copied image.
picture "theCopy","clipboard",,false,0
--False means that the picture window is created but not shown
--The empty windowStyle creates the default Zoom style window
--the windowStyle is not material here ...
choose browse tool
put round((the pictureWidth of window "theCopy")/2) into x
put round((the pictureHeight of window "theCopy")/2) into y
-- ... for pictureWidth & pictureHeight refer to the original image,
-- not to the created window
put x & "," & y into midPict
-- The centre of the image
choose select tool
get the bottomRight of cd
drag from it to 0,0 with commandKey
--selecting the picture by its bounding rectangle
drag from midPict to midCard
--Drags the centre of the picture to the centre of the card
choose browse tool
put "a,b,c,d" into myRect
put (item 1 of midCard)-x into item 1 of myRect
put (item 2 of midCard)-y into item 2 of myRect
--x is half the picture width - see above
--and y is half the picture height
put (item 1 of myRect) + (the pictureWidth of window "theCopy")¬
into item 3 of myRect
put (item 2 of myRect) + (the pictureHeight of window "theCopy")¬
into item 4 of myRect
put "My rect when centred is" && myRect
close window "theCopy"
--Get rid of it, or it may cause confusion another time
end clickCentral
Keep this extensive resource of tutorials and samples on-line! Support RunRev.info!
| Yes, this script is useful. I make a donation and choose freely how much I want to donate on-line (PayPal). Click here if you want to make a donation in dollars. | This script has not (completely) solved my problem and I want Economy-x-Talk to take care of it. Let me contact you. |
Copyright©2002-2008 by Mark Schonewille, Nijmegen, the Netherlands. This web site is in no way affiliated with Runtime Revolution Ltd., but we do recommend the Revolution development platform.