label

_images/label.jpg _images/label2.png

A label can be used to display 2D text in a 3D world. Labels are billboarded–the label will automatically face the camera no matter how the camera is rotated.

label(pos=vec(0, 0, 0), text='Early', xoffset=20, yoffset=50, space=30, height=16, border=4, font='sans')
Parameters:
  • pos (vector) – Default <0,0,0>.

  • text (string or numerical expression) – Text to be displayed. html formatting for sup, sub, italic, bold accepted.

  • color (vector) – Color of text. Default is color.white

  • align (string) – Specify ‘left’, ‘right’, or ‘center’. Alignment of text with pos. Default ‘center’.

  • xoffset (scalar) – x offset in pixels from pos.

  • yoffset (scalar) – y offset in pixels from pos.

  • font (string) – ‘sans’ or ‘serif or ‘monospace’ (fixed width). Default is ‘sans’.

  • background – Color of the background of the box. Default scene.background.

  • opacity – Opacity of box background. Range 0-1. Default is 0.66.

  • box (boolean) – True if box should be drawn. Default True.

  • border (scalar) – Distance in pixels from text to surrounding box. Default 5 pixels.

  • line (boolean) – True if a line should be drawn from pos to the box. Default True.

  • linecolor (vector) – Color of the line and box. Default is scene.foreground.

  • linewidth (scalar) – Thickness of line and edges of box, in pixels. Default 1 pixel.

  • space (scalar) – Radius in pixels of a sphere surrounding pos, from which line is excluded.

Setting xoffset overrides align.

Less frequently used attributes:

label(opacity=0.5, canvas=mycanvas, visible=True)
Parameters:
  • opacity (scalar) – Default 1.0; Range 0-1.

  • visible (boolean) – If False, label is not displayed. Default: True

  • canvas (object) – Default is scene.