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:21:14 +0100
Here is an other one, that will make your window describing a window
arouna 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 cneter 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)
_______________________________________________
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.