Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Data Linker Xtra
Protected Code
Navigate to a Different Movie
Director-3D.com
PopUp Field
Check Acrobat Version
NAB - 'Not Another Button'
Drag sprite around a snap grid
3D Quad
Fade In Out Text
MediaMacros Xtras Mall
 

 

 

Behavior Image Flood Fill (Using getPixel and setPixel)

Added on 10/6/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: JakobMadsen

This behavior uses the undocumented setPixel and getPixel functions to flood fill an image.

--------- flood fill color in bitmap to random color
--------- Jakob Hede Madsen
--------- hede@image.dk
--------- special thanks: Roy Pardi
property pPctRef
property pSprLeft
property pSprTop
property pSprScalarX
property pSprScalarY
property pPixelActorListX
property pPixelActorListY
property pSpreadListX
property pSpreadListY

---------------

on beginSprite me
  mySpr = sprite me.spriteNum
  pPctRef = mySpr.member
  pSprLeft = mySpr.left
  pSprTop = mySpr.top
  pSprScalarX = float(pPctRef.width) / mySpr.width
  pSprScalarY = float(pPctRef.height) / mySpr.height
  pPixelActorListX = []
  pPixelActorListY = []
  pSpreadListX = [1, 0, -1, 0]
  pSpreadListY = [0, 1, 0, -1]
end

---------------

on mouseDown me
  fillColor = random(16777216)
  sprX = the mouseH - pSprLeft
  sprY = the mouseV - pSprTop
  mbrX = integer(sprX * pSprScalarX) - 1
  mbrY = integer(sprY * pSprScalarY) - 1
  ----
  --  a = the ticks
  me.mFlood(mbrX, mbrY, fillColor)
  --  put the ticks - a
end

---------------

on mFlood me, aX, aY, aSourceColor
  targetColor = pPctRef.getPixel(aX, aY)
  pPctRef.setPixel(aX, aY, aSourceColor)
  append pPixelActorListX, aX
  append pPixelActorListY, aY
  repeat while count(pPixelActorListX)
    xCur = getAt(pPixelActorListX, 1)
    yCur = getAt(pPixelActorListY, 1)
    deleteAt pPixelActorListX, 1
    deleteAt pPixelActorListY, 1
    repeat with n = 1 to 4
      xTest = xCur + getAt(pSpreadListX, n)
      yTest = yCur + getAt(pSpreadListY, n)
      if pPctRef.getPixel(xTest, yTest) = targetColor then
        pPctRef.setPixel(xTest, yTest, aSourceColor)
        -- updateStage
        append pPixelActorListX, xTest
        append pPixelActorListY, yTest
      end if
    end repeat
  end repeat
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