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
Binary Convertor
QWI Script Styler
Noise Algorithm 2
Command Line Arguments, 3 State Buttons, and Limited Fields
Light Up Game Controller
Clipboard Xtra
Prompt for Disk
authoring method docSprite()
Get Font List without using xtras!
XML Socket Server for Flash, Director and Authorware
 

 

 

Behavior Noise 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)

Turns an image into random noise using the dominant colours. The amount value varies the random pattern. This algorithm creates a truly random noise pattern, but from an image, not from nothing.

-- Noise Effect
-- ©2005 by Josh Chunick (josh@chunick.com)
-- This code is free to use in commercial applications
-- or however you want.If you use this code you
-- must keep the comments, including this message,
-- intact. Feel free to add any changes or make
-- improvements.

-- theImage is an image object
-- amount is an integer value

on Noise (theImage, amount)
  
  theWidth = theImage.width - 1
  theHeight = theImage.height - 1
  newImage = theImage.duplicate()
  
  -- the look-up table for the original image (done for speed purposes)
  -- Use this if the
  listX = []
  listY = []
  
  repeat with x = 0 to theWidth
    repeat with y = 0 to theHeight
      listY.add(theImage.getPixel(x,y))
    end repeat
    listX.add(listY)
    listY = []
  end repeat
  
  -- draw each pixel in the new image
  repeat with y1 = 0 to theHeight
    
    repeat with x1 = 0 to theWidth
      rndX = random(amount) - 2
      rndY = random(amount) - 2
      
      xMod = max(min(theWidth, x1 + rndX), 1)
      yMod = max(min(theHeight, y1 + rndY), 1)
      
      theColour = listX[xMod][yMod]
      
      R = theColour.red
      G = theColour.green
      B = theColour.blue
      
      newImage.setPixel(point(x1,y1), color(R, G, B))
    end repeat
  end repeat
  
  return newImage
  
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail