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
Start Menu(xml)
PopUp Field
Video Codecs
QTRecordAudioXtra
Direct-L
myScreenSaver
Coloring Book
Show Me the Movie
System Info into a field member
Message Box Behavior
 

 

 

Behavior Fill using setPixel

Added on 10/7/1999

 

Compatibilities:
behavior D7 D8 Mac PC

This item has not yet been rated

Author: RoyPardi

Here"s a little "fill" behavior using get/set pixel. Its pretty slow for anything larger than 100 px square since each pixel is checked for color. On the other hand, drawing directly into a bitmap an arbitrary pixel at a time is fast.

--------- change selected color in bitmap to random color
--------- Roy Pardi
--------- rpardi@rcn.com
--------- www.roypardi.com

property spriteNum
property pMem
property pHeight
property pWidth

on beginSprite me
  pMem = sprite(spriteNum).member
  pWidth = pMem.width - 1
  pHeight = pMem.height -1
end

on mouseDown me
  fillColor = random(16777216)

  changeColor = getPixelColor(me)
  cursor 4
  repeat with V = 0 to pHeight
    repeat with H = 0 to pWidth
      testColor =  pMem.getPixel(H,V)
      if testColor = changeColor then
        pMem.setPixel(H, V, fillColor)
      end if
    end repeat
  end repeat
  updatestage
  cursor -1
end

on getPixelColor me
  mTop = (the mouseLoc).locV
  mLeft = (the mouseLoc).locH
  top = sprite(spriteNum).rect.top
  left = sprite(spriteNum).rect.left
  sLeft = mLeft-left
  sTop = mTop-top
  return pMem.getPixel(sLeft,sTop)
end

 


Contact

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

Send e-mail