Difference between revisions of "Programming turtle graphics"

From JSXGraph Wiki
Jump to navigationJump to search
Line 17: Line 17:
 
* t.setPenColor(col); (col: colorString, e.g. 'red' or '#ff0000')
 
* t.setPenColor(col); (col: colorString, e.g. 'red' or '#ff0000')
  
===Interaction===
+
===Input===
 
<html>
 
<html>
 
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
 
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
Line 27: Line 27:
 
<input type="button" value="run" onClick="run()">
 
<input type="button" value="run" onClick="run()">
 
</form>
 
</form>
 +
</html>
 +
===Output===
 +
<html>
 
<div id="box" class="jxgbox" style="width:600px; height:600px;"></div>
 
<div id="box" class="jxgbox" style="width:600px; height:600px;"></div>
 
<script language="JavaScript">
 
<script language="JavaScript">
Line 38: Line 41:
 
</script>
 
</script>
 
</html>
 
</html>
 +
===Log window===
 +
<source lang="javascript">
 +
</source>

Revision as of 12:25, 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