Draw a Koch curve. See details: Koch curve

 
Const Pi = 4 * Atn(1)
Const RtoD = 180 / Pi
Const DtoR = Pi / 180
 
Dim Shared As Single posX = 260, posY = 90, angulo = 0
 
Screen 19 : Color 0,15
 
Sub kochLado(longitud As Integer, fondo As Integer)
    Dim As Single dx, dy
    If fondo = 0 Then
        dx = Cos(angulo*DtoR) * longitud
        dy = Sin(angulo*DtoR) * longitud
        Line (posX, posY)-(posX+dx, posY+dy), 2
        posX += dx
        posY += dy
    Else
        kochLado(longitud/3.0, fondo-1)
        angulo += 60
        kochLado(longitud/3.0, fondo-1)
        angulo -= 120
        kochLado(longitud/3.0, fondo-1)
        angulo += 60
        kochLado(longitud/3.0, fondo-1)
    End If
End Sub
 
Sub CopoNieveKoch(longitud As Integer, recursionfondo As Integer)
    For i As Integer = 1 To 6
        kochLado(longitud,recursionfondo)
        angulo -= 300
    Next i
End Sub
 
For n As Integer = 0 To 5
    Cls
    Locate 3,4: Print "Copo de nieve de Koch"
    Locate 4,4: Print "Iteracion numero: " & n
    CopoNieveKoch(280, n)
    Sleep 800
Next n
color 4: Locate 6,4: Print "Pulsa una tecla..."
Bsave "Koch_curve.bmp",0
Sleep
End
 