var mx, my, md : int
proc fill (x, y : int)
drawdot (x, y, 7)
if whatdotcolor (x + 1, y) = 0 and x < maxx then
fill (x + 1, y)
end if
if whatdotcolor (x - 1, y) = 0 and x > 0 then
fill (x - 1, y)
end if
if whatdotcolor (x, y + 1) = 0 and y < maxy then
fill (x, y + 1)
end if
if whatdotcolor (x, y - 1) = 0 and y > 0 then
fill (x, y - 1)
end if
end fill
proc fillShape
loop
mousewhere (mx, my, md)
exit when md = 1
end loop
fill (mx, my)
end fillShape
proc drawShape
var x, y, oldx, oldy, startx, starty : int
loop
mousewhere (mx, my, md)
exit when md = 1
end loop
oldx := mx
oldy := my
startx := mx
starty := my
loop
mousewhere (mx, my, md)
exit when md = 0
x := mx
y := my
drawline (oldx, oldy, x, y, 7)
oldx := x
oldy := y
end loop
drawline (x, y, startx, starty, 7)
end drawShape
loop
drawShape
fillShape
end loop |