The Dragon Curve

Give the animation of the curve time to cycle!

This is an interesting structure/curve, where each iteration takes you into more, spacefilling detail. Colouring adds to the effect.

LB code used, with variations...


    nomainwin
    mainwin 50 20

    WindowHeight =620
    WindowWidth  =690

    open "Dragon Curve by command string" for graphics_nsb as #a

    #a, "trapclose [quit]"

    #a "down"

    Turn$ ="R"
    Pace  =300
    s     = 16
    j     =  0
    n     =  1

[again]
    print Turn$

    #a "cls ; goto 230 420 ; north ; down ; fill black ; turn -"; 45 *j

    for i =1 to len( Turn$)
        v =255 *i /len( Turn$)
        #a "color "; v; " 120 "; 255 -v
        #a "go "; Pace
        if mid$(  Turn$, i, 1) ="R" then #a "turn 90" else #a "turn -90"
    next i

    #a "color 255 120 0"
    #a "go "; Pace
    #a "flush"

    FlippedTurn$ =""
    for i =len( Turn$) to 1 step -1
        if mid$( Turn$, i, 1) ="R" then FlippedTurn$ =FlippedTurn$ +"L" else FlippedTurn$ =FlippedTurn$ +"R"
    next i

    Turn$ =Turn$ +"R" +FlippedTurn$

    Pace  =max( Pace /1.41, 1)
    j     =j +1

    scan

    timer 1000, [j]
    wait
[j]
    timer 0

    #a "flush"
    #a "getbmp drawing 1 1 620 590"
    bmpsave "drawing", "dragon"; str$( n); ".bmp"
    unloadbmp "drawing"
    n =n +1

    if len( Turn$) <40000 then goto [again]


wait

[quit]
    close #a
    end