qxgȐ

@r^[gOtBbNXgpqxgȐ`XNvgłB
@s恄http://vivi.dyndns.org/mv/hilbert.swf.html

@"hilbert.vvs":

#include    "turtle.vvs"

function hilbert(tur, n, right)
{
    if( n == 0 ) return;
    tur.turn(right);
    hilbert(tur, n - 1, -right);
    tur.forward(1);
    tur.turn(-right);
    hilbert(tur, n - 1, right);
    tur.forward(1);
    hilbert(tur, n - 1, right);
    tur.turn(-right);
    tur.forward(1);
    hilbert(tur, n - 1, -right);
    tur.turn(right);
}

function main()
{
    newDocument();
    var tur = newTurtle();
    hilbert(tur, 5, 1);
}

@"turtle.vvs":

function forward(step)
{
    var i;
    if( step < 1 ) step = 1;
    if( this.dir == 0 ) {   //  E
        for(i = 0; i<step; ++i)
            vicmd("33153#c");
    } else if( this.dir == 1 ) {    //  
        for(i = 0; i<step; ++i)
            vicmd("33155#c");
    } else if( this.dir == 2 ) {    //  
        for(i = 0; i<step; ++i)
            vicmd("33152#c");
    } else if( this.dir == 3 ) {    //  
        for(i = 0; i<step; ++i)
            vicmd("33154#c");
    }
}

function turn(d)
{
    this.dir += d;
    while( this.dir < 0 )
        this.dir += 4;
    this.dir %= 4;
}

function newTurtle()
{
    var obj;
    obj.dir = 0;    //  0:right, 1:down, 2:left, 3:up
    obj.pen = 1;    //  0:up, 1:down
    obj.forward = forward;
    obj.turn = turn;
    return obj;
}

@s:

(߁)!!!!!