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: Text

Plain 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 on original_text.

To color or restyle part of a string, use Text’s color_map / font_map / slant_map / weight_map / gradient_map arguments instead – those do reach the renderer.

Parameters:
  • text – The marked-up source. Tags are stripped, <br/> becomes a newline and entities such as &amp; 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 to False.

  • 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 Text spelling that actually colors the span:

Example: Example1MarkupText

../_images/Example1MarkupText-1.png
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_manager

This mob's scene-owned animation manager.

basis

The Mob's orientation and scale, as a flattened 3x3 matrix of shape (*, 9).

casts_shadows

Whether this Mob's geometry blocks light on its way from a light source to another surface -- whether it casts a shadow.

children

The Mobs attached below this one, in attachment order.

closed_shell

Whether this Mob's triangles form a CLOSED shell -- every camera ray that enters the geometry crosses a second time on its way out.

draws_descendants

Whether get_render_primitives returns geometry belonging to this Mob's DESCENDANTS as well as its own.

forward

Get the direction the Mob is facing.

lifespan

This mob's [spawn, despawn) interval on its Scene timeline (a Lifespan).

location

The Mob's position in world space, shape (*, 3).

normalized_basis

The Mob's orientation with scale divided out, shape (*, 9).

parents

The Mobs this one is attached to, in attachment order.

receives_shadows

Whether this Mob's surfaces are darkened by shadows cast onto them.

right

Get the Mob's own rightward direction.

scale_coefficient

The Mob's scale along its own right, up and forward axes, shape (*, 3).

triangulated

two_sided

Whether this Mob's geometry should be lit from whichever side the ray arrives on.

up

Get the Mob's own upward direction.

x

The Mob's x coordinate in world units, shape (*, 1).

xy

The Mob's x and y coordinates in world units, shape (*, 2).

y

The Mob's y coordinate in world units, shape (*, 1).

z

The Mob's z coordinate in world units, shape (*, 1).