Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2014-05-23T09:26:20+00:00 → 2014-05-23T09:26:20+00:00
<language>Java</language> | |
=== Nikolaushaus === | |
<code id="5363a2bd56714"> | |
public void nicolaushaus( double x){ | |
double c = Math.sqrt(2) * x; | |
turtle.forward(x); | |
turtle.right(90); | |
turtle.forward(c/2); | |
} | |
</code> | |
<canvas width="300" height="400"> | |
</canvas> | |
<run id="5363a2bd5678f"> | |
canvas1.clear(); | |
turtle1.move(150,200); | |
nicolaushaus(50); | |
</run> | |
===Treppe=== | |
<code id="5363715f23997"> | |
public void treppe(double x, int n) { | |
for (i=1, i<=n, i++) { | |
turtle2.forward(x); | |
turtle2.right(90); | |
turtle2.forward(x); | |
turtle2.left(90); | |
} | |
turtle2.right(180); | |
turtle2.forward(x*n); | |
turtle2.right(90); | |
turtle2.forward(x*n); | |
} | |
</code> | |
<canvas width="300" height="400"> | |
</canvas> | |
<run id="5363722dd6f19"> | |
canvas2.clear(); | |
turtle2.move(200,150); | |
treppe(40, 3); | |
</run> | |
===Zickzacklinie=== | |
<code id="537e0a635407e"> | |
public void zickzacklinie (Object turtle5, double x, int n) { | |
for (int i = 1; i <=n; i++){ | |
turtle.right(45); | |
turtle.forward(x); | |
turtle.right(90); | |
turtle.forward(x); | |
turtle.right(270); | |
} | |
} | |
</code> | |
<canvas width="500" height="200"></canvas> | |
<run id="537e0a63541ab"> | |
canvas.clear(); | |
turtle.move(100,150); | |
zickzacklinie(turtle5, 50, 10) | |
</run> | |
===Strichellinie=== | |
<code id="537e0a635410e"> | |
public void strichellinie(Object turtle6, double x, int n) { | |
for (int i = 1; i <=n; i++) { | |
turtle.forward(x); | |
turtle.penUp(); | |
turtle.forward(x); | |
Turtle.penDown(); | |
} | |
} | |
</code> | |
<canvas width="500" height="200"></canvas> | |
<run id="537e0a6354231"> | |
canvas.clear(); | |
turtle.move(50, 100); | |
strichellinie(turtle2, 50, 10); | |
</run> |