Example of Turtle Graphics

Koch Curve

You can change the parameter values appropriately.

Sub DrawKochCurve()
' Get device context handle
    monhdc = GetForegroundWindow()
    myhdc = GetDC(monhdc)
    If myhdc = 0 Then Exit Sub

Dim i, length, N

    N = 4       ' Koch dimension
    length = 60      ' 0-th length

    InitializeGraphics
    
    SetViewPort 10, 10, 489, 489
    SetGraphicsWindow 0, 5000, 5000, 0
    
    TGSetPoint 500, 2000
    TGSetAngle 0
   
    For i = 1 To 3
         Koch N, length
         TGTurn -120
    Next i

End Sub

Sub Koch(N, length)

    If N = 0 Then
        TGMoveL length, QBColor(1)     ' cyan
    Else
        Koch N - 1, length
        TGTurn 60
        Koch N - 1, length
        TGTurn -120
        Koch N - 1, length
        TGTurn 60
        Koch N - 1, length
    End If
    
End Sub

Koch curve

Download source program   tg-kochl-gdi32.bas