'Mandelbrot V4 for RunBasic 'Based on LibertyBasic solution 'copy the code and go to runbasic.com 'http://rosettacode.org/wiki/Mandelbrot_set#Liberty_BASIC 'May 2015 (updated 29 Apr 2018) ' 'Note - we only get so much processing time on the server, so the 'graph is computed in three or four pieces ' WindowWidth = 320 'RunBasic max size 800 x 600 WindowHeight = 320 'print zone -2 to 1 (X) 'print zone -1.5 to 1.5 (Y) a = -1.5 'graph -1.5 to -0.75, first "loop" b = -0.75 'adjust for max processor time (y0 for loop below) 'open "Mandelbrot Set" for graphics_nsb_nf as #w not used in RunBasic graphic #w, WindowWidth, WindowHeight '#w "trapclose [quit]" not used in RunBasic '#w "down" not used in RunBasic cls '#w flush() #w cls("black") render #w '#w flush() input "OK, hit enter to continue"; guess cls [man_calc] '3/screen size 3/800 = 0.00375 ** 3/790 = 0.0037974 '3/screen size (y) 3/600 = .005 ** 3/590 = 0.0050847 '3/215 = .0139 .0068 = 3/440 cc = 3/299 ' for x0 = -2 to 1 step cc for y0 = a to b step cc x = 0 y = 0 iteration = 0 maxIteration = 255 while ( ( x *x +y *y) <=4) and ( iteration maxIteration then c =iteration else c =0 end if call pSet x0, y0, c 'scan why scan? (wait for user input) with RunBasic ? next next '#w flush() 'what is flush? RunBasic uses the render command. render #w input "OK, hit enter to continue"; guess cls a = a + 0.75 b = b + 0.75 if b > 1.6 then goto[quit] else goto[man_calc] sub pSet x, y, c xScreen = 5+(x +2) /3 * 300 'need positive screen number yScreen = 5+(y +1.5) /3 * 300 'and 5x5 boarder if c =0 then col$ ="red" else if c mod 2 =1 then col$ ="lightgray" else col$ ="white" end if #w "color "; col$ #w "set "; xScreen; " "; yScreen end sub [quit] 'cls print print "This is a Mandelbrot Graph output from www.runbasic.com" render #w print "All done, good bye." end