Turtle Graphics: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary  | 
				A WASSERMANN (talk | contribs) No edit summary  | 
				||
| Line 90: | Line 90: | ||
                     this.board.createElement('line',[this.points[this.points.length-2],p],this.attributes);  |                      this.board.createElement('line',[this.points[this.points.length-2],p],this.attributes);  | ||
                 }  |                  }  | ||
                 this.board.update();  |                  //this.board.update();  | ||
             };  |              };  | ||
| Line 101: | Line 101: | ||
                 var t = this.board.createElement('transform', [-angle*Math.PI/180.0,this.turtle], {type:'rotate'});  |                  var t = this.board.createElement('transform', [-angle*Math.PI/180.0,this.turtle], {type:'rotate'});  | ||
                 t.applyOnce(this.turtle2);  |                  t.applyOnce(this.turtle2);  | ||
                 this.board.update();  |                  //this.board.update();  | ||
             }  |              }  | ||
| Line 131: | Line 131: | ||
                 var p = this.board.createElement('point',this.pos,{fixed:true,name:' ',visible:false});  |                  var p = this.board.createElement('point',this.pos,{fixed:true,name:' ',visible:false});  | ||
                 this.points.push(p);  |                  this.points.push(p);  | ||
                 this.board.update();  |                  //this.board.update();  | ||
             }  |              }  | ||
Revision as of 16:13, 19 December 2008
This is a very basic implementation of turtle graphics with JSXGraph.
List of 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);
 - t.left(angle); or t.lt(angle);
 - t.penUp();
 - t.penDown();
 - t.clean();
 - t.setPos(x,y);
 
Snowflake Example