First page of chapter 5

This commit is contained in:
Grant Sanderson
2016-08-02 12:26:15 -07:00
parent 014b7bfdef
commit 6fe057c0f9
8 changed files with 419 additions and 20 deletions

View File

@ -189,6 +189,7 @@ class Bubble(SVGMobject):
self.stretch_to_fit_width(self.width)
if self.direction[0] > 0:
Mobject.flip(self)
self.direction_was_specified = ("direction" in kwargs)
self.content = Mobject()
def get_tip(self):
@ -207,9 +208,11 @@ class Bubble(SVGMobject):
self.direction = -np.array(self.direction)
return self
def pin_to(self, mobject, allow_flipping = True):
def pin_to(self, mobject):
mob_center = mobject.get_center()
if np.sign(mob_center[0]) != np.sign(self.direction[0]) and allow_flipping:
want_to_filp = np.sign(mob_center[0]) != np.sign(self.direction[0])
can_flip = not self.direction_was_specified
if want_to_filp and can_flip:
self.flip()
boundary_point = mobject.get_critical_point(UP-self.direction)
vector_from_center = 1.0*(boundary_point-mob_center)