Turtle snow fall: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 18: | Line 18: | ||
function snowflake(size, level) { | function snowflake(size, level) { | ||
for (var i=0;i<3) { | for (var i=0; i<3; i++) { | ||
side(size, level); | side(size, level); | ||
t.rt(120); | t.rt(120); | ||
Line 82: | Line 82: | ||
function snowflake(size, level) { | function snowflake(size, level) { | ||
for (var i=0;i<3) { | for (var i=0; i<3; i++) { | ||
side(size, level); | side(size, level); | ||
t.rt(120); | t.rt(120); |
Revision as of 17:33, 29 October 2009
References
The source code
function side(size, level) {
if (level==0) {
t.fd(size);
} else {
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) {
for (var i=0; i<3; i++) {
side(size, level);
t.rt(120);
}
}
t.ht();
function snow() {
counter++;
if (counter>500) {
counter = 0;
t.cs();
}
t.setPos(Math.random()*600-300,Math.random()*600-300);
snowflake(30*Math.random(),Math.floor(Math.random()*4));
active = setTimeout(snow,200);
}
t.setPenColor('#ffff00');
counter = 0;
snow();