Turtle Graphics: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 4: Line 4:
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<form><textarea id="input" rows=7 cols=35 wrap="off" style="width:600px">
<form><textarea id="input" rows=7 cols=35 wrap="off" style="width:600px">
function side(size, level) {
    if (level==0) {
        t.fd(size);
        return;
    }
    side(size/3, level-1);
    t.lt(60);
    side(size/3, level-1);
    t.rt(120);
    side(size/3, level-1);
    t.lt(60);
    side(size/3, level-1);
}
function snowflake(size, level) {
    (3).times(function() {
        side(size, level);
        t.rt(120);
    });
}
brd.suspendUpdate();
t.clean();
t.lt(30);
t.setPos(0,-100);
snowflake(250, 4);
brd.unsuspendUpdate();
</textarea><br />
</textarea><br />
<input type="button" value="run" onClick="run()">  
<input type="button" value="run" onClick="run()">  

Revision as of 15:55, 19 December 2008