Turtle Commands

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.

CommandArgumentsDescriptionAlias
cleannoneremoves all canvas elements and resets the turtle
forwarddistance (number)move turtle forwardfd
backdistance (number)move turtle backwardbk
rightdegrees (number)rotate turtle clockwisert
leftdegrees (number)rotate turtle counter-clockwisert
setheadingdegrees (number)set turtle to face specified angleseth
setxyxcoordinate ycoordinate (numbers)move turtle to set coordinateslineto
arcdegrees radius (numbers)move turtle in an arc
fillscreencolor shade (numbers)fill canvas with specified color
setcolorcolor (number or string)set pen color using JSLogo color codes or CSS color stringssetc
setshadeshade (number)set color using JSLogo color code; will reset CSS color strings if usedsetsh
setpensizesize (number)set thickness of lines drawn by turtlesetps
pendownnonestart drawing if pen is uppd
penupnonestop drawing if pen is downpu
startfillnoneset starting point for fill shape
endfillnoneend fill shape; attemps to fill an object with current color
drawtexttext (string)write text at location of turtle
textaligndirection (string)set text alignment to left, right or center
setfontfont (string)set font of text; relies on system fonts being understood
setfontsizesize (number)set size of drawtext output
setlinestyledistances (array)set segment length of dashed line; see MDN (opens in a new tab)
loadpicURL (string)loads a picture into the canvas; overwrites existing content
xcornonereturns current x coordinate location of turtle
ycornonereturns current y coordinate location of turtle
tcornonereturns an array with x and y coordinates of turtle
headingnonereturns angle of current turtle heading
shadenonereturns currently set shade
pensizenonereturns currently set pen size
opacitynonereturns currently set opacity
hide-turtlenonehides turtle (drawing will continue)ht
showturtlenoneshows turtle if hiddenst
unixtimenoneretrives time in seconds since January 1st, 1970
setclassstring (warrior, mage, ranger, bard)set class of turtle
aboutclassstring (warrior, mage, ranger, bard)print information about turtle classes
Last updated on August 1, 2023