home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 91 / af091a.adf / af91a3.lzx / prgs / Turtle / snowflake.b < prev    next >
Text File  |  2019-01-20  |  900b  |  51 lines

  1.  
  2. '...Fractal Snowflake.
  3. '...You'll need a large stack (make it 40000 bytes) for this one.
  4.  
  5. sub koch(depth,side)
  6.  if depth = 0 then
  7.    Forward(side)
  8.  else
  9.   koch(depth-1,side\3) : turnLeft(60)
  10.   koch(depth-1,side\3) : turnRight(120)
  11.   koch(depth-1,side\3) : turnLeft(60)
  12.   koch(depth-1,side\3) :
  13.  end if
  14. end sub
  15.   
  16. sub snowflake(depth,side)
  17.  koch(depth,side) : turnRight(120)
  18.  koch(depth,side) : turnRight(120)
  19.  koch(depth,side) : turnRight(120)
  20. end sub
  21.  
  22. screen 1,640,400,2,4
  23. window 1,"Fractal Snowflake",(0,75)-(640,325),6,1
  24. font "topaz",8
  25. color 2,1
  26.  
  27. another$="Y"
  28. while another$="Y"
  29.  cls
  30.  locate 1,1
  31.  input "Enter depth (try 4):   ",depth 
  32.  input "Enter sides (try 250): ",sides 
  33.  
  34.  cls
  35.  
  36.  penup
  37.  setxy 250,225
  38.  pendown
  39.  snowflake(depth,sides)
  40.  
  41.  locate 2,1
  42.  print "Another (y/n)?"
  43.  another$=""
  44.  while another$<>"Y" and another$<>"N"
  45.    another$=ucase$(inkey$)
  46.  wend
  47. wend
  48.  
  49. window close 1
  50. screen close 1
  51.