shapes.text#

shapes.text(text, height=1.0, depth=0.2)#

Create a triangular mesh representing text.

Parameters#

textstr

The text string to be converted into a mesh. Must contain at least one visible character.

heightfloat, optional

Height scaling factor for the generated text (applied in the y-direction). Must be > 0. Default is 1.0, and this will result in a height of 1.0 for the string ‘fg’.

depthfloat, optional

Extrusion depth in the z-direction. If depth == 0.0, the mesh remains planar. Must be >= 0. Default is 0.2.

Returns#

Mesh

A triangular surface mesh (eltype='tri3') representing the specified text. If depth > 0, the result is a closed 3D surface mesh; otherwise it is planar.

Examples#

>>> T = text("Hello!", height=2.0, depth=0.5)
>>> print(T)
Mesh: n_nodes: 754, n_elems: 1488, plexitude: 3, level: 2, eltype: tri3
  BBox: [ 0.2028 -0.0294  0.    ], [5.7546 1.5702 0.5   ]
  Size: [5.5518 1.5996 0.5   ]
  Length: 0.0  Area: 21.08
>>> T.enclosed_volume() > 0.0
True
>>> T2 = text("Planar", depth=0.0)
>>> np.isclose(T2.enclosed_volume(), 0.0)
True