text

_images/newtext3d.png

The text object displays 3D text, which is created by extruding the outlines of individual letters and then compounding the resulting objects. In the image above white labels are used to illustrate some of the key attributes of the text object.

If you want 2D text superimposed on a canvas, see label. If you want 2D text above or below the canvas, see canvas.

text(text='My text is\ngreen', align='center', color=color.green)
Parameters:
  • pos (vector) – Location of the baseline of the text. Modified by align. Default <0,0,0>.

  • text (unicode string) – Text to be displayed. Once created cannot be modified.

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

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

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

  • billboard (boolean) – If True, text always faces camera, despite rotation. Default False.

  • axis (vector) – The axis points along the baseline. Default <1,0,0>

The text below has billboard=False:

_images/starwarstext.png

Less frequently used attributes:

text(text='mytext', start_face_color=color.red, end_face_color=color.cyan)
Parameters:
  • start_face_color (vector) – Color of starting (back) face of the text. Default same as text color.

  • end_face_color (vector) – Color of starting (front) face of the text. Default same as text color.

  • opacity (scalar) – Opacity of text. Range 0-1. Default is 0.66.

  • height (scalar) – Height of text in world coordinates. Default is 1.

  • length (scalar) – Length of displayed text. Can’t be specified in constructor, but can be changed later.

  • depth (scalar) – Depth of text. Default is 0.2*height. If depth>0, extrude +z, if depth<0, extrude -z.

  • descender (scalar) – Height of descender on lower case letters such as y. Read-only.

  • start (scalar) – Leftmost location on baseline. Read-only.

  • end – Rightmost location on baseline. Read-only.

  • vertical_spacing (scalar) – Vertical distance from one baseline to next in multiline text. Read-only.

  • opacity – Default 1.0; Range 0-1.

  • shininess (scalar) – Default 0.6; Range 0-1.

  • emissive (boolean) – Default False. Object glows, losing all shading, if True.

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

  • canvas (object) – Default is scene.

  • up (vector) – A vector perpendicular to the axis.

  • group (object) – The group to which this object belongs.

See also

Rotation; color; emissive; canvas