text#
- k3d.factory.text(text, position=[0, 0, 0], color=255, reference_point='lb', on_top=True, size=1.0, label_box=True, is_html=False, name=None, group=None, custom_data=None, compression_level=0, **kwargs)[source]#
Create a Text drawable for 3D-positioned text labels.
- Parameters
text (str or list of str) – Content of the text.
position (list) – (x, y, z) coordinates of text position, by default (0, 0, 0). If n text is pass position should contain 3*n elements .
color (int, optional) – Hex color of the text, by default _default_color.
reference_point (str, optional) –
Two-letter string representing text alignment, by default “lb”.
First letters
l
– leftc
– centerr
– right
Second letters
t
– topc
– centerb
– bottom
on_top (bool, optional) – Render order with 3d object, by default True.
size (float, optional) – Font size in ‘em’ HTML units, by default 1.0.
label_box (bool, optional) – Label background box, by default True.
is_html (bool, optional) – Interprete text as HTMl instead of KaTeX, by default False.
name (str, optional) – Object name, by default None.
group (str, optional) – Name of a group, by default None.
custom_data (dict) – A object with custom data attached to object.
compression_level (int, optional) – Level of data compression [-1, 9], by default 0.
**kwargs – For other keyword-only arguments, see process_transform_arguments.
- Returns
Text Drawable.
- Return type
Text
See also
Examples#
Basic#
import k3d
plt_text1 = k3d.text('Insert text here',
position=(1, 1, 1))
plt_text2 = k3d.text('Insert text here (HTML)',
position=(-1, -1, -1),
is_html=True)
plot = k3d.plot()
plot += plt_text1
plot += plt_text2
plot.display()
Reference points#
import k3d
plt_square = k3d.mesh(vertices=[[1, 0, 1], [1, 0, -1], [-1, 0, -1], [-1, 0, 1]],
indices=[[0, 1, 2], [2, 1, 0], [0, 2, 3], [3, 2, 0]],
colors=[0xff0000, 0x00ff00, 0x0000ff, 0xffff00])
plt_text_lt = k3d.text('Left-Top',
position=(-1, 0, 1), reference_point='lt',
color=0xffff00, size=0.7)
plt_text_lb = k3d.text('Left-Bottom',
position=(-1, 0, -1), reference_point='lb',
color=0x0000ff, size=0.7)
plt_text_lc = k3d.text('Left-Center',
position=(-1, 0, 0), reference_point='lc',
color=0x808080, size=0.7)
plt_text_rt = k3d.text('Right-Top',
position=(1, 0, 1), reference_point='rt',
color=0xff0000, size=0.7)
plt_text_rb = k3d.text('Right-Bottom',
position=(1, 0, -1), reference_point='rb',
color=0x00ff00, size=0.7)
plt_text_rc = k3d.text('Right-Center',
position=(1, 0, 0), reference_point='rc',
color=0x808000, size=0.7)
plt_text_ct = k3d.text('Center-Top',
position=(0, 0, 1), reference_point='ct',
color=0xff8000, size=0.7)
plt_text_cb = k3d.text('Center-Bottom',
position=(0, 0, -1), reference_point='cb',
color=0x008080, size=0.7)
plt_text_cc = k3d.text('Center-Center',
position=(0, 0, 0), reference_point='cc',
color=0xff00ff, size=0.7)
plot = k3d.plot()
plot += plt_square
plot += plt_text_lt
plot += plt_text_lb
plot += plt_text_lc
plot += plt_text_rt
plot += plt_text_rb
plot += plt_text_rc
plot += plt_text_ct
plot += plt_text_cb
plot += plt_text_cc
plot.display()