• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sine of the times: Much better window shaker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Sine of the times: Much better window shaker (From: LE STANG Jean-Baptiste <email@hidden>)

  • Prev by Date: Re: What are the elements listed in a dictionary?
  • Next by Date: Re: window shaker, finishing in the Dock?
  • Previous by thread: Re: Sine of the times: Much better window shaker
  • Next by thread: Re: Sine of the times: Much better window shaker
  • Index(es):
    • Date
    • Thread