Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Vector Shapes - Create Spiral & Create Spiral Twist
Wait for cuePoint behavior
Puzzler - Puzzle Maker
Cursor trails
SerialXtra
Set FrameRate of a Animated GIF Sprite
Dr.Explain - help file tool
Play and cleanup DV Sprites
Convert Fonts
Digital Video
 

 

 

Behavior Rotate Image Algorithm - Imaging Lingo

Added on 8/23/2005

 

Compatibilities:
behavior D8 D8_5 D9 Mac Parent PC Shockwave

This item has not yet been rated

Author: Chunick (website)

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

Send e-mail