Versionsvergleich

Aus ProgrammingWiki

Vergleich: 2016-06-02T07:29:14+00:00 → 2016-06-09T07:51:43+00:00

<language>Javascript</language>
'''Diese Seite soll Quadrate zeichnen'''
Wir brauchen ein Zeichenfeld (Canvas)
Wir brauchen den Code für das Zeichnen eines Quadraten
<canvas></canvas>
+
Ich möchte einen Befehl QUADRAT haben 
+
<code id="5759200f08c86">
+
function quadrat(a){
+
    turtle.forward(a);
+
     turtle.right(90);
+
     turtle.forward(a);
+
    turtle.right(90);
+
    turtle.forward(a);
+
    turtle.right(90);
+
    turtle.forward(a);
+
    turtle.right(90);
+
       }
−
<run id="574fe04ac74cd">   
+
function rechteck(a,b){
+
	turtle.forward(a);  
+
  	 turtle.right(90);
+
turtle.forward(b);  
+
  	 turtle.right(90);
+
turtle.forward(a);  
+
  	 turtle.right(90);
+
turtle.forward(b);  
+
 	  turtle.right(90);
+
}
+
+
function dreieck(a){
+
	turtle.forward(a);  
+
  	 turtle.right(120);
+
turtle.forward(a);  
+
  	 turtle.right(120);
+
turtle.forward(a);  
+
  	 turtle.right(120);
+
}
+
+
+
+
</code>
+
+
Eine Treppe aus Rechtecken
+
+
<run id="5759200f08cf1">   
+
canvas.clear;
turtle.home()   ; 
−
turtle.forward(50);
−
turtle.right(90);
+
rechteck(20,100);
+
turtle.forward(20);
+
rechteck(20,90);
+
turtle.forward(20);
+
rechteck(20,80);
+
turtle.forward(20);
+
rechteck(20,60);
+
turtle.forward(20);
−
turtle.forward(50);
−
turtle.right(90);
−
turtle.forward(50);
−
turtle.right(90);
−
turtle.forward(50);
−
turtle.right(90);
</run>