Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2014-05-23T09:42:56+00:00 → 2014-05-24T06:51:03+00:00
<language>Java</language> | |
<table border="0" cellpadding="0" cellspacing="10"> | |
<tr> | |
<td> | |
'''Nikolaushaus''' | |
<canvas w="400" h="300"></canvas> | |
</td> | |
<td> | |
'''Treppe''' | |
<canvas w ="400" h="300"></canvas> | |
</tr> | |
<tr> | |
<td align="center" valign="top"> | |
<code id="5375dc9278fa0"> | |
public void nikolaus(double x) { | |
double c = Math.sqrt(2) * x; | |
for (i=1, i<=n, i++){ | |
turtle1.forward(x); | |
turtle1.right(45); | |
turtle1.forward(c/2); | |
turtle1.right(90); | |
turtle1.forward(c/2); | |
turtle1.right(135); | |
turtle1.forward(x); | |
turtle1.left(45); | |
turtle1.forward(c); | |
turtle1.right(135); | |
turtle1.forward(x); | |
turtle1.right(135); | |
turtle1.forward(x); | |
turtle1.right(135); | |
turtle1.forward(c); | |
turtle1.right(135); | |
turtle1.forward(x); | |
} | |
} | |
</code> | |
<run id="5375d9ac13e01"> | |
canvas.clear(); | |
turtle1.move(1,299); | |
nikolaus(50); | |
</run> | |
</td> | |
<td align="center" valign="top"> | |
<code id="5375dc9279033"> | |
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> | |
<run id="5375d9ac13eae"> | |
canvas2.clear(); | |
turtle2.move(200,150); | |
treppe(40, 3); | |
</run> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
'''Pentagramm''' | |
</td> | |
<td> | |
'''Rosette''' | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<canvas w ="400" h="300"></canvas> | |
</td> | |
<td> | |
<canvas w ="400" h="300"></canvas> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<code id="5375dc92790bf"> | |
public void pentagram(int x) { | |
turtle3.right(144); | |
for (i=1; i<=5; i++){ | |
turtle3.forward(x); | |
turtle3.right(144); | |
} | |
} | |
</code> | |
<run id="5375d9ac13f3e"> | |
canvas3.clear(); | |
turtle3.move(200,150); | |
pentagram(100); | |
</run> | |
</td> | |
<td> | |
<code id="5375dc927913b"> | |
public void rosette (double x, int m, int n) { | |
for (int i=1; i<=n; i++) { | |
turtle4.right(360/n+1); | |
n_eck(x,m); | |
} | |
} | |
public void n_eck (double x, int m) { | |
for (int i=1; i<=m; i++) { | |
turtle4.forward(x); | |
turtle4.right(360/m); | |
} | |
} | |
</code> | |
<run id="5375d9ac13fbc"> | |
canvas4.clear(); | |
turtle4.move(200,150); | |
rosette(50,5,50); | |
</run> | |
</td> | |
</tr> | |
</table> | |
| − | <language>Java</language> |
| + | |
===Zickzacklinie=== | |
<code id="537e0a635407e"> | |
public void zickzacklinie (Object turtle, double x, int n) { | |
for (int i = 1; i <=n; i++){ | |
turtle5.right(45); | |
turtle5.forward(x); | |
turtle5.right(90); | |
turtle5.forward(x); | |
turtle5.right(270); | |
} | |
} | |
</code> | |
<canvas width="750" height="200"></canvas> | |
<run id="537e0a63541ab"> | |
canvas5.clear(); | |
turtle5.move(100,150); | |
zickzacklinie(turtle5, 50, 10) | |
</run> | |
===Strichellinie=== | |
| − | <code id="537e0a635410e"> |
| + | <code id="538041568fc6a"> |
| + | import Canvas; canvas6 = new Canvas(6); turtle6 = new Turtle(6); |
| + | |
public void strichellinie(Object turtle, double x, int n) { | |
| − | for (int i = 1; i <=n; i++) { |
| + | turtle.right(90); |
| + | for (int i = 1; i <= n; i++) { |
turtle.forward(x); | |
turtle.penUp(); | |
turtle.forward(x); | |
turtle.penDown(); | |
} | |
} | |
</code> | |
<canvas width="750" height="200"></canvas> | |
| − | <run id="537e0a6354231"> |
| + | <run id="538041568fd37"> |
canvas6.clear(); | |
turtle6.move(50, 100); | |
| − | strichellinie(turtle2, 40, 12); |
| + | strichellinie(turtle6, 40, 12); |
</run> |