The label Object

With the label object you can display text in a box, linked by a line to a specified point. In the accompanying diagram, a sphere representing the Earth (whose center is at earth.pos) has an associated label carrying the text "Earth" in a box, connected to the sphere by a line which stops at the surface of the sphere:

earthlabel = label(pos=earth.pos, text='Earth', xoffset=20, yoffset=12, space=earth.radius, height=10, border=6)

A unique feature of the label object is that several attributes are given in terms of screen pixels instead of the usual "world-space" coordinates. For example, the height of the text is given in pixels, with the result that the text remains readable even when the sphere object is moved far away. Other pixel-oriented attributes include xoffset, yoffset, and border. Here are the label attributes:

pos; x,y,z The point in world space being labeled

xoffset, yoffset The x and y components of the line, in pixels (see diagram)

text The text to be displayed, such as 'Earth'
(Line breaks are not yet supported)

height Height of the font in pixels

color, red, green, blue Color of the text

opacity Opacity of the background of the box, default 0.66
(0 transparent, 1 opaque, for objects behind the box)

border Distance in pixels from the text to the surrounding box

box 1 if the box should be drawn (default), else 0

line 1 if the line from the box to pos should be drawn (default), else 0

linecolor Color of the line and box

space World-space radius of a sphere surrounding pos,
into which the connecting line does not go

font Optional name of the font, such as `helvetica'