Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def play_farey_sum_animation(self, p1, q1, p2, q2):
c1, c2, c3, l1, l2, l3 = self.get_farey_sum_key_mobjects(p1, q1, p2, q2)
l3.set_color(PINK)
self.wait()
self.play(
ShowCreation(c1), ApplyMethod(l1.set_color, YELLOW),
ShowCreation(c2), ApplyMethod(l2.set_color, YELLOW),
)
self.play(
ReplacementTransform(l1.numer.deepcopy(), l3.numer),
ReplacementTransform(l1.line.deepcopy(), l3.line),
ReplacementTransform(l1.denom.deepcopy(), l3.denom),
ReplacementTransform(l2.numer.deepcopy(), l3.numer),
ReplacementTransform(l2.line.deepcopy(), l3.line),
ReplacementTransform(l2.denom.deepcopy(), l3.denom),
ReplacementTransform(c1.deepcopy(), c3),
ReplacementTransform(c2.deepcopy(), c3),
)
self.wait()
self.play(FadeOut(VGroup(c1, c2, c3, l1, l2, l3)))
def play_farey_sum_animation(self, p1, q1, p2, q2):
c1, c2, c3, l1, l2, l3 = self.get_farey_sum_key_mobjects(p1, q1, p2, q2)
l3.set_color(PINK)
self.wait()
self.play(
ShowCreation(c1), ApplyMethod(l1.set_color, YELLOW),
ShowCreation(c2), ApplyMethod(l2.set_color, YELLOW),
)
self.play(
ReplacementTransform(l1.numer.deepcopy(), l3.numer),
ReplacementTransform(l1.line.deepcopy(), l3.line),
ReplacementTransform(l1.denom.deepcopy(), l3.denom),
ReplacementTransform(l2.numer.deepcopy(), l3.numer),
ReplacementTransform(l2.line.deepcopy(), l3.line),
ReplacementTransform(l2.denom.deepcopy(), l3.denom),
ReplacementTransform(c1.deepcopy(), c3),
ReplacementTransform(c2.deepcopy(), c3),
)
self.wait()
self.play(FadeOut(VGroup(c1, c2, c3, l1, l2, l3)))
arranged_terms_list.append(cdots_copy)
arranged_terms = VGroup(*arranged_terms_list)
arranged_terms.arrange_submobjects(RIGHT, buff = 0.2)
arranged_terms.next_to(self.sum_tex, UP, aligned_edge = RIGHT, buff = 0.5)
# Move highlighted terms into position
anims_list = []
for i in range(4):
anims_list.append(
ReplacementTransform(
self.get_highlighted_terms(n)[i].deepcopy(),
arranged_terms[2*i],
lag_ratio = 0, run_time = 2
)
)
anims_list.append(
ReplacementTransform(
self.get_times_symbols()[i].deepcopy(),
arranged_terms[2*i+1],
lag_ratio = 0, run_time = 2
)
)
anims_list.append(
ReplacementTransform(
self.get_cdots_symbol().deepcopy(),
arranged_terms[-1],
lag_ratio = 0, run_time = 2
)
)
self.play(AnimationGroup(*anims_list))
self.wait()
if n == 1:
self.play(
return hasattr(pi, "bubble") and \
pi.bubble is not None and \
pi.bubble in on_screen_mobjects
pi_creatures_with_bubbles = list(filter(has_bubble, self.get_pi_creatures()))
if pi_creature in pi_creatures_with_bubbles:
pi_creatures_with_bubbles.remove(pi_creature)
old_bubble = pi_creature.bubble
bubble = pi_creature.get_bubble(
*content,
bubble_class=bubble_class,
**bubble_kwargs
)
anims += [
ReplacementTransform(old_bubble, bubble),
ReplacementTransform(old_bubble.content, bubble.content),
pi_creature.change_mode, target_mode
]
else:
anims.append(PiCreatureBubbleIntroduction(
pi_creature,
*content,
bubble_class=bubble_class,
bubble_kwargs=bubble_kwargs,
target_mode=target_mode,
**kwargs
))
anims += [
RemovePiCreatureBubble(pi, **bubble_removal_kwargs)
for pi in pi_creatures_with_bubbles
]
anims += added_anims
def has_bubble(pi):
return hasattr(pi, "bubble") and \
pi.bubble is not None and \
pi.bubble in on_screen_mobjects
pi_creatures_with_bubbles = list(filter(has_bubble, self.get_pi_creatures()))
if pi_creature in pi_creatures_with_bubbles:
pi_creatures_with_bubbles.remove(pi_creature)
old_bubble = pi_creature.bubble
bubble = pi_creature.get_bubble(
*content,
bubble_class=bubble_class,
**bubble_kwargs
)
anims += [
ReplacementTransform(old_bubble, bubble),
ReplacementTransform(old_bubble.content, bubble.content),
pi_creature.change_mode, target_mode
]
else:
anims.append(PiCreatureBubbleIntroduction(
pi_creature,
*content,
bubble_class=bubble_class,
bubble_kwargs=bubble_kwargs,
target_mode=target_mode,
**kwargs
))
anims += [
RemovePiCreatureBubble(pi, **bubble_removal_kwargs)
for pi in pi_creatures_with_bubbles
]