MarkupText¶
Qualified name: algan.mobs.text.MarkupText
- class MarkupText(text, fill_opacity=1, stroke_width=0, color=None, font_size=48, line_spacing=None, font='', slant='NORMAL', weight='NORMAL', justify=False, gradient=None, tab_width=4, height=None, width=None, center=True, disable_ligatures=False, warn_missing_font=True, **kwargs)[source]¶
Bases:
TextPlain text from a Pango-markup source, with the markup stripped out.
Manim’s markup syntax is accepted so a ported script keeps running, but the tags never reach the glyph renderer:
<br/>becomes a line break, HTML entities are unescaped, and every other tag is deleted before the text is typeset. This happens whether or not the optional Pango renderer is available, so a<span foreground='red'>span comes out in the Mob’s own color, not red. The source you passed is kept onoriginal_text.To color or restyle part of a string, use
Text’scolor_map/font_map/slant_map/weight_map/gradient_maparguments instead – those do reach the renderer.- Parameters:
text – The marked-up source. Tags are stripped,
<br/>becomes a newline and entities such as&are unescaped; what remains is typeset.justify – Accepted for Manim parity and has no effect on the rendered text; it is stored on the Mob as
justify. Defaults toFalse.fill_opacity – As
Text, with the same defaults.stroke_width – As
Text, with the same defaults.color – As
Text, with the same defaults.font_size – As
Text, with the same defaults.line_spacing – As
Text, with the same defaults.font – As
Text, with the same defaults.slant – As
Text, with the same defaults.weight – As
Text, with the same defaults.gradient – As
Text, with the same defaults.disable_ligatures – As
Text, with the same defaults.warn_missing_font – As
Text, with the same defaults.tab_width – As
Text, with the same defaults. All of these are redeclared here only so this constructor’s signature matches Manim’s.height – As
Text, with the same defaults. All of these are redeclared here only so this constructor’s signature matches Manim’s.width – As
Text, with the same defaults. All of these are redeclared here only so this constructor’s signature matches Manim’s.center – As
Text, with the same defaults. All of these are redeclared here only so this constructor’s signature matches Manim’s.**kwargs – Passed to
Text.
- original_text¶
The markup source exactly as given, before stripping.
Examples
A markup string, and the
Textspelling that actually colors the span:Example: Example1MarkupText ¶
from algan import * MarkupText("<b>bold</b> markup is stripped", font_size=32).move(UP * 0.5).spawn() Text("color_map is not", font_size=32, color_map={"not": BLUE}).move(DOWN * 0.5).spawn() Scene.save_video()
Methods
Attributes
animation_managerThis mob's scene-owned animation manager.
basisThe Mob's orientation and scale, as a flattened 3x3 matrix of shape
(*, 9).casts_shadowsWhether this Mob's geometry blocks light on its way from a light source to another surface -- whether it casts a shadow.
childrenThe Mobs attached below this one, in attachment order.
closed_shellWhether this Mob's triangles form a CLOSED shell -- every camera ray that enters the geometry crosses a second time on its way out.
draws_descendantsWhether
get_render_primitivesreturns geometry belonging to this Mob's DESCENDANTS as well as its own.forwardGet the direction the Mob is facing.
lifespanThis mob's [spawn, despawn) interval on its Scene timeline (a
Lifespan).locationThe Mob's position in world space, shape
(*, 3).normalized_basisThe Mob's orientation with scale divided out, shape
(*, 9).parentsThe Mobs this one is attached to, in attachment order.
receives_shadowsWhether this Mob's surfaces are darkened by shadows cast onto them.
rightGet the Mob's own rightward direction.
scale_coefficientThe Mob's scale along its own right, up and forward axes, shape
(*, 3).triangulatedtwo_sidedWhether this Mob's geometry should be lit from whichever side the ray arrives on.
upGet the Mob's own upward direction.
xThe Mob's x coordinate in world units, shape
(*, 1).xyThe Mob's x and y coordinates in world units, shape
(*, 2).yThe Mob's y coordinate in world units, shape
(*, 1).zThe Mob's z coordinate in world units, shape
(*, 1).