Here"s a little "fill" behavior using get/set pixel. Its pretty slow for anything larger than 100 px square since each pixel is checked for color. On the other hand, drawing directly into a bitmap an arbitrary pixel at a time is fast.
--------- change selected color in bitmap to random color
--------- Roy Pardi
--------- rpardi@rcn.com
--------- www.roypardi.com
on beginSprite me
pMem = sprite(spriteNum).member
pWidth = pMem.width - 1
pHeight = pMem.height -1
end
on mouseDown me
fillColor = random(16777216)
changeColor = getPixelColor(me)
cursor 4
repeat with V = 0 to pHeight
repeat with H = 0 to pWidth
testColor = pMem.getPixel(H,V)
if testColor = changeColor then
pMem.setPixel(H, V, fillColor)
end if
end repeat
end repeat
updatestage
cursor -1
end
on getPixelColor me
mTop = (the mouseLoc).locV
mLeft = (the mouseLoc).locH
top = sprite(spriteNum).rect.top
left = sprite(spriteNum).rect.left
sLeft = mLeft-left
sTop = mTop-top
return pMem.getPixel(sLeft,sTop)
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA