Finished initial animations for chapter 5

This commit is contained in:
Grant Sanderson
2016-08-03 16:51:16 -07:00
parent 4f42f62b3c
commit f52179c3d9
5 changed files with 760 additions and 15 deletions

View File

@ -103,7 +103,10 @@ class TexMobject(SVGMobject):
)
def add_background_rectangle(self, color = BLACK, opacity = 0.75):
rect = BackgroundRectangle(self, color = color, opacity = opacity)
rect = BackgroundRectangle(
self, color = color,
fill_opacity = opacity
)
letters = VMobject(*self.submobjects)
self.submobjects = [rect, letters]
return self
@ -123,6 +126,7 @@ class Brace(TexMobject):
}
TEX_STRING = "\\underbrace{%s}"%(3*"\\qquad")
def __init__(self, mobject, direction = DOWN, **kwargs):
digest_config(self, kwargs, locals())
TexMobject.__init__(self, self.TEX_STRING, **kwargs)
angle = -np.arctan2(*direction[:2]) + np.pi
mobject.rotate(-angle)
@ -133,6 +137,16 @@ class Brace(TexMobject):
for mob in mobject, self:
mob.rotate(angle)
def put_at_tip(self, mob, **kwargs):
mob.next_to(self, self.direction, **kwargs)
return self
def get_text(self, text, **kwargs):
text_mob = TextMobject(text)
self.put_at_tip(text_mob, **kwargs)
return text_mob
def tex_hash(expression, template_tex_file):
return str(hash(expression + template_tex_file))