load ('fractal.lefty');
fractal = function (level, length, angle) {
    local nlength, newpenpos;

    if (level >= maxlevel) {
        newpenpos.x = penpos.x + length * cos (angle);
        newpenpos.y = penpos.y + length * sin (angle);
        if (count < maxcount) {
            line (canvas, null, penpos, newpenpos);
            count = count + 1;
        }
        penpos = newpenpos;
        return;
    }
    nlength = length / 3;
    fractal (level + 1, nlength, angle);
    fractal (level + 1, nlength, angle + 60);
    fractal (level + 1, nlength, angle - 60);
    fractal (level + 1, nlength, angle);
};
maxlevel = 2;
count = 0;
maxcount = 48;
drawfractal ();
transformfractal (['x' = 200; 'y' = 50;], ['x' = 250; 'y' = 100;]);
count = 0;
drawfractal ();
count = 0;
dops ();
