These notes refer to the turtle graphics page. This page demonstrates simple turtle graphics. When the user clicks on one of the button the associated JavaScript function is executed. The JavaScript function in turn "calls" a function in the embedded VRML (in VRML speak - the JavaScript sends events to the turtle "Tommy").
<embed width=400 height=300 src="turtle.wrl">
<script>
function MyFunction(s){
alert(s + ' was here!');
}
</script>
alert is a JavaScript command to display a simple dialog box.
<input type="button" value="Who?" onClick="MyFunction('Andrew')">
document.embeds[0].getNode("Tommy").getEventIn("forward").setValue(v*1.0);
Note that we must force a type conversion from string to float by multiplying
by 1.0| Other turtle commands | ||
|---|---|---|
| Command | Parameter type | Notes |
| forward | float | A distance - 100 is fairly small. |
| left | float | Rotate by the angle in degrees. |
| dive | float | Rotate nose downwards by the angle given. |
| roll | float | Bank right wing downwards by angle given. |
| show | boolean | Turtle may be visible or not. |
| pen | boolean | No trail is left when the pen is up (false). |
| penColor | string | The string consists of three space separated decimal numbers between 0 and 1. These represent the Red, Green and Blue components. |