subtitles¶
- class janim.timeline.subtitles.SubtitleInfo(text: str, range: TimeRange, kwargs: dict, subtitle: Text | TypstText)¶
Bases:
objectParameter information for calling
subtitle()- text: str¶
- kwargs: dict¶
- class janim.timeline.subtitles.SubtitlesMixin(*args, **kwargs)¶
Bases:
TimelineCoreProvides the ability to add subtitles to
TimelineHint
All methods in this class can be used directly in
Timeline- subtitle(text: str | Iterable[str], duration: float = 1, *, delay: float = 0, scale: float | Iterable[float] = 0.8, use_typst_text: bool | Iterable[bool] = False, surrounding_color: JAnimColor = BLACK, surrounding_alpha: float = 0.5, font: str | Iterable[str] = [], depth: float = -100000.0, **kwargs) TimeRange¶
- subtitle(text: str | Iterable[str], range: TimeRange, **kwargs) TimeRange
Add subtitle
Text can be passed as a list, displayed vertically
You can specify that the subtitle appears
delayseconds after the current positiondurationrepresents the durationscalerepresents the scaling of text. You can pass a list to specify scaling for each textuse_typst_textindicates whether to useTypstText. You can pass a list to specify whether each text uses itSet
surrounding_alphato0to disable the background box
Configalso provides some configurable parameters:subtitle_fontglobally configures the font used for subtitlessubtitle_to_edge_buffconfigures the distance from the subtitle to the bottom edge; defaults toDEFAULT_ITEM_TO_EDGE_BUFF
Return value represents the display time range
- place_subtitle(subtitle: Text | TypstText, range: TimeRange) None¶
Called by
subtitle()to place subtitles in appropriate positions:For subtitles added in the same batch
[a, b],ais placed abovebIf
[a, b]mentioned above still exists and acis added, thencis placed at the top
- has_subtitle() bool¶