Graphic Rotation

Jim Hurley jhurley at infostations.com
Sun Feb 22 18:24:17 EST 2004


>
>Scott,
>
>The tmpanel loaded and is very nicely designed, but the contents come
>up with a lot of html tags and the only live url is for the first demo.
>   looks like some great stuff in here hiding among the tags.
>
>Yours,
>Chris
>On Feb 22, 2004, at 12:28 PM, Scott Rossi wrote:

Chris,

This issue has been on the list before. The following script may be 
helpful. It will rotate an arbitrary set of graphic points through an 
arbitrary angle. A number of people contributed to it.

I have used a button name "Pivot", with a grab me handler, to  use as 
the point of rotation.

On mouseUP
    --Rotate a polygon "myPoly" about a button "Pivot" by 45 degrees
    rotatePoly "myPoly",the loc of button "Pivot", 45
end mouseUP

On rotatePoly theGraphic, thePivot, theAngle
   put the points of graphic theGraphic into tPoints

   put item 1 of thePivot into xPivot
   put item 2 of thePivot into yPivot

   put empty into newPointList

--Set points relative to pivot 
   repeat for each line tLine in tPoints
     put (item 1 of tLine)- xPivot & "," & (item 2 of tLine)- yPivot & 
return after tRelPoints
   end repeat

   put sin(theAngle* pi/180) into S
   put cos(theAngle * pi/180) into C

   --Rotate coordinate axes
   repeat for each line tLine in tRelPoints
     put round(C*(item 1 of tLine)+ S*(item 2 of tLine) + xPivot)& 
comma after rotPtlist
     put round(-S*(item 1 of tLine) + C*(item 2 of tLine)+ 
yPivot)after rotPtlist
     put return after rotPtList
   end repeat

   set the points of graphic theGraphic to rotPtlist

end rotatePoly

Jim


More information about the use-livecode mailing list