Added in flood fill (uses the middle mouse button for now), Though once in a great while it will only fill 1/2 the object (any thoughts?).
sync on
set display mode 800,600,32
dim color(11,15) as dword
undo_level=10
type imagepoint
xpos as integer
ypos as integer
endtype
dim color_check(-1) as imagepoint
for a = 0 to 11
for b = 0 to 15
read color(a,b)
next b
next a
create bitmap 1,20,20
for a = 0 to 19
for b = 0 to 19
read x
ink x,0
dot b,a
next b:next a
get image 1,0,0,19,19,1
delete bitmap 1
ink rgb(212,209,201),0
box 0,0,165,screen height()
ink rgb(255,255,255),0
box 2,2,161,121
box 170,5,screen width()-5,screen height()-5
for a = 0 to 11
for b = 0 to 15
ink color(a,b),0
box b*10+2,a*10+2,b*10+11,a*10+11
next b
next a
paste image 1,5,220
drawing=1
do
box 2,170,32,200
mx=mousex():my=mousey()
ucm=mouseclick()
if drawing=1 and ucm=0
drawing=0
inc undo_level
if undo_level>30
shift_undo()
undo_level=30
endif
get image undo_level,170,5,screen width()-5,screen height()-5,1
endif
if mx>169 and mx<screen width()-4 and my>4 and my<screen height()-4
if ucm=1
if drawing=1 then line oldmx,oldmy,mx,my
dot mx,my
oldmx=mx:oldmy=my:drawing=1
else
drawing=0
endif
endif
if ucm=2
color5=point(mousex(),mousey())
ink color5,0
endif
if ucm=4
color_test=point(mx,my)
flood(mx,my,color5,color_test)
repeat
until mouseclick()=0
endif
if keystate(29)=1 and keystate(44)=1 and undo_level>10 and image exist(undo_level-1)
paste image undo_level-1,170,5
dec undo_level
delete image undo_level+1
repeat
until scancode()=0
endif
sync
loop
`palette
data 16777215,5063201,4672801,3624225,2575649,2182444,2182460,2182476,2178381,2174285,2498893,3613005,4661581,5054786,5054770,5054754
data 5713687,5719831,5199639,3626775,2053911,1529638,1529663,1529687,1523799,1517399,1972055,3544919,5183319,5707592,5707568,5707544
data 6433804,6441996,5792268,3629580,1532428,811553,811585,811618,803426,795234,1444962,3542114,5639266,6425678,6425645,6425613
data 7153921,7164417,6319361,3632385,1010945,93467,93508,93548,83309,73069,917869,3539309,6160749,7143763,7143723,7143683
data 10052419,10060611,9410883,7248195,5151043,4430168,4430200,4430233,4422041,4413849,5063577,7160729,9257881,10044293,10044260,10044228
data 11492909,11505197,10465069,7253805,4108077,2993997,2994045,2994094,2981807,2969519,3943855,7155119,10300847,11480464,11480416,11480367
data 12867608,12884248,11519000,3064856,7324696,1623106,1623171,1623235,1607108,1590468,2889924,7084228,11344068,12851355,12851291,12851226
data 14308098,14328834,12573186,7330306,2021890,186935,187016,187096,166874,146138,1770202,7078618,12321498,14287527,14287446,14287365
data 14325872,14335856,13490800,10869360,8313456,7395978,7396018,7396057,7386074,7375834,8155354,10776794,13332698,14315713,14315673,14315634
data 15504222,15517790,14347358,10873950,7466078,6220929,6220982,6221035,6207724,6194156,7298796,10772204,14180076,15490762,15490709,15490656
data 16617293,16634189,15269197,10943821,6618445,5111160,5111226,5111292,5094653,5077757,6376957,10702333,15027709,16600531,16600465,16600399
data 12566463,11711154,10921638,10066329,9211020,8421504,7566195,6710886,5855577,5000268,4210752,3355443,2500134,1710618,855309,0
`penciltool
data 13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,0,0,0,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,0,12517376,12517376,12517376,0,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,0,12517376,16777215,16777215,0,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,0,0,12517376,16777215,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,0,12636233,0,0,0,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,13947080,16777215,0,12636233,11649842,10465069,0,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,16777215,13947080,0,12636233,11649842,0,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,13947080,0,12636233,11649842,10465069,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,16777215,0,11649842,10465069,0,0,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,0,12636233,11649842,10465069,0,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,0,0,10465069,0,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,0,0,0,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,0,0,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,0,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,0,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
data 13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,13947080
data 16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080,16777215,13947080
function shift_undo()
for a = 11 to 30
make memblock from image a,a
next a
for a=11 to 29
make image from memblock a,a+1
delete memblock a+1
next a
endfunction
function flood(xpos,ypos,new,old)
array insert at top color_check()
color_check(0).xpos=xpos
color_check(0).ypos=ypos
lock pixels
ink new,0
dot xpos,ypos
repeat
for a = array count(color_check()) to 0 step -1
curx=color_check(a).xpos
cury=color_check(a).ypos
edge_reached=0
if point(curx-1,cury)=old
dot curx-1,cury
array insert at bottom color_check()
color_check(array count(color_check())).xpos=curx-1
color_check(array count(color_check())).ypos=cury
else
inc edge_reached
endif
if point(curx+1,cury)=old
dot curx+1,cury
array insert at bottom color_check()
color_check(array count(color_check())).xpos=curx+1
color_check(array count(color_check())).ypos=cury
else
inc edge_reached
endif
if point(curx,cury-1)=old
dot curx,cury-1
array insert at bottom color_check()
color_check(array count(color_check())).xpos=curx
color_check(array count(color_check())).ypos=cury-1
else
inc edge_reached
endif
if point(curx,cury+1)=old
dot curx,cury+1
array insert at bottom color_check()
color_check(array count(color_check())).xpos=curx
color_check(array count(color_check())).ypos=cury+1
else
inc edge_reached
endif
if edge_reached=4
array delete element color_check(),a
endif
next a
until array count(color_check())<0
unlock pixels
endfunction