11-29-2005, 09:34 AM
Code:
SUB MakeRecursiveFunction(kind)
code(kind)
if AllKindsDone THEN RETURN -1
FUNCTION=MakeRecursiveFunction(NewKind)
END SUB
Needless to say, I have found out the magic of recursive functions and am still learning, lol. As well as that Koch Curve, I made two filling functions, one of which works on only circles and the other which doesn't like large areas.
Keep this one in a small shape
Code:
screenres 640,480
declare sub fill(x AS INTEGER, y AS INTEGER,c AS INTEGER)
circle (320,240),92,1
fill(320,240,1)
sleep
sub fill(x AS INTEGER, y AS INTEGER,c)
if point(x,y)<>0 THEN EXIT SUB
PSET(x,y),c
fill(x-1,y,c)
fill(x,y+1,c)
fill(x+1,y,c)
fill(x,y-1,c)
end sub
Fill a Circle
Code:
DECLARE SUB CircleFilled(x AS INTEGER, y AS INTEGER, r AS INTEGER, c AS INTEGER)
DECLARE SUB Fill(x AS INTEGER, y AS INTEGER, c AS INTEGER)
DECLARE FUNCTION FindEdge(x AS INTEGER, y AS INTEGER, d AS INTEGER)
SCREENRES 640,480,8
CircleFilled(320,240,250,2)
SLEEP
SUB CircleFilled(x AS INTEGER, y AS INTEGER, r AS INTEGER, c AS INTEGER)
CIRCLE (x,y),r,c
Fill(x,y,c)
END SUB
SUB Fill(x AS INTEGER, y AS INTEGER, c AS INTEGER)
IF y < 0 OR y > 479 THEN EXIT SUB
IF POINT(x,y) <> 0 THEN EXIT SUB
LINE (findedge(x,y,-1),y)-(findedge(x,y,1),y),c
Fill(x,y-1,c)
Fill(x,y+1,c)
END SUB
FUNCTION FindEdge(x AS INTEGER, y AS INTEGER, d AS INTEGER)
IF POINT(x,y) <> 0 THEN RETURN x
FUNCTION=FindEdge(x+d,y,d)
END FUNCTION