Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

added Brace mobject to replace Underbrace

Grant Sandersonf47385d3dae2
diff --git a/mobject/tex_mobject.py b/mobject/tex_mobject.py
index c0d667744..cb3d138a9 100644
--- a/mobject/tex_mobject.py
+++ b/mobject/tex_mobject.py
@@ -45,15 +45,21 @@ class TextMobject(TexMobject):
}
-class Underbrace(TexMobject):
+class Brace(TexMobject):
DEFAULT_CONFIG = {
"buff" : 0.2,
}
- def __init__(self, left, right, **kwargs):
- expression = "\\underbrace{%s}"%(14*"\\quad")
- TexMobject.__init__(self, expression, **kwargs)
- result.stretch_to_fit_width(right[0]-left[0])
- result.shift(left - result.points[0] + buff*DOWN)
+ TEX_STRING = "\\underbrace{%s}"%(14*"\\quad")
+ def __init__(self, mobject, direction = DOWN, **kwargs):
+ TexMobject.__init__(self, self.TEX_STRING, **kwargs)
+ angle = -np.arctan2(*direction[:2]) + np.pi
+ mobject.rotate(-angle)
+ left = mobject.get_corner(DOWN+LEFT)
+ right = mobject.get_corner(DOWN+RIGHT)
+ self.stretch_to_fit_width(right[0]-left[0])
+ self.shift(left - self.points[0] + self.buff*DOWN)
+ for mob in mobject, self:
+ mob.rotate(angle)