Pencil Code Reference > label

 

label writes text under the turtle

label writes text at the turtle position.

label 'You are here.'

The text of a label is a string, so it should be quoted. The string may contain HTML.

Bigger Labels

label can create a larger label with an optional second argument. Remember the comma.

label 'Hi', 100

Colors and Fonts

Instead of a size, the last argument to label can be a CSS style object. Any CSS style properties can be used, with a colon after the style name spelled in camelCaps style. If there are several properties, the block of properties should be indented.

label 'Simple',
  fontFamily: 'Arial'
  fontWeight: 'bold'
  fontSize: 50
  color: orange

Rotated Labels

The label command inherits visual styles from the turtle, including its current rotation, scale, and position. To create a rotated label, just rotate the turtle first.

lt 90
label 'Vertical'

Labels on the Side

label supports a special CSS pseudo-style, labelSide, that controls the relative position and rotation of the label. Standard CSS does not include labelSide; it only works within the label command.

rt 90
label 'A', labelSide: 'top'
pen purple
fd 100
label 'B', labelSide: 'bottom'

The labelSide property should be a space-separated string including one or more of the following words:

labelSide meaning
top positioned above the turtle
bottom positioned below the turtle
right positioned to the right of the turtle
left positioned to the left of the turtle
centered centered directly over the turtle
rotated oriented as the turtle is rotated
scaled scaled as the turtle

More then one word can be included such as "top left rotated". If labelSide is not specified, it defaults to "centered rotated scaled".