55__all__ = ["Brace" , "BraceLabel" , "ArcBrace" , "BraceText" , "BraceBetweenPoints" ]
66
77from collections .abc import Sequence
8+ from typing import TYPE_CHECKING
89
910import numpy as np
1011import svgelements as se
2425from ...utils .color import BLACK
2526from ..svg .svg_mobject import VMobjectFromSVGPath
2627
28+ if TYPE_CHECKING :
29+ from manim .typing import Point3D , Vector3D
30+ from manim .utils .color .core import ParsableManimColor
31+
2732__all__ = ["Brace" , "BraceBetweenPoints" , "BraceLabel" , "ArcBrace" ]
2833
2934
@@ -65,13 +70,13 @@ def construct(self):
6570 def __init__ (
6671 self ,
6772 mobject : Mobject ,
68- direction : Sequence [ float ] | None = DOWN ,
69- buff = 0.2 ,
70- sharpness = 2 ,
71- stroke_width = 0 ,
72- fill_opacity = 1.0 ,
73- background_stroke_width = 0 ,
74- background_stroke_color = BLACK ,
73+ direction : Vector3D | None = DOWN ,
74+ buff : float = 0.2 ,
75+ sharpness : float = 2 ,
76+ stroke_width : float = 0 ,
77+ fill_opacity : float = 1.0 ,
78+ background_stroke_width : float = 0 ,
79+ background_stroke_color : ParsableManimColor = BLACK ,
7580 ** kwargs ,
7681 ):
7782 path_string_template = (
@@ -125,7 +130,20 @@ def __init__(
125130 for mob in mobject , self :
126131 mob .rotate (angle , about_point = ORIGIN )
127132
128- def put_at_tip (self , mob , use_next_to = True , ** kwargs ):
133+ def put_at_tip (self , mob : Mobject , use_next_to : bool = True , ** kwargs ):
134+ """Puts the given mobject at the brace tip.
135+
136+ Parameters
137+ ----------
138+ mob
139+ The mobject to be placed at the tip.
140+ use_next_to
141+ If true, then :meth:`next_to` is used to place the mobject at the
142+ tip.
143+ kwargs
144+ Any additional keyword arguments are passed to :meth:`next_to` which
145+ is used to put the mobject next to the brace tip.
146+ """
129147 if use_next_to :
130148 mob .next_to (self .get_tip (), np .round (self .get_direction ()), ** kwargs )
131149 else :
@@ -136,23 +154,53 @@ def put_at_tip(self, mob, use_next_to=True, **kwargs):
136154 return self
137155
138156 def get_text (self , * text , ** kwargs ):
157+ """Places the text at the brace tip.
158+
159+ Parameters
160+ ----------
161+ text
162+ The text to be placed at the brace tip.
163+ kwargs
164+ Any additional keyword arguments are passed to :meth:`.put_at_tip` which
165+ is used to position the text at the brace tip.
166+
167+ Returns
168+ -------
169+ :class:`~.Tex`
170+ """
139171 text_mob = Tex (* text )
140172 self .put_at_tip (text_mob , ** kwargs )
141173 return text_mob
142174
143175 def get_tex (self , * tex , ** kwargs ):
176+ """Places the tex at the brace tip.
177+
178+ Parameters
179+ ----------
180+ tex
181+ The tex to be placed at the brace tip.
182+ kwargs
183+ Any further keyword arguments are passed to :meth:`.put_at_tip` which
184+ is used to position the tex at the brace tip.
185+
186+ Returns
187+ -------
188+ :class:`~.MathTex`
189+ """
144190 tex_mob = MathTex (* tex )
145191 self .put_at_tip (tex_mob , ** kwargs )
146192 return tex_mob
147193
148194 def get_tip (self ):
195+ """Returns the point at the brace tip."""
149196 # Returns the position of the seventh point in the path, which is the tip.
150197 if config ["renderer" ] == "opengl" :
151198 return self .points [34 ]
152199
153200 return self .points [28 ] # = 7*4
154201
155202 def get_direction (self ):
203+ """Returns the direction from the center to the brace tip."""
156204 vect = self .get_tip () - self .get_center ()
157205 return vect / np .linalg .norm (vect )
158206
@@ -269,9 +317,9 @@ def construct(self):
269317
270318 def __init__ (
271319 self ,
272- point_1 : Sequence [ float ] | None ,
273- point_2 : Sequence [ float ] | None ,
274- direction : Sequence [ float ] | None = ORIGIN ,
320+ point_1 : Point3D | None ,
321+ point_2 : Point3D | None ,
322+ direction : Vector3D | None = ORIGIN ,
275323 ** kwargs ,
276324 ):
277325 if all (direction == ORIGIN ):
0 commit comments