Turtle Logo is the initial interface of JSLogo, in which a turtle can be controlled to draw images on a canvas. The commands described here can be used in the 'Canvas' view of the LbyM Web App. JSLogo Turtle commands are mostly compatible with older JLogo commands, but may have some differences.
LbyM provides a template, Turtle Words, used in the formal curriculum. Functions, or words, found in the project are not included in this documentation, only native commands that can be used in any project.
Command | Arguments | Description | Alias |
---|---|---|---|
clean | none | removes all canvas elements and resets the turtle | |
forward | distance (number) | move turtle forward | fd |
back | distance (number) | move turtle backward | bk |
right | degrees (number) | rotate turtle clockwise | rt |
left | degrees (number) | rotate turtle counter-clockwise | rt |
setheading | degrees (number) | set turtle to face specified angle | seth |
setxy | xcoordinate ycoordinate (numbers) | move turtle to set coordinates | lineto |
arc | degrees radius (numbers) | move turtle in an arc | |
fillscreen | color shade (numbers) | fill canvas with specified color | |
setcolor | color (number or string) | set pen color using JSLogo color codes or CSS color strings | setc |
setshade | shade (number) | set color using JSLogo color code; will reset CSS color strings if used | setsh |
setpensize | size (number) | set thickness of lines drawn by turtle | setps |
pendown | none | start drawing if pen is up | pd |
penup | none | stop drawing if pen is down | pu |
startfill | none | set starting point for fill shape | |
endfill | none | end fill shape; attemps to fill an object with current color | |
drawtext | text (string) | write text at location of turtle | |
textalign | direction (string) | set text alignment to left, right or center | |
setfont | font (string) | set font of text; relies on system fonts being understood | |
setfontsize | size (number) | set size of drawtext output | |
setlinestyle | distances (array) | set segment length of dashed line; see MDN (opens in a new tab) | |
loadpic | URL (string) | loads a picture into the canvas; overwrites existing content | |
xcor | none | returns current x coordinate location of turtle | |
ycor | none | returns current y coordinate location of turtle | |
tcor | none | returns an array with x and y coordinates of turtle | |
heading | none | returns angle of current turtle heading | |
shade | none | returns currently set shade | |
pensize | none | returns currently set pen size | |
opacity | none | returns currently set opacity | |
hide-turtle | none | hides turtle (drawing will continue) | ht |
showturtle | none | shows turtle if hidden | st |
unixtime | none | retrives time in seconds since January 1st, 1970 | |
setclass | string (warrior, mage, ranger, bard) | set class of turtle | |
aboutclass | string (warrior, mage, ranger, bard) | print information about turtle classes |
Last updated on August 1, 2023