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
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