'QO fractal generator version f NoMainWin UpperLeftX = 10 UpperLeftY = 2 WindowWidth = 520 WindowHeight = 530 textbox #1.text, 2, 2, 500, 30 graphicbox #1.graphic, 2, 36, 500, 200 texteditor #1.tedit, 2, 240, 500, 270 button #1.b, "Draw", [doit], UL, 400, 40, 50, 30 open "QO Fractal Generator" for window_nf as #1 print #1, "trapclose [quit]" print #1.graphic, "size 2 ; color black ; cls ; fill white" print #1.tedit, "!font courier_new 8" 'angle = 60 ie PI/2 in radians axiom$ = "F" rule$ = "F-F++F-F" n = 0 PI = 3.14159265 [doit] n =n+1 if n >6 then [quit] totalx = 0 totaly = 0 newrule$ = "" direction = 0 print #1.tedit, "Iteration # "; print #1.tedit, n; print #1.tedit, " & rule = " l =len( axiom$) for k =0 to l/64 print#1.tedit, mid$( axiom$, k, 64) next k for i =1 to len( axiom$) ch$ =mid$( axiom$, i, 1) select case ch$ case "+" direction =direction +PI/3 newrule$ =newrule$ +"+" case "-" direction =direction -PI/3 newrule$ =newrule$ +"-" case "F" newrule$ =newrule$ +rule$ totalx = totalx +cos( direction) totaly = totaly +sin( direction) end select next i op$ ="Total x = " +str$( int( totalx)) +" & total y = " +str$( int( totaly)) print #1.text, op$ ste =440 /totalx xx =10: yy =150: direction =0 print #1.graphic, "up ; goto 10 150 ; down ; north; turn 90 ; size 1" print #1.graphic, "color "; str$( 35 *n); " "; str$( 255 -35*n); " 0" for i =1 to len( axiom$) in$ =mid$( axiom$, i, 1) select case in$ case "F" xx =xx +ste *cos( direction) yy =yy +ste *sin( direction) case "+" direction =direction +PI/3 case "-" direction =direction -PI/3 end select #1.graphic, "goto "; str$( int( xx)); " "; str$( int( yy)) #1.graphic, "flush" next i axiom$ =newrule$ for y =0 to 100000 ' next y Wait end [quit] Close #1 End