Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Playing with dragon curve fractal
#6
Hmm, I dimmed p to double and it seems to work ok.  After reading your key input problem I decided to add some keyboard control.  Here's a newer version with some added features.

Press +/- to zoom in and out of fractal.  Press SPACE to jump to a new pattern number (p variable random change).  Press ESC to quit.  I changed drawing to using CIRCLE to make it look more solid while zoomed up.

- Dav

Code: (Select All)
'dragoncurve.bas - v2
'A play on a dragon curve fractal
'Adapted by Dav, OCT/2023

'v2 - New keyboard control. Press +/- to zoom, SPACE resets, ESC ends.

Screen _NewImage(800, 600, 32)
Dim Shared p As Double: p = Rnd: size = 200
Do
    Cls: dragon 400, 300, size, a, 15
    Select Case Inp(&H60)
        Case 13: If size < 1200 Then size = size + 5
        Case 12: If size > 25 Then size = size - 5
        Case 57: p = Rnd
        Case 1: Exit Do
    End Select
    _Limit 15: _Display
    a = a + .15: p = p + .001
Loop


Sub dragon (x, y, size, ang, depth)
    If depth < 1 Then
        'PSet (x, y), _RGBA(50, 150, 255, 50 + Rnd * 200)
        Circle (x, y), size / 3, _RGBA(50, 150, 255, 50 + Rnd * 200)
    Else
        size2 = size / Sqr(2): ang2 = ang - _Pi / p
        dragon x, y, size2, ang + _Pi / p, depth - 1
        dragon x + size2 * Cos(ang), y + size2 * Sin(ang), size2, ang2, depth - 1
    End If
End Sub

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
Playing with dragon curve fractal - by Dav - 10-06-2023, 06:25 PM
RE: Playing with dragon curve fractal - by bplus - 10-06-2023, 08:41 PM
RE: Playing with dragon curve fractal - by Dav - 10-06-2023, 09:08 PM
RE: Playing with dragon curve fractal - by Dav - 10-07-2023, 02:25 AM
RE: Playing with dragon curve fractal - by bplus - 10-07-2023, 12:05 PM
RE: Playing with dragon curve fractal - by Dav - 10-08-2023, 06:21 PM
RE: Playing with dragon curve fractal - by bplus - 10-08-2023, 06:44 PM
RE: Playing with dragon curve fractal - by Dav - 10-08-2023, 07:00 PM
RE: Playing with dragon curve fractal - by Dav - 10-09-2023, 12:23 AM



Users browsing this thread: 3 Guest(s)