Movement |
| fd 50 | forward 50 pixels |
| bk 10 | backward 10 pixels |
| rt 90 | turn right 90 degrees |
| lt 120 | turn left 120 degrees |
| rt 90, 50 | do a 90° arc of radius 50 |
| home() | go to the page center |
| slide x, y | slide right x and forward y |
| moveto x, y | go to x, y relative to home |
| turnto 45 | set direction to 45 (NE) |
| turnto obj | point toward obj |
| speed 30 | do 30 moves per second |
Appearance |
| hide() | hide the turtle |
| show() | show the turtle |
| scale 8 | do everything 8x bigger |
| wear yellow | wear a yellow shell |
| fadeOut() | fade and hide the turtle |
| remove() | totally remove the turtle |
Output |
| see obj | debug the value of obj |
| write 'hello' | writes a line of HTML |
| p = write 'hm' | saves an HTML element |
| p.html 'done' | changes old text |
| append 'ok' | text without a new line |
button 'go', -> fd 10 | adds a button with an action |
read (n) -> write n*n | adds a text input with an action |
| t = table 3,5 | adds a 3x5 <table> |
t.cell(0, 0). text 'aloha' |
selects the first cell of the table and sets its text |
| ct() | clear text |
|
Drawing |
| pen blue | draw in blue |
| pen red, 9 | 9 pixel wide red pen |
| pen null | use no color |
| pen off | pause use of the pen |
| pen on | use the pen again |
| label 'X' | draw the letter X |
| dot green | draw a green dot |
| dot gold, 30 | 30 pixel gold circle |
| pen path | trace an invisible path |
| fill cyan | fill traced path in cyan |
| cg() | clear graphics |
Properties |
| turtle | name of the main turtle |
| getxy() | [x, y] position relative to home |
| direction() | direction of turtle |
| hidden() | if the turtle is hidden |
| touches(obj) | if the turtle touches obj |
| inside(window) |
if enclosed in the window |
Sets |
| g = hatch 20 | hatch 20 new turtles |
| g = $('img') | select all <img> as a set |
g.plan (j) -> @fd j * 10 |
direct the jth turtle to go forward by 10j pixels |
Other Functions |
| forever 5, -> fd 8 | go 5 times per second |
| click -> fd 10 | go when clicked |
| random [3,5,7] | return 3, 5, or 7 |
| random 100 | random [0..99] |
| play 'ceg' | play musical notes |
| $(window) | the visible window |
| $('p').eq(0) | the first <p> element |
| $('#zed') | the element with id="zed" |
|