GW-BASIC Mandelbrot Set fractal explorer


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. 1 SCREEN 1
  2. 3 PRINT "Basic Mandelbrot Explorer":PRINT
  3. 4 PRINT "2007-2009 Zufolek":PRINT
  4. 5 PRINT "Controls:"
  5. 6 PRINT "8 - Up":PRINT "2 - Down"
  6. 7 PRINT "4 - Left":PRINT "6 - Right"
  7. 9 PRINT "5 - Zoom In":PRINT "0 - Zoom Out"
  8. 11 PRINT "Space Bar - Show Coordinates"
  9. 13 PRINT "i - Change # of Iterations"
  10. 11 PRINT "Esc - Exit"
  11. 15 PRINT:PRINT "More iterations means higher quality but slower display"
  12. 17 PRINT:PRINT "Press any key to start"
  13. 19 IF INKEY$="" THEN 19
  14. 20 N=40
  15. 30 OX=2:OY=1:OU=100
  16. 50 CLS
  17. 100 D=N/4
  18. 400 FOR X = 0 TO 319
  19. 500 FOR Y = 0 TO 199
  20. 505 X1=X/OU-OX:XX=X1
  21. 510 Y1=Y/OU-OY:YY=Y1
  22. 515 X2 = XX*XX
  23. 520 Y2 = YY*YY
  24. 525 IT = 0
  25. 535 IF X2 + Y2 > 4 OR IT = N THEN 580
  26. 540 YY = 2*XX*YY + Y1
  27. 545 XX = X2 - Y2 + X1
  28. 550 X2 = XX*XX
  29. 555 Y2 = YY*YY
  30. 560 IT = IT + 1
  31. 565 GOTO 535
  32. 580 A=IT-INT(IT/4)*4
  33. 600 PSET(X,Y),A
  34. 700 NEXT Y:Z$=INKEY$:IF Z$>"" THEN 854
  35. 800 NEXT X
  36. 849 IF INKEY$>"" THEN 849
  37. 850 Z$=INKEY$
  38. 852 IF Z$="" THEN 850
  39. 854 IF Z$="4" THEN OX=OX+80/OU:GOTO 400
  40. 856 IF Z$="6" THEN OX=OX-80/OU:GOTO 400
  41. 858 IF Z$="8" THEN OY=OY+50/OU:GOTO 400
  42. 860 IF Z$="2" THEN OY=OY-50/OU:GOTO 400
  43. 862 IF Z$="5" THEN OU=OU*2:OX=OX-160/OU:OY=OY-100/OU:GOTO 400
  44. 864 IF Z$="0" THEN OX=OX+160/OU:OY=OY+100/OU:OU=OU*.5:GOTO 400
  45. 866 IF Z$="i" THEN LOCATE 1,1:INPUT "Iterations?",N:GOTO 100
  46. 868 IF Z$=" " THEN LOCATE 1,1:PRINT "(";160/OU-OX;",";100/OU-OY;") Zoom";OU/100:GOTO 850
  47. 890 IF Z$=CHR$(27) THEN END
  48. 899 GOTO 850

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.