<\/pre>","numboards":1,"description":"### List of available commands\r\nThere is a predefined turtle object *t*. Therefore, all commands\r\nstart with *t*, like *t.fd(100)*;\r\n\r\n* t.forward(len); or t.fd(len);\r\n* t.back(len); or t.bk(len);\r\n* t.right(angle); or t.rt(angle); *)\r\n* t.left(angle); or t.lt(angle); *)\r\n* t.penUp(); or t.pu();\r\n* t.penDown(); or t.pd();\r\n* t.clearScreen(); or t.cs();\r\n* t.clean();\r\n* t.setPos(x,y); \r\n* t.home();\r\n* t.hideTurtle(); or t.ht();\r\n* t.showTurtle(); or t.st();\r\n* t.setPenSize(size); (size: number)\r\n* t.setPenColor(col); (col: colorString, e.g. 'red' or '#ff0000')\r\n* t.setAttribute({key1:value1,key2:value2,...});\r\n* t.pushTurtle()\r\n* t.popTurtle()\r\n* t.lookTo(dir) or t.lookTo([x,y]) (Turtle looks to a coordinate pair. If t2 is another turtle object: t.lookTo(t2.pos))\r\n* t.moveTo([x,y]) (Turtle goes forward to the coordinates pair. The turtles direction is not changed.)\r\n* t.X(), t.Y(): get the position of the turtle t.","dimensions":[{"width":"100%","height":null,"aspect-ratio":"1 \/ 1"}],"wider":0,"license":{"id":2,"identifier":"CC BY-SA 4.0","title":"Creative Commons Attribution ShareAlike 4.0 International","free":"- Share\r\n- Adapt","restrictions":"- Attribution\r\n- ShareAlike\r\n- No additional restrictions","with_attribution":1,"link":"https:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/","image":"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png","rank":1},"timestamp":"2025-09-09 13:03:56","visible":0,"tags":[{"id":151,"alias":"turtle","name":"Turtle"}],"tag_ids":[151],"refers_to":[],"refers_to_ids":[],"authors":[],"authors_ids":[],"unique_ids":["jxgbox-69389d976facb"],"code_display":"\/\/ Define the id of your board in BOARDID\n\nvar board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true });\r\nvar t = board.create('turtle');\r\n\r\nfunction run() {\r\n board.suspendUpdate();\r\n var code = document.getElementById('inputtext').value;\r\n if (code == '') { return; }\r\n eval(code);\r\n document.getElementById('logwindow').innerHTML += code + '\\n';\r\n \/\/document.getElementById('inputtext').value = '';\r\n board.unsuspendUpdate();\r\n}\r\n\r\nfunction clearturtle() {\r\n t.cs();\r\n \/\/document.getElementById('inputtext').value = 't.fd(100);';\r\n}\r\n\r\nfunction clearlog() {\r\n document.getElementById('logwindow').innerHTML = '';\r\n}","code_execute_html":"<\/div>\n Share BROKEN | Programming turtle graphics Show plain example JSFiddle Link QR code Copy QR Download QR iFrame <iframe src="http://jsxgraph.uni-bayreuth.de/share/iframe/programming-turtle-graphics" style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" name="JSXGraph example: BROKEN | Programming turtle graphics" allowfullscreen ></iframe> <iframe src="http://jsxgraph.uni-bayreuth.de/share/iframe/programming-turtle-graphics" style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" name="JSXGraph example: BROKEN | Programming turtle graphics" allowfullscreen ></iframe> This code has to HTML <textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">t.fd(100); <div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; "> <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div> </div> <pre id="logwindow" class="javascript javascript" style="font-family:monospace;"></pre> <script type = "text/javascript"> /* This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'board-0'; var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; } </script> <textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">t.fd(100); <div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; "> <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div> </div> <pre id="logwindow" class="javascript javascript" style="font-family:monospace;"></pre> <script type = "text/javascript"> /* This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'board-0'; var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; } </script> JavaScript /* This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'your_div_id'; // Insert your id here! var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; } /* This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'your_div_id'; // Insert your id here! var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; } Download Print BROKEN | Programming turtle graphics Turtle ### 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); *) * 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') * t.setAttribute({key1:value1,key2:value2,...}); * t.pushTurtle() * t.popTurtle() * t.lookTo(dir) or t.lookTo([x,y]) (Turtle looks to a coordinate pair. If t2 is another turtle object: t.lookTo(t2.pos)) * t.moveTo([x,y]) (Turtle goes forward to the coordinates pair. The turtles direction is not changed.) * t.X(), t.Y(): get the position of the turtle t. t.fd(100); <textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">t.fd(100); <textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">t.fd(100); // Define the id of your board in BOARDID var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; } // Define the id of your board in BOARDID var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; } <pre id="logwindow" class="javascript javascript" style="font-family:monospace;"></pre> <pre id="logwindow" class="javascript javascript" style="font-family:monospace;"></pre> This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.
<iframe src="http://jsxgraph.uni-bayreuth.de/share/iframe/programming-turtle-graphics" style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" name="JSXGraph example: BROKEN | Programming turtle graphics" allowfullscreen ></iframe>
<textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">t.fd(100); <div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; "> <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div> </div> <pre id="logwindow" class="javascript javascript" style="font-family:monospace;"></pre> <script type = "text/javascript"> /* This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'board-0'; var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; } </script>
/* This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'your_div_id'; // Insert your id here! var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; }
<textarea id="inputtext" rows=5 cols=35 wrap="off" style="width:600px;">t.fd(100);
// Define the id of your board in BOARDID var board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-300, 300, 300, -300], keepaspectratio: true }); var t = board.create('turtle'); function run() { board.suspendUpdate(); var code = document.getElementById('inputtext').value; if (code == '') { return; } eval(code); document.getElementById('logwindow').innerHTML += code + '\n'; //document.getElementById('inputtext').value = ''; board.unsuspendUpdate(); } function clearturtle() { t.cs(); //document.getElementById('inputtext').value = 't.fd(100);'; } function clearlog() { document.getElementById('logwindow').innerHTML = ''; }
<pre id="logwindow" class="javascript javascript" style="font-family:monospace;"></pre>
This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License. Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.