text#
- k3d.factory.text(text: str, position: List | Tuple = None, color: int = 255, reference_point: str = 'lb', on_top: bool = True, size: float = 1.0, label_box: bool = True, is_html: bool = False, name: str | None = None, group: str | None = None, custom_data: Dict[str, Any] | None = None, compression_level: int = 0, visible: bool = True, **kwargs: Any) Text[source]#
Create a Text drawable, rendered with KaTeX at a position in space.
- Parameters:
text (str or list of str) – Content of the text.
position (list, optional) – (x, y, z) coordinates of text position, by default (0, 0, 0). If n text is pass position should contain 3*n elements . Default is None.
color (int, optional) – Packed RGB color of the text (0xff0000 is red, 0xff is blue). Default is 255.
reference_point (str, optional) – Two-letter string representing the text’s alignment. First letter ‘’l’, ‘c’ or ‘r’’ left, center or right Second letter ‘’t’, ‘c’ or ‘b’’ top, center or bottom. Default is ‘lb’.
on_top (bool, optional) – Render order with 3d object Default is True.
size (float, optional) – Font size in ‘em’ HTML units. Default is 1.0.
label_box (bool, optional) – Label background box. Default is True.
is_html (bool, optional) – Whether text should be interpreted as HTML insted of KaTeX. Default is False.
name (str, optional) – A name of the object. Default is None.
group (str, optional) – A name of a group. Default is None.
custom_data (dict, optional) – An object with custom data attached to object. Default is None.
compression_level (int, optional) – Level of compression [-1, 9]. Default is 0.
visible (bool, optional) – Whether the object is drawn. Default is True.
**kwargs – Additional keyword arguments passed to process_transform_arguments.
- Returns:
The created Text object.
- 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()