MCPcopy
hub / github.com/ManimCommunity/manim / add_subcaption

Method add_subcaption

manim/scene/scene.py:1699–1745  ·  view source on GitHub ↗

r"""Adds an entry in the corresponding subcaption file at the current time stamp. The current time stamp is obtained from ``Scene.time``. Parameters ---------- content The subcaption content. duration The duration (in seconds

(
        self, content: str, duration: float = 1, offset: float = 0
    )

Source from the content-addressed store, hash-verified

1697 self.update_self(dt)
1698
1699 def add_subcaption(
1700 self, content: str, duration: float = 1, offset: float = 0
1701 ) -> None:
1702 r"""Adds an entry in the corresponding subcaption file
1703 at the current time stamp.
1704
1705 The current time stamp is obtained from ``Scene.time``.
1706
1707 Parameters
1708 ----------
1709
1710 content
1711 The subcaption content.
1712 duration
1713 The duration (in seconds) for which the subcaption is shown.
1714 offset
1715 This offset (in seconds) is added to the starting time stamp
1716 of the subcaption.
1717
1718 Examples
1719 --------
1720
1721 This example illustrates both possibilities for adding
1722 subcaptions to Manimations::
1723
1724 class SubcaptionExample(Scene):
1725 def construct(self):
1726 square = Square()
1727 circle = Circle()
1728
1729 # first option: via the add_subcaption method
1730 self.add_subcaption("Hello square!", duration=1)
1731 self.play(Create(square))
1732
1733 # second option: within the call to Scene.play
1734 self.play(
1735 Transform(square, circle), subcaption="The square transforms."
1736 )
1737
1738 """
1739 subtitle = srt.Subtitle(
1740 index=len(self.renderer.file_writer.subcaptions),
1741 content=content,
1742 start=datetime.timedelta(seconds=float(self.time + offset)),
1743 end=datetime.timedelta(seconds=float(self.time + offset + duration)),
1744 )
1745 self.renderer.file_writer.subcaptions.append(subtitle)
1746
1747 def add_sound(
1748 self,

Callers 2

test_subcaptionFunction · 0.95
playMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by 1

test_subcaptionFunction · 0.76