Author Topic: Fractals! : Part 2  (Read 22117 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fractals! : Part 2
« Reply #15 on: February 17, 2021, 12:01:45 pm »
Cant get to Fractals part 1.


I have made some fractals in VB6 which I will try to convert to QB64. (Made fern, circle fractal, pythagoras tree, binary tree)

Sure! Here is the Platinum Edition:
Code: QB64: [Select]
  1. _Title "Ashish Fractals Plus! mods by bplus 2017-10-19, press space to return to menu"
  2. Dim Shared lowX, highX, lowY, highY
  3.  
  4.     Screen 0
  5.     Cls
  6.     cp 2, "Fractal Menu:"
  7.     lp 4, 25, " 1 Circle"
  8.     lp 5, 25, " 2 Arc"
  9.     lp 6, 25, " 3 Tree"
  10.     lp 7, 25, " 4 Quad"
  11.     lp 8, 25, " 5 Quad & Circle"
  12.     lp 9, 25, " 6 Squares forming triangle"
  13.     lp 10, 25, " 7 Sierpinski Carpet"
  14.     lp 11, 25, " 8 Kite"
  15.     lp 12, 25, " 9 Dragon"
  16.     lp 13, 25, "10 Triangle of Circles"
  17.     lp 14, 25, "11 Vicsek"
  18.     lp 15, 25, "12 Circle Illusion?"
  19.     lp 16, 25, "13 Sierpinski Triangle"
  20.     lp 17, 25, "14 Plus, another variation"
  21.     lp 18, 25, "15 Sierpinski Fies a Kite"
  22.     lp 20, 25, "16 Exit"
  23.     Locate 22, 20
  24.     Input "Enter the menu number of your choice "; menu
  25.  
  26.     Select Case menu
  27.         Case 1: CircleFrac
  28.         Case 2: arcFrac
  29.         Case 3: treeFrac
  30.         Case 4: quadFrac
  31.         Case 5: qncFrac
  32.         Case 6: tnsFrac
  33.         Case 7: sierCarFrac
  34.         Case 8: KiteFrac
  35.         Case 9: dragonFrac
  36.         Case 10: TofCsFrac
  37.         Case 11: VicsekFrac
  38.         Case 12: cIllusFrac
  39.         Case 13: SierTriFrac
  40.         Case 14: PlusFrac
  41.         Case 15: SierFliesKiteFrac
  42.         Case 16: End
  43.     End Select
  44.  
  45. Sub arcFrac
  46.     Screen _NewImage(800, 600, 32)
  47.     r = 40
  48.     needUpdate = 1
  49.     Do
  50.         If _KeyDown(32) Then Exit Sub
  51.         If _KeyDown(Asc("w")) Then r = r + s: needUpdate = 1
  52.         If _KeyDown(Asc("s")) And r > 2 Then r = r - s: needUpdate = 1
  53.         If needUpdate = 1 Then
  54.             needUpdate = 0
  55.             ttl "Arc Fractal, Press 'w' and 's' to zoom-in and zoom-out, space to return to Menu"
  56.             drawArc 400, 300, r, 1
  57.             _Display
  58.             Cls
  59.         End If
  60.         _Limit 60
  61.         s = map(r, 1, 10000, 1, 300)
  62.     Loop
  63.  
  64. Sub CF (x, y, r)
  65.     Circle (x, y), r
  66.     If r > 2 Then
  67.         CF x + r, y, r / 2
  68.         CF x - r, y, r / 2
  69.     End If
  70.  
  71. Sub cIll (x, y, r)
  72.     Line (x, y)-(x - r, y)
  73.     Line (x, y)-(x + r, y)
  74.     Line (x, y)-(x, y - r)
  75.     Line (x, y)-(x, y + r)
  76.     If r > 21 Then
  77.         cIll (x - r) + r / 3, y, r / 2
  78.         cIll (x + r) - r / 3, y, r / 2
  79.         cIll x, (y + r) - r / 3, r / 2
  80.         cIll x, (y - r) + r / 3, r / 2
  81.     End If
  82.  
  83. Sub cIllusFrac
  84.     'Coded By Ashish with <3
  85.     'Can you observe circle in this fractal!? (no, sorry)
  86.     'I was able to do so... :D
  87.     Screen _NewImage(800, 600, 32)
  88.     cIll 400, 300, 200
  89.     ttl "Circle with 4 line variation, Illusion? press any..."
  90.     _Display
  91.     Sleep
  92.  
  93. Sub CircleFrac
  94.     'Idea from  [youtube]https://youtu.be/jPsZwrV9ld0[/youtube]
  95.     Screen _NewImage(800, 600, 32)
  96.     r = 50
  97.     needUpdate = 1
  98.     Do
  99.         If _KeyDown(32) Then Exit Sub
  100.         If _KeyDown(Asc("w")) Then r = r + s: needUpdate = 1
  101.         If _KeyDown(Asc("s")) And r > 2 Then r = r - s: needUpdate = 1
  102.         If needUpdate = 1 Then
  103.             needupadte = 0
  104.             ttl "Circle Fractal, Press 'w' and 's' to zoom-in and zoom-out, space to return to Menu"
  105.             CF 400, 300, r
  106.             _Display
  107.             Cls
  108.         End If
  109.         s = map(r, 1, 10000, 1, 300)
  110.         _Limit 60
  111.     Loop
  112.  
  113. Sub cp (r%, txt$)
  114.     Locate r%, (80 - Len(txt$)) / 2: Print txt$
  115.  
  116. 'Calculate the distance between two points.
  117. Function dist! (x1!, y1!, x2!, y2!)
  118.     dist! = Sqr((x2! - x1!) ^ 2 + (y2! - y1!) ^ 2)
  119.  
  120. Sub dragonFrac
  121.     Screen _NewImage(800, 600, 32)
  122.     drawDragon 400, 300, 400, 300, 60, Rnd * _Pi(2), Rnd * 255, Rnd * 255, Rnd * 255
  123.     ttl "Dragon Curve Fractal, press any except space for more..."
  124.     _Display
  125.     Sleep
  126.     Do
  127.         If _KeyDown(32) Then Exit Sub
  128.         xx = Rnd * _Width
  129.         yy = Rnd * _Height
  130.         drawDragon xx, yy, xx, yy, 60, Rnd * _Pi(2), Rnd * 255, Rnd * 255, Rnd * 255 ': f = 0
  131.         Line (0, 0)-(_Width, _Height), _RGBA(0, 0, 0, 30), BF
  132.         f = f + 1
  133.         ttl "Dragon Curve Fractal, press space to exit"
  134.         _Display
  135.         _Limit 60
  136.     Loop
  137.  
  138. Sub drawArc (x, y, r, f)
  139.     If f = 1 Then
  140.         Circle (x, y), r, , 0, _Pi
  141.     Else
  142.         Circle (x, y), r, , _Pi, _Pi(2)
  143.     End If
  144.     If r > 2 Then
  145.         If f = 1 Then e = 0 Else e = 1
  146.         drawArc x + r, y, r / 2, e
  147.         drawArc x - r, y, r / 2, e
  148.     End If
  149.  
  150. Sub drawDragon (cx, cy, x, y, r, a, mR, mG, mB)
  151.     d = dist(x, y, cx, cy)
  152.     Color _RGB(map(d, 0, 200, mR, 0), map(d + y, y, d + y, 0, mG), map(d, 0, 200, 0, mB))
  153.     fcirc x, y, r
  154.     If r > 1 Then
  155.         drawDragon cx, cy, x + r * 1.75 * Cos(a), y + r * 1.75 * Sin(a), r * 0.75, a - 0.62, mR, mG, mB
  156.         drawDragon cx, cy, x + r * 1.75 * Cos(a + _Pi), y + r * 1.75 * Sin(a + _Pi), r * 0.75, (a + _Pi) - 0.62, mR, mG, mB ')+_PI
  157.     End If
  158.  
  159. Sub drawKite (x, y, s, a)
  160.     Line (x, y)-(x + s * Cos(_Pi(2) - a), (y - s) + s * Sin(_Pi(2) - a))
  161.     Line (x, y)-(x + s * Cos(_Pi + a), (y - s) + s * Sin(_Pi + a))
  162.     If s > 1 Then
  163.         drawKite x + s * Cos(_Pi(2) - a), (y - s) + s * Sin(_Pi(2) - a), s / 2, a
  164.         drawKite x + s * Cos(_Pi + a), (y - s) + s * Sin(_Pi + a), s / 2, a
  165.     End If
  166.  
  167. Sub drawKite2 (xx, yy, s, a)
  168.     x = xx: y = yy
  169.     x2 = x + 3 * s * Cos(_Pi(1 / 2) - a / 2): y2 = y + 3 * s * Sin(_Pi(1 / 2) - a / 2)
  170.     x3 = x + 3 * s * Cos(_Pi(1 / 2) + a / 2): y3 = y + 3 * s * Sin(_Pi(1 / 2) + a / 2)
  171.     SierLineTri x, y, x2, y2, x3, y3, 0
  172.     If s > 10 Then
  173.         drawKite2 x + 1 * s * Cos(_Pi(2) - a), (y - s) + 1 * s * Sin(_Pi(2) - a), s / 2, a
  174.         drawKite2 x + 1 * s * Cos(_Pi + a), (y - s) + 1 * s * Sin(_Pi + a), s / 2, a
  175.     End If
  176.  
  177. Sub drawTree (x, y, r, a, s)
  178.     If r < 14 Then c~& = _RGB(10, 200, 10) Else c~& = _RGB(160, 10, 10)
  179.     internalp5line x, y, x + r * Cos(a - s), y + r * Sin(a - s), r / 10, c~&
  180.     internalp5line x, y, x + r * Cos(a + s * 3), y + r * Sin(a + s * 3), r / 10, c~&
  181.     If r > 2 Then
  182.         drawTree x + r * Cos(a - s), y + r * Sin(a - s), r * 0.67, a - s, s
  183.         drawTree x + r * Cos(a + s * 3), y + r * Sin(a + s * 3), r * 0.67, a + s * 3, s
  184.     End If
  185.  
  186. 'Steve McNeil's  copied from his forum   note: Radius is too common a name
  187. Sub fcirc (CX As Long, CY As Long, R As Long)
  188.     Dim subRadius As Long, RadiusError As Long
  189.     Dim X As Long, Y As Long
  190.     subRadius = Abs(R)
  191.     RadiusError = -subRadius
  192.     X = subRadius
  193.     Y = 0
  194.     If subRadius = 0 Then PSet (CX, CY): Exit Sub
  195.     ' Draw the middle span here so we don't draw it twice in the main loop,
  196.     ' which would be a problem with blending turned on.
  197.     Line (CX - X, CY)-(CX + X, CY), , BF
  198.     While X > Y
  199.         RadiusError = RadiusError + Y * 2 + 1
  200.         If RadiusError >= 0 Then
  201.             If X <> Y + 1 Then
  202.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), , BF
  203.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), , BF
  204.             End If
  205.             X = X - 1
  206.             RadiusError = RadiusError - X * 2
  207.         End If
  208.         Y = Y + 1
  209.         Line (CX - X, CY - Y)-(CX + X, CY - Y), , BF
  210.         Line (CX - X, CY + Y)-(CX + X, CY + Y), , BF
  211.     Wend
  212.  
  213. 'taken from QB64's p5.js
  214. 'http://bit.ly/p5jsbas
  215. Sub internalp5line (x0!, y0!, x1!, y1!, s!, col~&)
  216.     dx! = x1! - x0!
  217.     dy! = y1! - y0!
  218.     d! = Sqr(dx! * dx! + dy! * dy!)
  219.     For i = 0 To d!
  220.         Color col~&
  221.         fcirc x0! + dxx!, y0! + dyy!, s!
  222.         dxx! = dxx! + dx! / d!
  223.         dyy! = dyy! + dy! / d!
  224.     Next
  225.  
  226. Sub KiteFrac
  227.     Screen _NewImage(800, 600, 32)
  228.     ttl "Kite Fractal, press any"
  229.     drawKite 400, 500, 140, .5
  230.     _Display
  231.     Sleep
  232.  
  233. Sub lp (r%, c%, txt$)
  234.     Locate r%, c%: Print txt$
  235.  
  236. 'taken from QB64's p5.js
  237. 'http://bit.ly/p5jsbas
  238. Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  239.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  240.  
  241. Sub Plus (x, y, r)
  242.     'variation BF, B, B, BF
  243.     'variation #2 BF, BF, BF, BF
  244.     'variation #3 B, B, B, B
  245.     'How many plus can you find?
  246.     Color _RGB(r, 255 - r, 255 - r)
  247.     Line (x, y)-(x - r, y - r), , BF
  248.     Line (x, y)-(x + r, y - r), , B
  249.     Line (x, y)-(x - r, y + r), , B
  250.     Line (x, y)-(x + r, y + r), , BF
  251.     If r > 6 Then
  252.         Plus x - r / 2, y - r / 2, r / 2.3
  253.         Plus x + r / 2, y - r / 2, r / 2.3
  254.         Plus x - r / 2, y + r / 2, r / 2.3
  255.         Plus x + r / 2, y + r / 2, r / 2.3
  256.     End If
  257.  
  258. Sub PlusFrac
  259.     'playing with Ashish circle with 4 line by bplus 2017-10-16
  260.     Screen _NewImage(800, 600, 32)
  261.     Plus 400, 300, 290
  262.     ttl "Plus, another variation "
  263.     _Display
  264.     Sleep
  265.  
  266. Sub qncFrac
  267.     Screen _NewImage(800, 600, 32)
  268.     r = 100
  269.     needupdate = 1
  270.     Do
  271.         If _KeyDown(32) Then Exit Sub
  272.         If _KeyDown(Asc("w")) Then r = r + s: needupdate = 1
  273.         If _KeyDown(Asc("s")) And r > 2 Then r = r - s: needupdate = 1
  274.         If needupdate = 1 Then
  275.             needupdate = 0
  276.             ttl "Quad Inside Circle Inside Quad, press w to widen, s to shrink, space to exit"
  277.             quad_circle 400, 300, 0, 0, r, 0
  278.             _Display
  279.             Cls
  280.             s = map(r, 1, 10000, 1, 300)
  281.         End If
  282.         _Limit 40
  283.     Loop
  284.  
  285. Sub quad_circle (x, y, x2, y2, r, e)
  286.     If e = 1 Then
  287.         Line (x, y)-(x2, y2), , B
  288.     Else
  289.         Circle (x, y), r
  290.     End If
  291.     If r > 2 Then
  292.         If e = 1 Then
  293.             If x2 > x Then newR = x2 - x Else newR = x - x2
  294.             quad_circle (x + x2) / 2, (y + y2) / 2, 0, 0, newR / 2, 0
  295.         Else
  296.             tx1 = x + r * Cos(_Pi - .7)
  297.             ty1 = y + r * Sin(_Pi - .7)
  298.             tx2 = x + r * Cos(_Pi(2) - .7)
  299.             ty2 = y + r * Sin(_Pi(2) - .7)
  300.             quad_circle tx1, ty1, tx2, ty2, r / 2, 1
  301.         End If
  302.     End If
  303.  
  304. Sub quad_fractal (x, y, r, e)
  305.     If _KeyDown(32) Then Exit Sub
  306.     Line (x - r, y - r)-(x + r, y - r)
  307.     Line (x + r, y - r)-(x + r, y + r)
  308.     Line (x + r, y + r)-(x - r, y + r)
  309.     Line (x - r, y + r)-(x - r, y - r)
  310.     If r > e Then
  311.         quad_fractal x - r, y - r, r / 2, e
  312.         quad_fractal x + r, y - r, r / 2, e
  313.         quad_fractal x + r, y + r, r / 2, e
  314.         quad_fractal x - r, y + r, r / 2, e
  315.     End If
  316.  
  317. Sub quadFrac
  318.     Screen _NewImage(800, 600, 32)
  319.     k = 100: dir = .5
  320.     Do
  321.         If _KeyDown(32) Then Exit Sub
  322.         Cls
  323.         ttl "Quads!!, press space to exit"
  324.         quad_fractal 400, 300, 100, k
  325.         _Display
  326.         _Limit 2
  327.         k = k * dir
  328.         If k < 2 Then dir = 2
  329.         If k > 100 Then dir = .5
  330.     Loop
  331.  
  332. Sub SC (x, y, r)
  333.     Line (x - r, y - r)-(x + r, y + r), _RGB(map(x, lowX, highX, 0, 255), map(y, lowY, highY, 255, 0), map(x + y, lowX + lowY, highX + highY, 255, 0)), BF
  334.     If r > 3 Then
  335.         v = r * 2
  336.         SC x, y - v, r / 3
  337.         SC x, y + v, r / 3
  338.         SC x + v, y, r / 3
  339.         SC x - v, y, r / 3
  340.         SC x - v, y - v, r / 3
  341.         SC x + v, y + v, r / 3
  342.         SC x - v, y + v, r / 3
  343.         SC x + v, y - v, r / 3
  344.     End If
  345.  
  346. Sub SC0 (x, y, r)
  347.     Line (x - r, y - r)-(x + r, y + r), _RGB(0, 0, 0), BF
  348.     If x - r < lowX Then lowX = x - r
  349.     If x + r > highX Then highX = x + r
  350.     If y - r < lowY Then lowY = y - r
  351.     If y + r > highY Then highY = y + r
  352.     If r > 3 Then
  353.         v = r * 2
  354.         SC0 x, y - v, r / 3
  355.         SC0 x, y + v, r / 3
  356.         SC0 x + v, y, r / 3
  357.         SC0 x - v, y, r / 3
  358.         SC0 x - v, y - v, r / 3
  359.         SC0 x + v, y + v, r / 3
  360.         SC0 x - v, y + v, r / 3
  361.         SC0 x + v, y - v, r / 3
  362.     End If
  363.  
  364. Sub sierCarFrac
  365.     Screen _NewImage(1000, 700, 32)
  366.     lowX = 500
  367.     highX = 500
  368.     highY = 500
  369.     lowY = 500
  370.     Cls , _RGB(255, 255, 255)
  371.     SC0 500, 350, 120
  372.     Line (0, 0)-(lowX, _Height), _RGB(0, 0, 0), BF
  373.     Line (_Width - 1, 0)-(highX, _Height), _RGB(0, 0, 0), BF
  374.     Line (0, 0)-(_Width, lowY), _RGB(0, 0, 0), BF
  375.     Line (0, _Height)-(_Width, highY), _RGB(0, 0, 0), BF
  376.     ttl "Sierpinski_Carpet, press any"
  377.     _Display
  378.     Sleep
  379.     SC 500, 350, 120
  380.     ttl "Sierpinski_Carpet, press any"
  381.     _Display
  382.     Sleep
  383.  
  384. Sub SierFliesKiteFrac
  385.     ' after playing with Ashish Kite Fractal,  by bplus 2017-10-16
  386.     Screen _NewImage(1200, 700, 32)
  387.     While 1
  388.         Cls
  389.         If _KeyDown(32) Then Exit Sub
  390.         drawKite2 600, 540, 200, a
  391.         ttl "Sierpinski flies a Kite, press space to exit"
  392.         _Display
  393.         _Limit 20
  394.         a = a + _Pi(2 / 360)
  395.     Wend
  396.  
  397. Sub SierLineTri (x1, y1, x2, y2, x3, y3, depth)
  398.     If depth = 0 Then 'draw out triangle if level 0
  399.         Line (x1, y1)-(x2, y2)
  400.         Line (x2, y2)-(x3, y3)
  401.         Line (x1, y1)-(x3, y3)
  402.     End If
  403.     'find midpoints
  404.     If x2 < x1 Then mx1 = (x1 - x2) / 2 + x2 Else mx1 = (x2 - x1) / 2 + x1
  405.     If y2 < y1 Then my1 = (y1 - y2) / 2 + y2 Else my1 = (y2 - y1) / 2 + y1
  406.     If x3 < x2 Then mx2 = (x2 - x3) / 2 + x3 Else mx2 = (x3 - x2) / 2 + x2
  407.     If y3 < y2 Then my2 = (y2 - y3) / 2 + y3 Else my2 = (y3 - y2) / 2 + y2
  408.     If x3 < x1 Then mx3 = (x1 - x3) / 2 + x3 Else mx3 = (x3 - x1) / 2 + x1
  409.     If y3 < y1 Then my3 = (y1 - y3) / 2 + y3 Else my3 = (y3 - y1) / 2 + y1
  410.     Line (mx1, my1)-(mx2, my2) '  'draw all inner triangles
  411.     Line (mx2, my2)-(mx3, my3)
  412.     Line (mx1, my1)-(mx3, my3)
  413.     If depth < 4 Then 'not done so call me again
  414.         SierLineTri x1, y1, mx1, my1, mx3, my3, depth + 1
  415.         SierLineTri x2, y2, mx1, my1, mx2, my2, depth + 1
  416.         SierLineTri x3, y3, mx3, my3, mx2, my2, depth + 1
  417.     End If
  418.  
  419. Sub SierTri (x, y, r)
  420.     Line (x + r * Cos(_D2R(330)), y + r * Sin(_D2R(330)))-(x + r * Cos(_D2R(90)), y + r * Sin(_D2R(90)))
  421.     Line (x + r * Cos(_D2R(90)), y + r * Sin(_D2R(90)))-(x + r * Cos(_D2R(210)), y + r * Sin(_D2R(210)))
  422.     Line (x + r * Cos(_D2R(210)), y + r * Sin(_D2R(210)))-(x + r * Cos(_D2R(330)), y + r * Sin(_D2R(330)))
  423.     If r > 4 Then
  424.         SierTri x + r * Cos(_D2R(30)), y + r * Sin(_D2R(30)), r / 2
  425.         SierTri x + r * Cos(_D2R(150)), y + r * Sin(_D2R(150)), r / 2
  426.         SierTri x + r * Cos(_D2R(270)), y + r * Sin(_D2R(270)), r / 2
  427.     End If
  428.  
  429. Sub SierTriFrac
  430.     Screen _NewImage(800, 600, 32)
  431.     SierTri 400, 400, 160
  432.     ttl "Sierpinski Triangle, press any..."
  433.     _Display
  434.     Sleep
  435.  
  436. Sub TofCs (x, y, r, t)
  437.     Color _RGB(Rnd * 255, Rnd * 255, Rnd * 255)
  438.     fcirc x, y, r
  439.     If r > 2 Then
  440.         TofCs x + r * 1.75 * Cos(t), y + r * 1.75 * Sin(t), r * 0.75, t
  441.         TofCs x + r * 1.75 * Cos(_Pi + t), y + r * 1.75 * Sin(_Pi - t), r * 0.75, t
  442.     End If
  443.  
  444. Sub TofCsFrac 'modified for speed as Petr had shown
  445.     Screen _NewImage(1000, 600, 32)
  446.     TofCs 500, 200, 80, .5
  447.     ttl "Triangle Formed By Circle, press any..."
  448.     _Display
  449.     Sleep
  450.  
  451. Sub tns (x, y, r)
  452.     Line (x - r, y - r)-(x + r, y + r), _RGB(Rnd * 255, Rnd * 255, Rnd * 255), BF
  453.     If r > 1 Then
  454.         v = r * 2
  455.         tns x, y - v, r / 2
  456.         tns x + v, y - r * 2, r / 2
  457.         tns x + v, y, r / 2
  458.     End If
  459.  
  460. Sub tnsFrac
  461.     ttl "Square_formed_triangle, press any..."
  462.     Screen _NewImage(800, 600, 32)
  463.     tns 250, 450, 100
  464.     _Display
  465.     Sleep
  466.  
  467. Sub treeFrac
  468.     Screen _NewImage(800, 600, 32)
  469.     radius = 130
  470.     Do
  471.         Cls
  472.         ttl "Fractal_Trees, press space to return to Menu"
  473.         If _KeyDown(32) Then Exit Sub
  474.         drawTree 400, 400, radius, _Pi(3 / 2), s
  475.         internalp5line 400, 600, 400, 400, radius / 10, _RGB(160, 10, 10)
  476.         _Display
  477.         _Limit 40
  478.         s = Abs(Sin(v#)) * 0.25 + 0.2
  479.         v# = v# + 0.01
  480.     Loop
  481.  
  482. Sub ttl (txt$)
  483.     Color _RGB(0, 200, 200)
  484.     lp 2, 5, txt$
  485.     Color _RGB(255, 255, 255)
  486.  
  487. Sub vicsek (x, y, r)
  488.     Line (x, y)-(x - r, y)
  489.     Line (x, y)-(x + r, y)
  490.     Line (x, y)-(x, y - r)
  491.     Line (x, y)-(x, y + r)
  492.     If r > 2 Then
  493.         vicsek x - r, y, r / 3
  494.         vicsek x + r, y, r / 3
  495.         vicsek x, y + r, r / 3
  496.         vicsek x, y - r, r / 3
  497.         vicsek x, y, r / 3
  498.     End If
  499.  
  500. Sub VicsekFrac
  501.     Screen _NewImage(800, 600, 32)
  502.     vicsek 400, 300, 180
  503.     ttl "Vicsek Fractal, press any..."
  504.     _Display
  505.     Sleep
  506.  

Platinum because this Edition has Sierpinsky Flies a Kite a mod of Ashish Kite:
 
Sierpinsky Flies a Kite.PNG
« Last Edit: February 17, 2021, 12:05:03 pm by bplus »