This code was posted by James Newton on the games list a little while ago - it should point you in the right direction
on imageRotate(anImage, anAngle) ------------------------------------- -- INPUT: <anImage> must be an image object -- <anAngle> should be an integer or floating point number -- representing an angle in degrees -- OUTPUT: an anti-aliased image object corresponding to <anImage> -- rotated clockwise through <anAngle> degrees. This image -- is likely to be larger than the original, and include -- white triangles in each corner. -------------------------------------------------------------------- -- Convert anAngle to radians anAngle = anAngle * pi / 180 tRect = anImage.rect tWidth = tRect.width tHeight = tRect.height tDepth = anImage.depth tPalette = anImage.paletteRef -- Scale the image before rotation so that the downscaled result is -- anti-aliased (supersampling) tImage2 = image(tWidth * 2, tHeight * 2, tDepth, tPalette) tImage2.copyPixels(anImage, tRect * 2, tRect) -- Determine polar coordinates of bottom right corner tAngle = atan(tHeight, tWidth) tRadius = sqrt(tHeight * tHeight + tWidth * tWidth) -- Rotate top and bottom right-hand corners and convert to Cartesian tTemp = anAngle - tAngle tH2 = tRadius * cos(tTemp) tV2 = tRadius * sin(tTemp) tTemp = anAngle + tAngle tH3 = tRadius * cos(tTemp) tV3 = tRadius * sin(tTemp) -- Determine the dimensions of a quarter of the new image tHMax = max(abs(tH2), abs(tH3)) tVMax = max(abs(tV2), abs(tV3)) -- Map the rotated positions of the corners, and translate all -- corners to positive h and v coordinates tPoint1 = point(tHMax - tH3, tVMax - tV3) tPoint2 = point(tHMax + tH2, tVMax + tV2) tPoint3 = point(tHMax + tH3, tVMax + tV3) tPoint4 = point(tHMax - tH2, tVMax - tV2) -- Create a half-double-sized image for the final output tImage3 = image(tHMax, tVMax, tDepth, tPalette) tNewRect = rect(0, 0, tHMax, tVMax) -- Determine the dimensions of the rotate double-sized image tHMax = tHMax * 2 tVMax = tVMax * 2 tRect = tRect * 2 -- Create an image of the appropriate size and copy the double-sized -- image using a quad for the rotation tImage4 = image(tHMax, tVMax, tDepth, tPalette) tImage4.copyPixels(tImage2,[tPoint1,tPoint2,tPoint3,tPoint4],tRect) -- Reduce to actual size to introduce an anti-alias effect tImage3.copyPixels(tImage4, tNewRect, tNewRect * 2) return tImage3 end imageRotate [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
