Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Slow Searches - Valentina
EasyBase
Lingo-An Advanced Guide to Directors Scripting Language
PrimeBase Xtra
Delete a file
Set Frame Rate for Flash Member
Buddy API Review
Text Outliner
StuntRacer
Detect MS Media Player v9
MediaMacros Xtras Mall
 

 

 

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

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail