Difference between revisions of "Programming turtle graphics"

From JSXGraph Wiki
Jump to navigationJump to search
Line 25: Line 25:
 
<form><textarea id="inputtext" rows=3 cols=35 wrap="off" style="width:600px;">t.fd(100);</textarea><br />
 
<form><textarea id="inputtext" rows=3 cols=35 wrap="off" style="width:600px;">t.fd(100);</textarea><br />
 
<input type="button" value="run" onClick="run()">
 
<input type="button" value="run" onClick="run()">
<input type="button" value="clear" onClick="clear()">
+
<input type="button" value="clear" onClick="clearturtle()">
 
<input type="button" value="clear log" onClick="clearlog()">
 
<input type="button" value="clear log" onClick="clearlog()">
 
</form>
 
</form>
Line 44: Line 44:
 
   brd.unsuspendUpdate();
 
   brd.unsuspendUpdate();
 
}
 
}
function clear() {
+
function clearturtle() {
 
   t.cs();
 
   t.cs();
 
   //$('inputtext').value = 't.fd(100);';
 
   //$('inputtext').value = 't.fd(100);';

Revision as of 11:39, 21 December 2008

List of available commands

There is a predefined turtle object t. Therefore, all commands start with t, like t.fd(100);

  • t.forward(len); or t.fd(len);
  • t.back(len); or t.bk(len);
  • t.right(angle); or t.rt(angle); ([math]0\leq angle \leq 360[/math])
  • t.left(angle); or t.lt(angle);
  • t.penUp(); or t.pu();
  • t.penDown(); or t.pd();
  • t.clearScreen(); or t.cs();
  • t.clean();
  • t.setPos(x,y);
  • t.home();
  • t.hideTurtle(); or t.ht();
  • t.showTurtle(); or t.st();
  • t.setPenSize(size); (size: number)
  • t.setPenColor(col); (col: colorString, e.g. 'red' or '#ff0000')

Input


Output

Log window