Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Generic Countdown Timer
Go Marker
Wait for a cuepoint
PDF export: text and vector shapes
Macromedia Director Game Development: From Concept to Creation
3D SpeedPort Xtra
Text Pop Up
FlashMaster
Create a Shortcut on desktop
APresentationTrakker Xtra
MediaMacros Xtras Mall
 

 

 

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

 


Upload Provided by ABCUpload ASP

Contact

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

Fax - (206) 339-5833

Send e-mail