This code was originally written by Luke Wigley. I've modified it so you can pass it an image object and also a colour for the background
on rotateImage (anImage, anAngle, anOffSet, aColour)
--------------------------------------------------------------------
-- rotates the supplied image.
-- anAngle is specified in degrees.
-- I Added the image parameter and the colour parameter, aColour.
-- the offset parameter is the pivot point of the rotation.
-- pass along the member.regPoint for rotation around the center point
-- the colour parameter is the background colour of the empty image
-- which you get when you rotate an image.
-- original code by Luke Wigley www.lingoworkshop.com
--------------------------------------------------------------------
aRect = anImage.rect
aQuad = [point(0,0), point(aRect.width,0), point(aRect.width,aRect.height), point(0,aRect.height)]
newQuad = []
anAngle = anAngle * pi/180.0
repeat with j = 1 to 4
thisPoint = aQuad[j]
x = thisPoint[1] - anOffSet[1]
y = thisPoint[2] - anOffSet[2]
thisPoint[1] = x * cos(anAngle) - y * sin(anAngle)
thisPoint[2] = x * sin(anAngle) + y * cos(anAngle)
newQuad[j] = thisPoint + anOffSet
end repeat
newImage = image(anImage.width, anImage.height, anImage.depth)
newImage.floodFill(point(0,0), aColour)
newImage.copyPixels(anImage, newQuad, aRect, [#useFastQuads: 0])
return newImage
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA