Text
Description
The Text
class, which inherits from TransformableMobject
, represents a customizable text mobject.
The method create_label
of the Mobject class constructs a Text
instance.
Constructor Parameters
Constructor Parameters
text
(str): The text to display.position
(Point3D, default=UL): Coordinates of the upper left corner.start_angle
(float, default=0): Starting angle in radians.color
(ManimColor | None, default=WHITE): Text color.font_family
(str | None, default="computer-modern"): Font family.font_size
(float | None, default=DEFAULT_FONT_SIZE): Font size.opacity
(float, default=1.0): Text opacity.text_decoration
(Literal["none", "underline", "overline", "line-through"], default="none"): Text decoration.bold
(bool, default=False): Bold text.italics
(bool, default=False): Italicized text.z_index
(int, default=1): Z-index for layering.max_width
(float | None, default=6.0): Maximum width before text wrapping, in internal smanim units.x_padding
(float, default=0): Horizontal padding.y_padding
(float, default=0): Vertical padding.leading
(float, default=0.2): Line spacing as a percentage of line height.kwargs
(dict): Additional arguments forTransformableMobject
.
Attributes
raw_text
(str): The raw text string.fill_color
(ManimColor): Text color.fill_opacity
(float): Text opacity.text_decoration
(Literal["none", "underline", "overline", "line-through"]): Text decoration.italics
(bool): Italicized text.bold
(bool): Bold text.font_path
(Path): Path to the font file.position
(Point3D): Upper left corner of the text bounding box.heading
(float): Text heading angle.
Examples
Example 1
Text with custom color, size, and styling.
from smanim import *
text = Text(
text="Hello, world!",
color=RED,
font_size=H3_FONT_SIZE,
bold=True,
italics=True,
)
canvas.add(text)
canvas.snapshot(preview=True, crop=True, ignore_bg=True)