Re: Sine of the times: Much better window shaker
Re: Sine of the times: Much better window shaker
- Subject: Re: Sine of the times: Much better window shaker
- From: LE STANG Jean-Baptiste <email@hidden>
- Date: Sat, 22 Mar 2003 00:24:39 +0100
Oopss, without the typo it gives :
Here is an other one, that will make your window describe a spiral
around a given point of the screen
on SpiralShakeWindow(w, destination)
set numPeriods to 10 -- the number of turns arouns the final point
set numberOfSteps to 40 -- the number of steps for each turn
set {xFinal, yFinal} to destination -- the center of the spiral
set stepF to 2 * pi / numberOfSteps -- the step of the angle
tell application "Finder"
activate
set {xPrime, yPrime} to position of w
set theta to atan ((yPrime - yFinal) / (xPrime - xFinal))
if xFinal > xPrime then set theta to theta + pi -- check taht we took
the good angle
repeat with i from 0 to numberOfSteps * numPeriods
set r to my getDistance({xFinal, yFinal}, {xPrime, yPrime})
set theta to theta + stepF
set newX to xFinal + r * (1 - i / (numberOfSteps * numPeriods)) *
(cos (theta))
set newY to yFinal + r * (1 - i / (numberOfSteps * numPeriods)) *
(sin (theta))
set position of window 1 to {newX, newY}
end repeat
end tell
end SpiralShakeWindow
on getDistance(centerF, pointF)
return sqrt (((item 2 of centerF) - (item 2 of pointF)) ^ 2 + ((item 2
of centerF) - (item 2 of pointF)) ^ 2)
end getDistance
tell application "Finder"
set w to window 1
set destination to {500, 200}
end tell
SpiralShakeWindow(w, destination)
JB
-- I'm going to sleep right now before I collapse on my keyboard
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.