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 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
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA