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
Resizing Flash Sprite to its Original Size
Font Dialog Behavior
Arca Database Xtra
SkyDir
Scuba
Maeda @ Media
Face Mouse-Alphamania
An Unofficial Brief History of Director
Macromedia Director Workshop
Amara Flash Intro and Banner Builder
 

 

 

Behavior Quck Fill

Added on 4/6/2000

 

Compatibilities:
behavior D8 Mac Shockwave

This item has not yet been rated

Author: RadoslawTurek (website)

High speed fill (3-10x speed up from function Jakob Hede Madsen ("Image flood fill")) for a Director 8. This behavior uses setPixel & getPixel

property spriteNum, pGrObject, pMember

on beginSprite me
  pMember = sprite(spriteNum).member
  pGrObject = member(pMember).image
end beginSprite

on mouseUp me
  global vlGame
  tx = the mouseH-sprite(spriteNum).left
  ty = the mouseV-sprite(spriteNum).top
  viC = member(pMember).image.getPixel(tx, ty)
  fvFill(tx, ty, rgb(random(255),random(255),random(255)),viC)
end mouseUp me

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

on fvFill x, y, colorData, colorBack
  seedList = []
  currentSeed = 1
  newUpperSeedFound = TRUE
  newLowerSeedFound = TRUE
  indexPoint = [x:0,y:0]
  
  indexPoint.x = x
  indexPoint.y = y
  
  temp = colorBack
  
  repeat while (pGrObject.getPixel(indexPoint.x, indexPoint.y) = temp)
    indexPoint.x = indexPoint.x-1
  end repeat
  
  indexPoint.x = indexPoint.x+1
  
  repeat while (pGrObject.getPixel(indexPoint.x, indexPoint.y) = temp)
    
    if (pGrObject.getPixel(indexPoint.x, indexPoint.y-1) = temp) then
      if (newUpperSeedFound) then
        add seedList, [x:0,y:0]
        seedList[currentSeed].x = indexPoint.x
        seedList[currentSeed].y = indexPoint.y - 1
        currentSeed = currentSeed + 1
        newUpperSeedFound = FALSE
      end if
    else
      newUpperSeedFound = TRUE
    end if
    
    if (pGrObject.getPixel(indexPoint.x, indexPoint.y+1) = temp) then
      if (newLowerSeedFound) then
        add seedList, [x:0,y:0]
        seedList[currentSeed].x = indexPoint.x
        seedList[currentSeed].y = indexPoint.y + 1
        currentSeed = currentSeed + 1
        newLowerSeedFound = FALSE
      end if
    else
      newLowerSeedFound = TRUE
    end if
    
    indexPoint.x = indexPoint.x+1
    
    if (currentSeed > 120) then
      return 0    
    end if
    
  end repeat
  pGrObject.draw(x, y, indexPoint.x, y,[#shapeType:#line, #lineSize:1, #color: colorData])
  
  i = 1
  repeat while i < currentSeed
    if (fvFill(seedList[i].x, seedList[i].y,colorData,colorBack) = 0) then
      return 0
    end if
    i = i + 1
  end repeat
  
  return 1
end fvFill

 


Contact

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

Send e-mail