diff --git a/active_projects/eop/bayes.py b/active_projects/eop/bayes.py index 3eb0469e..921dbc9e 100644 --- a/active_projects/eop/bayes.py +++ b/active_projects/eop/bayes.py @@ -130,7 +130,7 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): self.play(LaggedStart( ApplyMethod, straight_cards, - lambda m : (m.highlight, YELLOW), + lambda m : (m.set_color, YELLOW), rate_func = there_and_back, run_time = 1.5, lag_ratio = 0.5, @@ -227,7 +227,7 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): ten, UP, aligned_edge = LEFT ) num_hearts.to_edge(UP) - num_hearts.highlight(RED) + num_hearts.set_color(RED) num_hearts_arrow = Arrow( num_hearts.get_bottom(), ten.get_right(), color = RED, buff = SMALL_BUFF @@ -238,7 +238,7 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): num_cards.scale(0.75) num_cards.next_to(fourty_five, LEFT) num_cards.to_edge(LEFT) - num_cards.highlight(BLUE) + num_cards.set_color(BLUE) num_cards_arrow = Arrow( num_cards, fourty_five, color = BLUE, buff = SMALL_BUFF @@ -249,12 +249,12 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): self.play( FadeIn(num_hearts), ShowCreation(num_hearts_arrow), - ten.highlight, RED, + ten.set_color, RED, ) self.play( FadeIn(num_cards), ShowCreation(num_cards_arrow), - fourty_five.highlight, BLUE + fourty_five.set_color, BLUE ) self.wait(3) equation.remove(percentage) @@ -330,7 +330,7 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): for y in range(4) ]).arrange_submobjects(UP, buff = SMALL_BUFF) money = VGroup(*it.chain(*pre_money)) - money.highlight(GREEN) + money.set_color(GREEN) money.scale(0.8) money.next_to(her.hand, DOWN) for dollar in money: @@ -389,7 +389,7 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): def name_bayes_rule(self): title = TextMobject("Bayes' rule") - title.highlight(BLUE) + title.set_color(BLUE) title.to_edge(UP) subtitle = TextMobject("Update ", "prior ", "beliefs") subtitle.scale(0.8) @@ -398,7 +398,7 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): numbers = self.sample_space.horizontal_parts.labels rect = SurroundingRectangle(numbers, color = GREEN) arrow = Arrow(prior_word.get_bottom(), rect.get_top()) - arrow.highlight(GREEN) + arrow.set_color(GREEN) words = TextMobject( "Maybe she really \\\\ does have a flush $\\dots$", @@ -413,7 +413,7 @@ class IntroducePokerHand(PiCreatureScene, SampleSpaceScene): ) self.wait() self.play(FadeIn(subtitle)) - self.play(prior_word.highlight, GREEN) + self.play(prior_word.set_color, GREEN) self.play( ShowCreation(rect), ShowCreation(arrow) @@ -533,8 +533,8 @@ class UpdatePokerPrior(SampleSpaceScene): explanation = TextMobject( "Probability of", "high bet", "given", "flush" ) - explanation.highlight_by_tex("high bet", GREEN) - explanation.highlight_by_tex("flush", RED) + explanation.set_color_by_tex("high bet", GREEN) + explanation.set_color_by_tex("flush", RED) explanation.scale(0.6) explanation.next_to(label, UP) @@ -582,8 +582,8 @@ class UpdatePokerPrior(SampleSpaceScene): explanation = TextMobject( "Probability of", "high bet", "given", "no flush" ) - explanation.highlight_by_tex("high bet", GREEN) - explanation.highlight_by_tex("no flush", RED) + explanation.set_color_by_tex("high bet", GREEN) + explanation.set_color_by_tex("no flush", RED) explanation.scale(0.6) explanation.next_to(label, DOWN) @@ -627,7 +627,7 @@ class UpdatePokerPrior(SampleSpaceScene): randy.shift(2*DOWN) words = TextMobject("Where do these \\\\", "numbers", "come from?") numbers_word = words.get_part_by_tex("numbers") - numbers_word.highlight(YELLOW) + numbers_word.set_color(YELLOW) words.scale(0.7) bubble = ThoughtBubble(height = 3, width = 4) bubble.pin_to(randy) @@ -667,7 +667,7 @@ class UpdatePokerPrior(SampleSpaceScene): Write(words, run_time = 2) ) self.play(*map(ShowCreation, arrows)) - self.play(numbers.highlight, YELLOW) + self.play(numbers.set_color, YELLOW) self.play(Blink(randy)) self.play(randy.change_mode, "maybe") self.play(*map(FadeOut, [ @@ -728,11 +728,11 @@ class UpdatePokerPrior(SampleSpaceScene): for j in range(2) ] words = TexMobject("P(", self.cash_string, ")") - words.highlight_by_tex(self.cash_string, GREEN) + words.set_color_by_tex(self.cash_string, GREEN) words.next_to(self.sample_space, RIGHT) low_bet_space.generate_target() for submob in low_bet_space.target: - submob.highlight(average_color( + submob.set_color(average_color( submob.get_color(), *[BLACK]*4 )) arrows = VGroup(*[ @@ -762,7 +762,7 @@ class UpdatePokerPrior(SampleSpaceScene): "|", self.cash_string, ")" ) posterior_tex.scale(0.7) - posterior_tex.highlight_by_tex(self.cash_string, GREEN) + posterior_tex.set_color_by_tex(self.cash_string, GREEN) self.insert_double_heart(posterior_tex) rects = self.high_bet_space.copy() rects = [rects[0].copy()] + list(rects) @@ -972,8 +972,8 @@ class UpdatePokerPrior(SampleSpaceScene): ] ] for i in 0, 2: - products[i].highlight(prior_rects[0].get_color()) - products[1].highlight(prior_rects[1].get_color()) + products[i].set_color(prior_rects[0].get_color()) + products[1].set_color(prior_rects[1].get_color()) fraction.scale(0.65) fraction.to_corner(UP+RIGHT, buff = MED_SMALL_BUFF) arrow_kwargs = { @@ -1064,7 +1064,7 @@ class UpdatePokerPrior(SampleSpaceScene): "=", str(value) ) self.insert_double_heart(label) - label.highlight_by_tex(self.cash_string, GREEN) + label.set_color_by_tex(self.cash_string, GREEN) label.scale(0.7) return label @@ -1114,8 +1114,8 @@ class BayesRuleInMemory(Scene): "P(", "B", ")", "{P(", D, "|", B, ")", "\\over", "P(", D, ")}" ) - rule.highlight_by_tex(B, RED) - rule.highlight_by_tex(D, GREEN) + rule.set_color_by_tex(B, RED) + rule.set_color_by_tex(D, GREEN) rule.next_to(randy, RIGHT, LARGE_BUFF, UP) rule.generate_target() bubble.add_content(rule.target) @@ -1396,7 +1396,7 @@ class GeneralizeBayesRule(SampleSpaceScene): posterior_word = TextMobject("Posterior") words = [prior_word, posterior_word] for word in words: - word.highlight(YELLOW) + word.set_color(YELLOW) word.scale(0.7) prior_rect = SurroundingRectangle(prior) posterior_rect = SurroundingRectangle(posterior) @@ -1473,7 +1473,7 @@ class GeneralizeBayesRule(SampleSpaceScene): ) for rect, vect in zip(rects, [RIGHT, UP]) ] - VGroup(name, *arrows+rects).highlight(YELLOW) + VGroup(name, *arrows+rects).set_color(YELLOW) morty = Mortimer() morty.scale(0.5) @@ -1537,7 +1537,7 @@ class GeneralizeBayesRule(SampleSpaceScene): self.play(LaggedStart( ApplyMethod, prior_rects, - lambda m : (m.highlight, YELLOW), + lambda m : (m.set_color, YELLOW), rate_func = there_and_back, lag_ratio = 0.7 )) @@ -1567,8 +1567,8 @@ class GeneralizeBayesRule(SampleSpaceScene): #### def color_label(self, label): - label.highlight_by_tex("B", RED) - label.highlight_by_tex("I", GREEN) + label.set_color_by_tex("B", RED) + label.set_color_by_tex("I", GREEN) class MoreExamples(TeacherStudentsScene): def construct(self): @@ -1809,7 +1809,7 @@ class MusicExample(SampleSpaceScene, PiCreatureScene): self.play(negative_space.fade, 0.8) self.play(LaggedStart( ApplyMethod, positive_space, - lambda m : (m.highlight, YELLOW), + lambda m : (m.set_color, YELLOW), rate_func = there_and_back, run_time = 2, lag_ratio = 0.7, @@ -1823,7 +1823,7 @@ class MusicExample(SampleSpaceScene, PiCreatureScene): post_rects = self.get_posterior_rectangles() label = TexMobject("P(S | ", "\\checkmark", ")") label.scale(0.7) - label.highlight_by_tex("\\checkmark", GREEN) + label.set_color_by_tex("\\checkmark", GREEN) braces, labels = self.get_posterior_rectangle_braces_and_labels( post_rects, [label] ) @@ -1914,7 +1914,7 @@ class MusicExample(SampleSpaceScene, PiCreatureScene): self.wait(2) for mob in prior_rects, prior_rects[0]: self.play( - mob.highlight, YELLOW, + mob.set_color, YELLOW, Animation(self.products), rate_func = there_and_back, run_time = 2 @@ -1991,7 +1991,7 @@ class MusicExample(SampleSpaceScene, PiCreatureScene): "\\approx", "0.98" ) label.scale(0.7) - label.highlight_by_tex("\\checkmark", GREEN) + label.set_color_by_tex("\\checkmark", GREEN) braces, labels = self.get_posterior_rectangle_braces_and_labels( post_rects, [label] ) @@ -2065,7 +2065,7 @@ class MusicExample(SampleSpaceScene, PiCreatureScene): "S", ")", "=", str(value) ) - label.highlight_by_tex(positive_str, GREEN) + label.set_color_by_tex(positive_str, GREEN) label.scale(0.7) return label @@ -2133,8 +2133,8 @@ class FinalWordsOnRule(SampleSpaceScene): labels = VGroup(P_B, P_D_given_B, P_D_given_not_B, P_B_given_D) for label in labels: label.scale(0.7) - label.highlight_by_tex(B, BLUE) - label.highlight_by_tex(D, GREEN) + label.set_color_by_tex(B, BLUE) + label.set_color_by_tex(D, GREEN) prior_rects = self.get_prior_rectangles() post_rects = self.get_posterior_rectangles() @@ -2257,8 +2257,8 @@ class Thumbnail(SampleSpaceScene): prior_label = TexMobject("P(", "H", ")") post_label = TexMobject("P(", "H", "|", "D", ")") for label in prior_label, post_label: - label.highlight_by_tex("H", YELLOW) - label.highlight_by_tex("D", GREEN) + label.set_color_by_tex("H", YELLOW) + label.set_color_by_tex("D", GREEN) label.scale(1.5) sample_space = self.get_sample_space() diff --git a/active_projects/eop/bayes_footnote.py b/active_projects/eop/bayes_footnote.py index 28a1bbde..46d82f74 100644 --- a/active_projects/eop/bayes_footnote.py +++ b/active_projects/eop/bayes_footnote.py @@ -73,7 +73,7 @@ class Introduction(TeacherStudentsScene): self.add(name, randy) self.play( randy.change_mode, "sick", - randy.highlight, SICKLY_GREEN + randy.set_color, SICKLY_GREEN ) self.play(ShowCreation(rect)) self.play( @@ -152,7 +152,7 @@ class Introduction(TeacherStudentsScene): bayes_to_intuition.arrange_submobjects(RIGHT, buff = SMALL_BUFF) bayes_to_intuition.next_to(brace, UP, SMALL_BUFF) check = TexMobject("\\checkmark") - check.highlight(GREEN) + check.set_color(GREEN) check.next_to(bayes_to_intuition[1], UP, SMALL_BUFF) for example in examples: @@ -185,7 +185,7 @@ class Introduction(TeacherStudentsScene): def other_culprit(self): bayes = self.bayes_to_intuition[0] something_else = TextMobject("Something else") - something_else.highlight(YELLOW) + something_else.set_color(YELLOW) something_else.scale_to_fit_height(bayes.get_height()) something_else.move_to(bayes, RIGHT) new_group = VGroup( @@ -224,8 +224,8 @@ class Introduction(TeacherStudentsScene): probability = TexMobject( "P(", "\\text{Flush}", "|", "\\text{High bet}", ")" ) - probability.highlight_by_tex("Flush", RED) - probability.highlight_by_tex("High bet", GREEN) + probability.set_color_by_tex("Flush", RED) + probability.set_color_by_tex("High bet", GREEN) probability.scale(0.5) probability.next_to(rect.get_top(), DOWN) @@ -247,8 +247,8 @@ class Introduction(TeacherStudentsScene): probability = TexMobject( "P(", "\\text{Suck }", "|", "\\text{ Good review}", ")" ) - probability.highlight_by_tex("Suck", RED) - probability.highlight_by_tex("Good", GREEN) + probability.set_color_by_tex("Suck", RED) + probability.set_color_by_tex("Good", GREEN) probability.scale(0.5) probability.next_to(rect.get_top(), DOWN) @@ -256,7 +256,7 @@ class Introduction(TeacherStudentsScene): def get_example_rect(self): rect = self.example[0].copy() - rect.highlight(WHITE) + rect.set_color(WHITE) return rect class OneInOneThousandHaveDisease(Scene): @@ -276,17 +276,17 @@ class OneInOneThousandHaveDisease(Scene): randy = all_creatures[0][0] all_creatures[0].remove(randy) randy.change_mode("sick") - randy.highlight(SICKLY_GREEN) + randy.set_color(SICKLY_GREEN) randy.save_state() randy.scale_to_fit_height(3) randy.center() randy.change_mode("plain") - randy.highlight(BLUE) + randy.set_color(BLUE) self.add(randy) self.play( randy.change_mode, "sick", - randy.highlight, SICKLY_GREEN + randy.set_color, SICKLY_GREEN ) self.play(Blink(randy)) self.play(randy.restore) @@ -300,7 +300,7 @@ class TestScene(PiCreatureScene): def get_result(self, creature, word, color): arrow = self.get_test_arrow() test_result = TextMobject(word) - test_result.highlight(color) + test_result.set_color(color) test_result.next_to(arrow.get_end(), RIGHT) group = VGroup(arrow, test_result) group.next_to(creature, RIGHT, aligned_edge = UP) @@ -332,7 +332,7 @@ class TestDiseaseCase(TestScene): def construct(self): randy = self.pi_creature randy.change_mode("sick") - randy.highlight(SICKLY_GREEN) + randy.set_color(SICKLY_GREEN) result = self.get_positive_result(randy) accuracy = TextMobject("100\\% Accuracy") accuracy.next_to(VGroup(randy, result), UP) @@ -365,7 +365,7 @@ class TestNonDiseaseCase(TestScene): all_creatures.to_corner(DOWN+LEFT) last_guy = all_creatures[-1][-1] rect = SurroundingRectangle(last_guy, buff = 0) - rect.highlight(YELLOW) + rect.set_color(YELLOW) self.add(randy, accuracy) self.play(FadeIn(result[0])) @@ -409,7 +409,7 @@ class ReceivePositiveResults(TestScene): result = self.get_positive_result(randy) accuracy = TextMobject("99\% Accuracy") accuracy.next_to(result[1], DOWN, LARGE_BUFF) - accuracy.highlight(YELLOW) + accuracy.set_color(YELLOW) self.add(status, randy) self.play(FadeIn(result[0])) @@ -447,19 +447,19 @@ class RephraseQuestion(Scene): words.scale_to_fit_width(2*(FRAME_X_RADIUS - MED_LARGE_BUFF)) prior = TextMobject("Prior") - prior.highlight(GREEN) + prior.set_color(GREEN) prior.next_to(words[0], UP, 1.5*LARGE_BUFF) prior_arrow = Arrow(prior, words[0]) - prior_arrow.highlight(prior.get_color()) + prior_arrow.set_color(prior.get_color()) posterior = TextMobject("Posterior") posterior.next_to(words[2], UP) posterior.shift( (prior.get_center() - posterior.get_center())[1]*UP ) - posterior.highlight(YELLOW) + posterior.set_color(YELLOW) posterior_arrow = Arrow(posterior, words[2]) - posterior_arrow.highlight(posterior.get_color()) + posterior_arrow.set_color(posterior.get_color()) self.add(words[0]) self.play( @@ -491,7 +491,7 @@ class TryUnitSquareVisual(SampleSpaceScene): hard_to_see.scale(0.7) hard_to_see.next_to(prior_label, UP) hard_to_see.to_edge(UP) - hard_to_see.highlight(YELLOW) + hard_to_see.set_color(YELLOW) arrow = Arrow(hard_to_see, prior_label) self.wait() @@ -532,7 +532,7 @@ class TryUnitSquareVisual(SampleSpaceScene): ) top_label.scale(0.7) top_label.next_to(top_brace, UP) - top_label.highlight_by_tex("+", GREEN) + top_label.set_color_by_tex("+", GREEN) self.play(GrowFromCenter(top_brace)) self.play(FadeIn(top_label)) @@ -545,7 +545,7 @@ class TryUnitSquareVisual(SampleSpaceScene): "P(", "+", "|", "\\text{Not disease}", ")", "=", "1" ) bottom_label.scale(0.7) - bottom_label.highlight_by_tex("+", GREEN) + bottom_label.set_color_by_tex("+", GREEN) braces, labels = bottom_part.get_bottom_braces_and_labels( [bottom_label] ) @@ -585,7 +585,7 @@ class ShowRestrictedSpace(Scene): sick_one_words = TextMobject("1 sick") sick_one_words.next_to(sick_one, RIGHT) sick_one_words.to_edge(RIGHT) - sick_one_words.highlight(SICKLY_GREEN) + sick_one_words.set_color(SICKLY_GREEN) sick_one_arrow = Arrow( sick_one_words, sick_one, color = SICKLY_GREEN @@ -594,7 +594,7 @@ class ShowRestrictedSpace(Scene): healthy_words = TextMobject("999 healthy") healthy_words.next_to(sick_one_words, UP, MED_LARGE_BUFF) healthy_words.shift_onto_screen() - healthy_words.highlight(BLUE) + healthy_words.set_color(BLUE) self.add(title) self.play(LaggedStart(FadeIn, all_creatures)) @@ -632,8 +632,8 @@ class ShowRestrictedSpace(Scene): "P(", "\\text{Test positive }", "|", "\\text{ sick}", ")", "=", "100\\%" ) - equation.highlight_by_tex("positive", YELLOW) - equation.highlight_by_tex("sick", SICKLY_GREEN) + equation.set_color_by_tex("positive", YELLOW) + equation.set_color_by_tex("sick", SICKLY_GREEN) equation.to_corner(UP+LEFT) self.play(Write(equation, run_time = 1)) @@ -646,8 +646,8 @@ class ShowRestrictedSpace(Scene): "P(", "\\text{Test positive }", "|", "\\text{ healthy}", ")", "=", "1\\%" ) - equation.highlight_by_tex("positive", YELLOW) - equation.highlight_by_tex("healthy", BLUE) + equation.set_color_by_tex("positive", YELLOW) + equation.set_color_by_tex("healthy", BLUE) equation.to_corner(UP+LEFT) self.play(ReplacementTransform( @@ -672,7 +672,7 @@ class ShowRestrictedSpace(Scene): GrowFromCenter(brace), LaggedStart( ApplyMethod, false_positives, - lambda pi : (pi.highlight, self.false_positive_color), + lambda pi : (pi.set_color, self.false_positive_color), run_time = 1 ) ) @@ -727,8 +727,8 @@ class ShowRestrictedSpace(Scene): "\\text{ Positive test result}", ")", "\\approx \\frac{1}{11}", "\\approx 9\\%" ) - posterior.highlight_by_tex("Sick", SICKLY_GREEN) - posterior.highlight_by_tex("Positive", YELLOW) + posterior.set_color_by_tex("Sick", SICKLY_GREEN) + posterior.set_color_by_tex("Positive", YELLOW) posterior.to_edge(UP) posterior.shift(LEFT) @@ -741,7 +741,7 @@ class ShowRestrictedSpace(Scene): prior = TexMobject( "P(", "\\text{Sick}", ")", "= 0.1\\%" ) - prior.highlight_by_tex("Sick", SICKLY_GREEN) + prior.set_color_by_tex("Sick", SICKLY_GREEN) prior.move_to(self.posterior, UP+RIGHT) self.revert_to_original_skipping_status() @@ -776,7 +776,7 @@ class ShowRestrictedSpace(Scene): healthy_creatures = VGroup(*it.chain(*all_creatures)) sick_one = all_creatures[-1][0] sick_one.change_mode("sick") - sick_one.highlight(SICKLY_GREEN) + sick_one.set_color(SICKLY_GREEN) healthy_creatures.remove(sick_one) all_creatures.sick_one = sick_one all_creatures.healthy_creatures = healthy_creatures @@ -796,14 +796,14 @@ class DepressingForMedicalTestDesigners(TestScene): checks = VGroup(*[ VGroup(*[ - TexMobject("\\checkmark").highlight(GREEN) + TexMobject("\\checkmark").set_color(GREEN) for y in range(10) ]).arrange_submobjects(DOWN) for x in range(10) ]).arrange_submobjects(RIGHT) cross = TexMobject("\\times") cross.replace(checks[-1][-1]) - cross.highlight(RED) + cross.set_color(RED) Transform(checks[-1][-1], cross).update(1) checks.scale_to_fit_height(6) checks.next_to(title, DOWN) @@ -855,7 +855,7 @@ class HowMuchCanYouChangeThisPrior(ShowRestrictedSpace, PiCreatureScene): new_sick_one = sick_one.copy() new_sick_one.shift(1.3*sick_one.get_width()*RIGHT) sick_one.change_mode("plain") - sick_one.highlight(BLUE_E) + sick_one.set_color(BLUE_E) self.add(new_sick_one) self.sick_one = new_sick_one @@ -958,11 +958,11 @@ class ShowTheFormula(TeacherStudentsScene): rhs = TexMobject("\\approx 0.09") rhs.scale(scale_factor) rhs.move_to(equals_group[-1], LEFT) - rhs.highlight(YELLOW) + rhs.set_color(YELLOW) for mob in formula, alt_numerator: - mob.highlight_by_tex(sick, SICKLY_GREEN) - mob.highlight_by_tex(positive, YELLOW) + mob.set_color_by_tex(sick, SICKLY_GREEN) + mob.set_color_by_tex(positive, YELLOW) #Ask question @@ -1033,8 +1033,8 @@ class SourceOfConfusion(Scene): arrow = Arrow(ORIGIN, self.arrow_width*RIGHT) posterior = TexMobject("P(", "S", "|", "+", ")", "= 0.09") for mob in prior, posterior: - mob.highlight_by_tex("S", SICKLY_GREEN) - mob.highlight_by_tex("+", YELLOW) + mob.set_color_by_tex("S", SICKLY_GREEN) + mob.set_color_by_tex("+", YELLOW) progression = VGroup(prior, arrow, posterior) progression.arrange_submobjects(RIGHT) progression.shift(DOWN) @@ -1079,11 +1079,11 @@ class SourceOfConfusion(Scene): "{P(", "+", "|", "S", ")", "\\over", "P(", "+", ")}" ) - rule.highlight_by_tex("S", SICKLY_GREEN) - rule.highlight_by_tex("+", YELLOW) + rule.set_color_by_tex("S", SICKLY_GREEN) + rule.set_color_by_tex("+", YELLOW) rule.to_corner(UP+RIGHT) rule_rect = SurroundingRectangle(rule) - rule_rect.highlight(BLUE) + rule_rect.set_color(BLUE) rule.save_state() rule.replace(words_rect) rule.scale_in_place(0.9) @@ -1153,7 +1153,7 @@ class StatisticsVsEmpathy(PiCreatureScene): ) self.play( sick_one.change_mode, "sick", - sick_one.highlight, SICKLY_GREEN + sick_one.set_color, SICKLY_GREEN ) self.wait() @@ -1205,12 +1205,12 @@ class PlaneCrashProbability(Scene): "P(\\text{Dying in a }", "\\text{plane}", "\\text{ crash})", "\\approx", "1/", "11{,}000{,}000" ) - plane_prob.highlight_by_tex("plane", BLUE) + plane_prob.set_color_by_tex("plane", BLUE) car_prob = TexMobject( "P(\\text{Dying in a }", "\\text{car}", "\\text{ crash})", "\\approx", "1/", "5{,}000" ) - car_prob.highlight_by_tex("car", YELLOW) + car_prob.set_color_by_tex("car", YELLOW) plane_prob.shift(UP) car_prob.shift( plane_prob.get_part_by_tex("approx").get_center() -\ @@ -1304,8 +1304,8 @@ class IntroduceTelepathyExample(StatisticsVsEmpathy): "P(", "\\text{Telepath }", "|", "\\text{ Correct}", ")", "=", "???" ) - probability.highlight_by_tex("Telepath", BLUE) - probability.highlight_by_tex("Correct", GREEN) + probability.set_color_by_tex("Telepath", BLUE) + probability.set_color_by_tex("Correct", GREEN) probability.to_edge(UP) self.play(morty.change, "confused", randy.eyes) @@ -1396,10 +1396,10 @@ class CompareNumbersInBothExamples(Scene): priors.next_to(likelihoods, UP, LARGE_BUFF) for group in priors, likelihoods: for mob, vect in zip(group, [LEFT, RIGHT]): - mob.highlight_by_tex("Sick", BLUE) - mob.highlight_by_tex("Powers", BLUE) - mob.highlight_by_tex("+", GREEN) - mob.highlight_by_tex("Correct", GREEN) + mob.set_color_by_tex("Sick", BLUE) + mob.set_color_by_tex("Powers", BLUE) + mob.set_color_by_tex("+", GREEN) + mob.set_color_by_tex("Correct", GREEN) mob.scale(0.8) mob.shift(vect*FRAME_X_RADIUS/2) @@ -1420,7 +1420,7 @@ class NonchalantReactionToPositiveTest(TestScene): randy.shift(DOWN+2*RIGHT) result = self.get_positive_result(randy) accuracy = TextMobject("99\\% Accuracy") - accuracy.highlight(YELLOW) + accuracy.set_color(YELLOW) accuracy.next_to(result, DOWN, LARGE_BUFF, RIGHT) self.add(accuracy) @@ -1526,8 +1526,8 @@ class Thumbnail(Scene): prob = TexMobject("P(", "\\text{Sick}", "|", "\\text{Test+}", ")") prob.scale(2) - prob.highlight_by_tex("Sick", YELLOW) - prob.highlight_by_tex("Test", GREEN) + prob.set_color_by_tex("Sick", YELLOW) + prob.set_color_by_tex("Test", GREEN) prob.next_to(randy, RIGHT) self.add(title, randy, prob) diff --git a/active_projects/eop/combinations.py b/active_projects/eop/combinations.py index 8a0c33f6..3da82f0f 100644 --- a/active_projects/eop/combinations.py +++ b/active_projects/eop/combinations.py @@ -77,7 +77,7 @@ class Male(TexMobject): digest_config(self, kwargs) TexMobject.__init__(self, self.tex, **kwargs) self.scale_to_fit_height(self.height) - self.highlight(self.color) + self.set_color(self.color) class Female(Male): CONFIG = { @@ -183,7 +183,7 @@ class ExperienceProblemSolver(PiCreatureScene): for row in rows: for num in row: n = float(num.get_tex_string()) - num.highlight(interpolate_color( + num.set_color(interpolate_color( BLUE, YELLOW, n/10.0 )) @@ -280,8 +280,8 @@ class InitialFiveChooseThreeExample(Scene): number = TexMobject(str(choose(n, k))) equation = VGroup(binomial, TexMobject("="), number) equation.arrange_submobjects(RIGHT, buff = SMALL_BUFF) - equation.highlight(YELLOW) - equation[1].highlight(WHITE) + equation.set_color(YELLOW) + equation[1].set_color(WHITE) binomial_equations.add(equation) for stack, eq in zip(stacks, binomial_equations): @@ -338,7 +338,7 @@ class InitialFiveChooseThreeExample(Scene): line.ones = ones self.play(LaggedStart( ApplyMethod, ones, - lambda mob : (mob.highlight, YELLOW), + lambda mob : (mob.set_color, YELLOW), rate_func = there_and_back, lag_ratio = 0.7, run_time = 1, @@ -352,7 +352,7 @@ class InitialFiveChooseThreeExample(Scene): brace = Brace(VGroup(*stack[:i+1]), LEFT) number.next_to(brace, LEFT) line.save_state() - line.highlight(YELLOW) + line.set_color(YELLOW) self.add(number, brace) self.wait(0.25) self.remove(number, brace) @@ -390,7 +390,7 @@ class InitialFiveChooseThreeExample(Scene): def walk_though_notation(self): equation = self.binomial_equations[3] rect = SurroundingRectangle(equation[0]) - rect.highlight(WHITE) + rect.set_color(WHITE) words = TextMobject("``5 choose 3''") words.next_to(rect, UP) @@ -423,7 +423,7 @@ class InitialFiveChooseThreeExample(Scene): ones = line.ones ones.save_state() self.play( - ones.highlight, YELLOW, + ones.set_color, YELLOW, last_ones.restore, morty.look_at, ones, run_time = 0.25 @@ -434,10 +434,10 @@ class InitialFiveChooseThreeExample(Scene): #### def get_obj1(self): - return TexMobject("1").highlight(self.one_color) + return TexMobject("1").set_color(self.one_color) def get_obj2(self): - return TexMobject("0").highlight(self.zero_color) + return TexMobject("0").set_color(self.zero_color) class SixChooseThreeExample(InitialFiveChooseThreeExample): CONFIG = { @@ -469,8 +469,8 @@ class SixChooseThreeExample(InitialFiveChooseThreeExample): "{%d \\choose %d}"%(self.n, self.k), "=", str(choose(self.n, self.k)) ) - equation.highlight(YELLOW) - equation.highlight_by_tex("=", WHITE) + equation.set_color(YELLOW) + equation.set_color_by_tex("=", WHITE) equation.next_to(stack, RIGHT, LARGE_BUFF) self.add(equation) @@ -492,15 +492,15 @@ class SixChooseThreeExample(InitialFiveChooseThreeExample): brace = Brace(line, UP) n_options = TextMobject(str(self.n), "options") - n_options.highlight_by_tex(str(self.n), YELLOW) + n_options.set_color_by_tex(str(self.n), YELLOW) n_options.next_to(brace, UP) arrows = VGroup(*[ Vector(0.5*UP).next_to(one, DOWN, SMALL_BUFF) for one in line.ones ]) - arrows.highlight(self.one_color) + arrows.set_color(self.one_color) choose_k = TextMobject("Choose", str(self.k), "of them") - choose_k.highlight_by_tex(str(self.k), YELLOW) + choose_k.set_color_by_tex(str(self.k), YELLOW) choose_k.next_to(arrows, DOWN) self.play( @@ -525,7 +525,7 @@ class SixChooseThreeExample(InitialFiveChooseThreeExample): num = TexMobject(str(i+1)) num.next_to(brace, LEFT) line.ones.save_state() - line.ones.highlight(YELLOW) + line.ones.set_color(YELLOW) line.ones.set_stroke(RED, 1) self.add(brace, num) self.wait(0.15) @@ -540,7 +540,7 @@ class SixChooseThreeExample(InitialFiveChooseThreeExample): lhs.next_to(num, LEFT) coming_soon = TextMobject("Coming soon...") coming_soon.next_to(lhs, UP) - coming_soon.highlight(MAROON_B) + coming_soon.set_color(MAROON_B) self.play(*map(FadeIn, [lhs, coming_soon])) self.wait() @@ -564,7 +564,7 @@ class SixChooseThreeExample(InitialFiveChooseThreeExample): ones = line.ones ones.save_state() self.play( - ones.highlight, YELLOW, + ones.set_color, YELLOW, ones.set_stroke, RED, 1, last_ones.restore, run_time = 0.2 @@ -672,14 +672,14 @@ class SixChooseThreeInOtherContext(Scene): # number = TexMobject(str(choose(n, k))) # equation = VGroup(binomial, TexMobject("="), number) # equation.arrange_submobjects(RIGHT, buff = SMALL_BUFF) -# equation.highlight(YELLOW) -# equation[1].highlight(WHITE) +# equation.set_color(YELLOW) +# equation[1].set_color(WHITE) # binomial_equations.add(equation) # new_words = TextMobject("``Binomial coefficients''") # stacks = get_stacks( -# TexMobject("x").highlight(BLUE), -# TexMobject("y").highlight(RED), +# TexMobject("x").set_color(BLUE), +# TexMobject("y").set_color(RED), # n # ) # stacks.to_edge(DOWN, buff = LARGE_BUFF) @@ -717,10 +717,10 @@ class SixChooseThreeInOtherContext(Scene): # line.scale(FRAME_X_RADIUS) # line.next_to(top_stacks, DOWN) -# x = TexMobject("x").highlight(BLUE) -# y = TexMobject("y").highlight(RED) +# x = TexMobject("x").set_color(BLUE) +# y = TexMobject("y").set_color(RED) # add_x, add_y = [ -# TextMobject("Prepend", "$%s$"%s).highlight_by_tex(s, color) +# TextMobject("Prepend", "$%s$"%s).set_color_by_tex(s, color) # for s, color in ("x", BLUE), ("y", RED) # ] # add_x.to_corner(UP+LEFT) @@ -798,8 +798,8 @@ class SixChooseThreeInOtherContext(Scene): # str(choose(n+1, k)) # ) # term[0].scale(0.85, about_point = term[0].get_right()) -# term[0].highlight(YELLOW) -# term[2].highlight(YELLOW) +# term[0].set_color(YELLOW) +# term[2].set_color(YELLOW) # term.scale(0.85) # term.next_to(top_stack.target, UP) @@ -830,8 +830,8 @@ class SixChooseThreeInOtherContext(Scene): # def add_stack(self): # n, k = self.n, self.k -# x = TexMobject("x").highlight(BLUE) -# y = TexMobject("y").highlight(RED) +# x = TexMobject("x").set_color(BLUE) +# y = TexMobject("y").set_color(RED) # stack = get_stack(x, y, n, k) # stack.scale_to_fit_height(self.stack_height) # stack.shift(FRAME_X_RADIUS*LEFT/2) @@ -884,7 +884,7 @@ class SixChooseThreeInOtherContext(Scene): # choose_words = TextMobject("Choose %d"%k) # choose_words.scale(0.9) # choose_words.next_to(letter_set, DOWN) -# choose_words.highlight(YELLOW) +# choose_words.set_color(YELLOW) # self.revert_to_original_skipping_status() # self.play(Write(letter_set, run_time = 1)) @@ -894,9 +894,9 @@ class SixChooseThreeInOtherContext(Scene): # ) # self.wait() # for subset, subset_mob in zip(letter_subsets, subset_mobs): -# VGroup(subset_mob, *subset).highlight(BLUE) +# VGroup(subset_mob, *subset).set_color(BLUE) # self.wait(0.5) -# VGroup(*subset).highlight(WHITE) +# VGroup(*subset).set_color(WHITE) # self.wait() # self.set_variables_as_attrs( @@ -960,9 +960,9 @@ class SixChooseThreeInOtherContext(Scene): # "{n \\choose k} = {n! \\over (n-k)!k!}", # ) # for i in 1, 5, 9: -# formula[i].highlight(BLUE) +# formula[i].set_color(BLUE) # for i in 2, 11, 14: -# formula[i].highlight(YELLOW) +# formula[i].set_color(YELLOW) # self.student_thinks(formula, student_index = 1) # self.play(self.teacher.change, "sassy") @@ -1017,7 +1017,7 @@ class ProbabilityOfKWomenInGroupOfFive(Scene): prob_words = VGroup(*[ TextMobject( "Probability of", str(n), "women?" - ).highlight_by_tex(str(n), YELLOW) + ).set_color_by_tex(str(n), YELLOW) for n in range(self.n_people_per_lineup+1) ]) prob_words.arrange_submobjects(DOWN) @@ -1079,7 +1079,7 @@ class ProbabilityOfKWomenInGroupOfFive(Scene): ) n_possibilities.next_to(self.title, DOWN) twos = VGroup(*n_possibilities[-2::-1]) - twos.highlight(YELLOW) + twos.set_color(YELLOW) two_anims = [ ReplacementTransform( VectorizedPoint(twos[0].get_center()), @@ -1124,7 +1124,7 @@ class ProbabilityOfKWomenInGroupOfFive(Scene): eq_32 = TexMobject("=", "32") eq_32.move_to(twos.get_right()) - eq_32.highlight_by_tex("32", YELLOW) + eq_32.set_color_by_tex("32", YELLOW) self.play( n_possibilities[-1].next_to, eq_32, RIGHT, twos.next_to, eq_32, LEFT, @@ -1183,8 +1183,8 @@ class ProbabilityOfKWomenInGroupOfFive(Scene): ) equation[0].scale_in_place(0.6) equation.arrange_submobjects(RIGHT, SMALL_BUFF) - equation.highlight(YELLOW) - equation.highlight_by_tex("=", WHITE) + equation.set_color(YELLOW) + equation.set_color_by_tex("=", WHITE) equation.next_to(stack, UP) equations.add(equation) @@ -1243,7 +1243,7 @@ class ProbabilityOfKWomenInGroupOfFive(Scene): "=", "{\\quad \\over", "32}", "\\approx", "%0.3f"%(choose(n, k)/32.0) ) - prob_words.highlight_by_tex_to_color_map({ + prob_words.set_color_by_tex_to_color_map({ "female" : MAROON_B, "32" : YELLOW, }) @@ -1270,7 +1270,7 @@ class ProbabilityOfKWomenInGroupOfFive(Scene): Circle().replace(num, dim_to_match = 1).scale_in_place(1.5) for num in numbers ]) - circles.highlight(WHITE) + circles.set_color(WHITE) self.play(LaggedStart(FadeIn, question)) self.play(LaggedStart(ShowCreationThenDestruction, circles)) @@ -1343,7 +1343,7 @@ class TeacherHoldingSomething(TeacherStudentsScene): # def construct(self): # title = TexMobject("2^6 =", "64", "\\text{ Possibilities}") # title.to_edge(UP, buff = MED_SMALL_BUFF) -# title.highlight_by_tex("64", YELLOW) +# title.set_color_by_tex("64", YELLOW) # man, woman = Male(), Female() # stacks = get_stacks(man, woman, 6, vertical_buff = SMALL_BUFF) # stacks.scale_to_fit_height(6.25) @@ -1373,7 +1373,7 @@ class TeacherHoldingSomething(TeacherStudentsScene): # self.wait() # self.play(LaggedStart( # ApplyMethod, women_groups, -# lambda m : (m.highlight, PINK), +# lambda m : (m.set_color, PINK), # lag_ratio = 0.1, # rate_func = wiggle, # run_time = 6, @@ -1385,7 +1385,7 @@ class TeacherHoldingSomething(TeacherStudentsScene): # question = TextMobject( # "How many groups \\\\ of 7 with 3 ", "$\\female$", "?" # ) -# question.highlight_by_tex("female", MAROON_B) +# question.set_color_by_tex("female", MAROON_B) # question.shift(1.5*UP) # self.add(question) @@ -1464,7 +1464,7 @@ class BuildFiveFromFour(ProbabilityOfKWomenInGroupOfFive): eq_16 = TexMobject("=", "16") eq_16.move_to(twos.get_right()) - eq_16.highlight_by_tex("16", YELLOW) + eq_16.set_color_by_tex("16", YELLOW) self.play( n_possibilities[-1].next_to, eq_16, RIGHT, twos.next_to, eq_16, LEFT, @@ -1512,7 +1512,7 @@ class BuildFiveFromFour(ProbabilityOfKWomenInGroupOfFive): self.play(ShowCreation(rect)) for n, lineup in enumerate(stack): lineup_copy = lineup.copy() - lineup_copy.highlight(YELLOW) + lineup_copy.set_color(YELLOW) number = TexMobject(str(n+1)) number.next_to(stack, UP) self.add(lineup_copy, number) @@ -1578,9 +1578,9 @@ class BuildFiveFromFour(ProbabilityOfKWomenInGroupOfFive): #Fill extra slot add_man = TextMobject("Add", "$\\male$") - add_man.highlight_by_tex("male", BLUE) + add_man.set_color_by_tex("male", BLUE) add_woman = TextMobject("Add", "$\\female$") - add_woman.highlight_by_tex("female", MAROON_B) + add_woman.set_color_by_tex("female", MAROON_B) add_man.next_to(ORIGIN, DOWN).to_edge(LEFT) add_woman.to_corner(UP+LEFT) @@ -1654,7 +1654,7 @@ class BuildFiveFromFour(ProbabilityOfKWomenInGroupOfFive): new_numbers.add_to_back(bottom_stacks.numbers[0].copy()) new_numbers.add(top_stacks.numbers[-1].copy()) - new_numbers.highlight(PINK) + new_numbers.set_color(PINK) self.play(Write(new_numbers, run_time = 3)) self.wait() @@ -1912,7 +1912,7 @@ class IntroducePascalsTriangle(Scene): line.next_to(num, LEFT) else: line.next_to(num, DOWN, MED_LARGE_BUFF) - self.highlight_num(num) + self.set_color_num(num) self.add(line) if n < self.max_n: self.wait(0.25) @@ -1924,12 +1924,12 @@ class IntroducePascalsTriangle(Scene): num = rows[self.max_n][k] line = get_stack(Female(), Male(), self.max_n, k)[0] line.next_to(num, DOWN, MED_LARGE_BUFF) - self.highlight_num(num) + self.set_color_num(num) self.add(line) self.wait(0.5) self.dehighlight_num(num) self.remove(line) - num.highlight(YELLOW) + num.set_color(YELLOW) num.scale_in_place(1.2) self.add(line) self.wait() @@ -1965,7 +1965,7 @@ class IntroducePascalsTriangle(Scene): "P(4", "\\female", "\\text{ out of }", "9", ")", "=" ) expr.move_to(num.get_left()) - expr.highlight_by_tex("female", MAROON_B) + expr.set_color_by_tex("female", MAROON_B) nine_choose_four_term = self.nine_choose_four_term.copy() nine_choose_four_term.generate_target() nine_choose_four_term.target.scale(1./1.2) @@ -1998,7 +1998,7 @@ class IntroducePascalsTriangle(Scene): show_random_lines(6) self.play( self.nine_choose_four_term.scale_in_place, 1./1.2, - self.nine_choose_four_term.highlight, WHITE, + self.nine_choose_four_term.set_color, WHITE, *map(FadeOut, [ expr, nine_choose_four_term, over_512, eq_result, self.curr_line @@ -2045,12 +2045,12 @@ class IntroducePascalsTriangle(Scene): ### - def highlight_num(self, num): - num.highlight(YELLOW) + def set_color_num(self, num): + num.set_color(YELLOW) num.scale_in_place(1.2) def dehighlight_num(self, num): - num.highlight(WHITE) + num.set_color(WHITE) num.scale_in_place(1.0/1.2) class StacksApproachBellCurve(Scene): @@ -2315,7 +2315,7 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene): self.wait() self.play( ReplacementTransform(line_rect, full_line_rect), - triplet.highlight, YELLOW + triplet.set_color, YELLOW ) self.wait(2) self.play( @@ -2336,7 +2336,7 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene): aligned_edge = UP, ) updownarrow = TexMobject("\\Updownarrow") - updownarrow.highlight(YELLOW) + updownarrow.set_color(YELLOW) updownarrow.next_to(triplet, DOWN, SMALL_BUFF) permutations = VGroup() for indices in it.permutations(range(len(triplet))): @@ -2350,7 +2350,7 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene): words = TextMobject("``Order doesn't matter''") words.scale(0.75) - words.highlight(BLUE) + words.set_color(BLUE) words.next_to(permutations, DOWN) self.play(ReplacementTransform( @@ -2392,7 +2392,7 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene): q_marks = TextMobject("???") q_marks.next_to(odm_words, DOWN) - q_marks.highlight(YELLOW) + q_marks.set_color(YELLOW) self.play( LaggedStart( @@ -2418,12 +2418,12 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene): line.sort_submobjects(lambda p : p[0]) words = VGroup(*map(TextMobject, ["First", "Second", "Fifth"])) - words.highlight(YELLOW) + words.set_color(YELLOW) words.scale(0.75) word_arrow_groups = VGroup() for i, word in zip([0, 1, 4], words): arrow = Vector(0.5*DOWN) - arrow.highlight(YELLOW) + arrow.set_color(YELLOW) arrow.next_to(line[i], UP, SMALL_BUFF) word.next_to(arrow, UP, SMALL_BUFF) word_arrow_groups.add(VGroup(word, arrow)) @@ -2450,7 +2450,7 @@ class ChooseThreeFromFive(InitialFiveChooseThreeExample, PiCreatureScene): lambda m : "1" in m.get_tex_string(), line )).copy() - ones.highlight(YELLOW) + ones.set_color(YELLOW) all_ones.add(ones) self.play( @@ -2538,11 +2538,11 @@ class SubsetProbabilityExample(ChooseThreeFromFive): "Choose 3 people randomly.\\\\", "Probability", "Ali", "is one of them?" ) - words.highlight_by_tex("Ali", self.people[0].get_color()) + words.set_color_by_tex("Ali", self.people[0].get_color()) words.next_to(pi_name_groups, DOWN, 2*LARGE_BUFF) - checkmark = TexMobject("\\checkmark").highlight(GREEN) - cross = TexMobject("\\times").highlight(RED) + checkmark = TexMobject("\\checkmark").set_color(GREEN) + cross = TexMobject("\\times").set_color(RED) for mob in checkmark, cross: mob.scale(2) mob.next_to(self.braces, DOWN, aligned_edge = LEFT) @@ -2599,7 +2599,7 @@ class SubsetProbabilityExample(ChooseThreeFromFive): "{5 \\choose 3}", "=", "10", buff = MED_LARGE_BUFF ) - total_count.highlight(BLUE) + total_count.set_color(BLUE) self.play( GrowFromCenter(brace), Write(total_count), @@ -2631,7 +2631,7 @@ class SubsetProbabilityExample(ChooseThreeFromFive): self.play( ShowCreation(rect), - alis.highlight, YELLOW + alis.set_color, YELLOW ) for pair in it.combinations(names[1:], 2): arrows = VGroup() @@ -2658,7 +2658,7 @@ class SubsetProbabilityExample(ChooseThreeFromFive): for x in range(20): name_rect = SurroundingRectangle(random.choice(name_triplets)) - name_rect.highlight(BLUE) + name_rect.set_color(BLUE) name_rect.set_fill(BLUE, opacity = 0.25) self.play(Animation(name_rect, run_time = 0)) self.wait(0.25) @@ -3089,8 +3089,8 @@ class NineChooseFourExample(HowToComputeNChooseK): def show_n_choose_k_pattern(self): n, k = self.n, self.k stack = get_stack( - TexMobject("1").highlight(PINK), - TexMobject("0").highlight(BLUE), + TexMobject("1").set_color(PINK), + TexMobject("0").set_color(BLUE), n, k ) l = len(stack) @@ -3184,7 +3184,7 @@ class NineChooseFourExample(HowToComputeNChooseK): mob.cross = Cross(mob) mob.cross.set_stroke("red", 5) two = TexMobject("2") - two.highlight(eight.get_fill_color()) + two.set_color(eight.get_fill_color()) two.next_to(eight, UP) rhs.next_to(fraction, RIGHT) @@ -3251,7 +3251,7 @@ class WeirdKindOfCancelation(TeacherStudentsScene): #Go through numerators for num, name in zip(top_numbers[::2], chosen_names): rect = SurroundingRectangle(num) - name.target.highlight(num.get_color()) + name.target.set_color(num.get_color()) self.play( ShowCreationThenDestruction(rect), MoveToTarget(name), @@ -3297,7 +3297,7 @@ class ABCNotBCA(Scene): def construct(self): words = TextMobject("If order mattered:") equation = TextMobject("(A, B, C) $\\ne$ (B, C, A)") - equation.highlight(YELLOW) + equation.set_color(YELLOW) equation.next_to(words, DOWN) group = VGroup(words, equation) group.scale_to_fit_width(FRAME_WIDTH - 1) @@ -3317,9 +3317,9 @@ class ShowFormula(Scene): "k \\cdot (k-1) \\cdots 2 \\cdot 1}" ) for i, j in (0, 1), (2, 0), (2, 3), (2, 11): - general_formula[i][j].highlight(BLUE) + general_formula[i][j].set_color(BLUE) for i, j in (0, 2), (2, 13), (4, 0), (4, 3): - general_formula[i][j].highlight(YELLOW) + general_formula[i][j].set_color(YELLOW) formulas = VGroup(specific_formula, general_formula) formulas.arrange_submobjects(DOWN, buff = 2) formulas.to_edge(UP) @@ -3355,8 +3355,8 @@ class SumsToPowerOf2(Scene): def setup_stacks(self): stacks = get_stacks( - TexMobject("1").highlight(PINK), - TexMobject("0").highlight(BLUE), + TexMobject("1").set_color(PINK), + TexMobject("0").set_color(BLUE), n = self.n, vertical_buff = SMALL_BUFF, ) @@ -3398,11 +3398,11 @@ class SumsToPowerOf2(Scene): sum_group.shift(MED_LARGE_BUFF*RIGHT) for i, line in zip(it.count(1), lines): - line_copy = line.copy().highlight(YELLOW) + line_copy = line.copy().set_color(YELLOW) number = Integer(i) number.scale(1.5) number.to_edge(UP) - VGroup(number, line_copy).highlight(YELLOW) + VGroup(number, line_copy).set_color(YELLOW) self.add(line_copy, number) self.wait(0.15) self.remove(line_copy, number) @@ -3411,7 +3411,7 @@ class SumsToPowerOf2(Scene): self.wait() sum_result.target = TexMobject(str(2**self.n)) - sum_result.target.highlight(sum_result.get_color()) + sum_result.target.set_color(sum_result.get_color()) sum_result.target.next_to(sum_group, RIGHT) rhs.next_to(sum_result.target, RIGHT, aligned_edge = DOWN) self.play( @@ -3472,7 +3472,7 @@ class SumsToPowerOf2(Scene): str(2**self.alt_n), "=", "2^{%d}"%(self.alt_n) ) - rhs[0].highlight(YELLOW) + rhs[0].set_color(YELLOW) rhs.next_to(sum_group, RIGHT) self.play( @@ -3518,20 +3518,20 @@ class AskWhyTheyAreCalledBinomial(TeacherStudentsScene): "Bi", "nomials", arg_separator = "", ) - binomial_word.highlight_by_tex("Bi", YELLOW) - binomial_word.highlight_by_tex("nomials", WHITE) + binomial_word.set_color_by_tex("Bi", YELLOW) + binomial_word.set_color_by_tex("nomials", WHITE) binomial_word.next_to(example_binomials, LEFT, buff = 1.5) arrows = VGroup(*[ Arrow(binomial_word.get_right(), binom.get_left()) for binom in example_binomials ]) - arrows.highlight(BLUE) + arrows.set_color(BLUE) two_variables = TextMobject("Two", "variables") two_variables.next_to(binomial_word, DOWN) two_variables.shift(SMALL_BUFF*LEFT) for tv, bw in zip(two_variables, binomial_word): - tv.highlight(bw.get_color()) + tv.set_color(bw.get_color()) self.student_says( "Why are they called \\\\ ``binomial coefficients''?" @@ -3646,13 +3646,13 @@ class CombinationsPatreonEndScreen(PatreonEndScreen): class Thumbnail(Scene): def construct(self): n_choose_k = TexMobject("n \\choose k") - n_choose_k[1].highlight(YELLOW) - n_choose_k[2].highlight(YELLOW) + n_choose_k[1].set_color(YELLOW) + n_choose_k[2].set_color(YELLOW) n_choose_k.scale(2) n_choose_k.to_edge(UP) stacks = get_stacks( - TexMobject("1").highlight(PINK), - TexMobject("0").highlight(BLUE), + TexMobject("1").set_color(PINK), + TexMobject("0").set_color(BLUE), n = 5, vertical_buff = SMALL_BUFF, ) stacks.to_edge(DOWN) diff --git a/active_projects/eop/independence.py b/active_projects/eop/independence.py index 9741de22..da830909 100644 --- a/active_projects/eop/independence.py +++ b/active_projects/eop/independence.py @@ -55,7 +55,7 @@ def get_quiz(*questions): content.arrange_submobjects(DOWN, buff = MED_SMALL_BUFF) rect = SurroundingRectangle(content, buff = MED_LARGE_BUFF) rect.shift(MED_SMALL_BUFF*DOWN) - rect.highlight(WHITE) + rect.set_color(WHITE) quiz = VGroup(rect, content) quiz.questions = q_mobs quiz.scale(0.7) @@ -101,11 +101,11 @@ def get_slot_group( mob = VectorizedPoint() elif bool_list[i]: mob = TexMobject("\\checkmark") - mob.highlight(GREEN) + mob.set_color(GREEN) slot_group.shift(total_height*DOWN / (base**(i+1))) else: mob = TexMobject("\\times") - mob.highlight(RED) + mob.set_color(RED) slot_group.shift(total_height*UP / (base**(i+1))) mob.next_to(line, UP, SMALL_BUFF) slot_group.content.add(mob) @@ -240,7 +240,7 @@ class MeaningOfIndependence(SampleSpaceScene): word = TextMobject("Independence") word.scale(1.5) word.next_to(self.sample_space, RIGHT, buff = LARGE_BUFF) - word.highlight(RED) + word.set_color(RED) self.play(*it.chain( self.get_top_conditional_change_anims(0.7), @@ -347,11 +347,11 @@ class IntroduceBinomial(Scene): "(1-", "p", ")", "^{n-", "k}", arg_separator = "" ) - formula.highlight_by_tex("k", BLUE) - formula.highlight_by_tex("p", YELLOW) + formula.set_color_by_tex("k", BLUE) + formula.set_color_by_tex("p", YELLOW) choose_part = formula.get_part_by_tex("choose") - choose_part.highlight(WHITE) - choose_part[-2].highlight(BLUE) + choose_part.set_color(WHITE) + choose_part[-2].set_color(BLUE) formula.next_to(title, DOWN, MED_LARGE_BUFF) self.formula = formula @@ -391,7 +391,7 @@ class IntroduceBinomial(Scene): triangle.move_to(interval.number_to_point(self.p), DOWN) label = TexMobject("p") label.next_to(triangle, UP, SMALL_BUFF) - label.highlight(triangle.get_color()) + label.set_color(triangle.get_color()) self.p_slider = VGroup(interval, triangle, label) self.play(Write(self.p_slider, run_time = 1)) @@ -405,7 +405,7 @@ class IntroduceBinomial(Scene): assumption = TextMobject("Independence assumption") assumption.scale(1.2) assumption.next_to(self.formula, DOWN, MED_LARGE_BUFF, LEFT) - assumption.highlight(GREEN_C) + assumption.set_color(GREEN_C) self.play(Write(assumption, run_time = 2)) self.wait() @@ -414,7 +414,7 @@ class IntroduceBinomial(Scene): def cross_out_assumption(self): cross = Cross(self.assumption) - cross.highlight(GREY) + cross.set_color(GREY) self.bar_chart.save_state() self.play(ShowCreation(cross)) @@ -438,7 +438,7 @@ class IntroduceBinomial(Scene): corner = bar.get_corner(DOWN+vect) bar.stretch(0.5, 0) bar.move_to(corner, DOWN+vect) - old_bars.target.highlight(RED) + old_bars.target.set_color(RED) old_bars.target.fade() self.play( @@ -494,7 +494,7 @@ class IntroduceQuiz(PiCreatureScene): VGroup(*[ TexMobject( "P(", s_tex, "=", str(score), ")", rhs - ).highlight_by_tex_to_color_map({ + ).set_color_by_tex_to_color_map({ str(score) : YELLOW, "text" : GREEN, }) @@ -566,7 +566,7 @@ class IntroduceQuiz(PiCreatureScene): "= 0.8" ) prob.to_corner(UP+RIGHT) - prob.highlight_by_tex("text", GREEN) + prob.set_color_by_tex("text", GREEN) rect = SurroundingRectangle(prob, buff = MED_SMALL_BUFF) self.play( @@ -685,7 +685,7 @@ class AssociatePatternsWithScores(BreakDownQuestionPatterns): score_groups[sum(slot_group.bool_list)].add(slot_group) for i, score_group in enumerate(score_groups): score = TextMobject("Score", "=", str(i)) - score.highlight_by_tex("Score", GREEN) + score.set_color_by_tex("Score", GREEN) scores.add(score) score_group.organized = score_group.deepcopy() score_group.organized.arrange_submobjects(UP, buff = SMALL_BUFF) @@ -742,7 +742,7 @@ class AssociatePatternsWithScores(BreakDownQuestionPatterns): self.randy.change, "pondering", LaggedStart(FadeIn, triangle, run_time = 4), ) - self.play(row.highlight, YELLOW) + self.play(row.set_color, YELLOW) self.wait(4) class BeforeCounting(TeacherStudentsScene): @@ -801,7 +801,7 @@ class TemptingButWrongCalculation(BreakDownQuestionPatterns): rhs.arrange_submobjects(RIGHT, SMALL_BUFF) rhs.next_to(lhs, RIGHT, SMALL_BUFF) for part, b in zip(rhs, slot_group.bool_list): - part.highlight_by_tex_to_color_map({ + part.set_color_by_tex_to_color_map({ "checkmark" : GREEN, "times" : RED, }) @@ -810,7 +810,7 @@ class TemptingButWrongCalculation(BreakDownQuestionPatterns): value = TexMobject("(0.8)") else: value = TexMobject("(0.2)") - value.highlight(part[1].get_color()) + value.set_color(part[1].get_color()) value.next_to(brace, UP) part.brace = brace part.value = value @@ -922,7 +922,7 @@ class ThousandPossibleQuizzes(Scene): split.generate_target() split.target.shift(MED_LARGE_BUFF*vect) for quiz in split.target: - quiz[0].highlight(color) + quiz[0].set_color(color) labels = VGroup() for num, b, split in (800, True, top_split), (200, False, bottom_split): @@ -992,7 +992,7 @@ class ThousandPossibleQuizzes(Scene): for split, color in (left_split, GREEN_E), (right_split, RED_E): split.generate_target() for quiz in split.target: - quiz[1].highlight(color) + quiz[1].set_color(color) left_split.target.shift(LEFT) left_label = VGroup( @@ -1010,7 +1010,7 @@ class ThousandPossibleQuizzes(Scene): self.play(FadeIn(left_label)) self.play(LaggedStart( ApplyMethod, left_split, - lambda m : (m.highlight, YELLOW), + lambda m : (m.set_color, YELLOW), rate_func = there_and_back, lag_ratio = 0.2, )) @@ -1026,12 +1026,12 @@ class ThousandPossibleQuizzes(Scene): movers = VGroup(*right_split[:self.n_movers]) movers.generate_target() for quiz in movers.target: - quiz[1].highlight(left_split[0][1].get_color()) + quiz[1].set_color(left_split[0][1].get_color()) movers.target.shift(LEFT) new_equation = TexMobject("(0.925)", "800 =", "740") for i in 0, 2: - new_equation[i].highlight(YELLOW) + new_equation[i].set_color(YELLOW) new_equation.move_to(left_label_equation) self.play( @@ -1066,13 +1066,13 @@ class ThousandPossibleQuizzes(Scene): for split, color in (left_split, GREEN_E), (right_split, RED_E): split.generate_target() for quiz in split.target: - quiz[1].highlight(color) + quiz[1].set_color(color) left_split.target.shift(LEFT) movers = VGroup(*left_split[-self.n_movers:]) movers.generate_target() for quiz in movers.target: - quiz[1].highlight(right_split.target[0][1].get_color()) + quiz[1].set_color(right_split.target[0][1].get_color()) equation = TexMobject("(0.8)", "200 = ", "160") slot_group = get_slot_group([False, True], buff = SMALL_BUFF, include_qs = False) @@ -1081,7 +1081,7 @@ class ThousandPossibleQuizzes(Scene): label.next_to(left_split.target, UP, SMALL_BUFF, LEFT) alt_equation = TexMobject("(0.3)", "200 = ", "60") for i in 0, 2: - alt_equation[i].highlight(YELLOW) + alt_equation[i].set_color(YELLOW) alt_equation.move_to(equation) self.play(top_group.to_edge, UP, SMALL_BUFF) @@ -1126,7 +1126,7 @@ class ThousandPossibleQuizzes(Scene): equation = TexMobject("740", "+", "60", "=", "800") for tex in "740", "60": - equation.highlight_by_tex(tex, YELLOW) + equation.set_color_by_tex(tex, YELLOW) slot_group = get_slot_group([True, True]) slot_group.content[0].set_fill(BLACK, 0) label = VGroup(equation, slot_group) @@ -1166,9 +1166,9 @@ class ThousandPossibleQuizzes(Scene): top_movers.target = bottom_movers.copy().shift(LEFT) bottom_movers.target = top_movers.copy().shift(RIGHT) for quiz in top_movers.target: - quiz[0].highlight(RED) + quiz[0].set_color(RED) for quiz in bottom_movers.target: - quiz[0].highlight(GREEN) + quiz[0].set_color(GREEN) line = Line(UP, DOWN, color = YELLOW) line.scale_to_fit_height(self.quizzes.get_height()) @@ -1197,9 +1197,9 @@ class ThousandPossibleQuizzes(Scene): bottom_part = VGroup(*split.target[n:]) bottom_part.shift(MED_SMALL_BUFF*DOWN) for quiz in top_part: - quiz[-1].highlight(GREEN) + quiz[-1].set_color(GREEN) for quiz in bottom_part: - quiz[-1].highlight(RED) + quiz[-1].set_color(RED) split = self.top_left_split n_all_right = int(proportions[0]*len(split)) @@ -1214,7 +1214,7 @@ class ThousandPossibleQuizzes(Scene): self.wait() self.play(LaggedStart( ApplyMethod, all_right, - lambda m : (m.highlight, YELLOW), + lambda m : (m.set_color, YELLOW), rate_func = there_and_back, lag_ratio = 0.2, run_time = 2 @@ -1253,7 +1253,7 @@ class ExampleConditional(Scene): [True, True], [True] ) rhs = TexMobject("=", "0.925", ">", "0.8") - rhs.highlight_by_tex("0.925", YELLOW) + rhs.set_color_by_tex("0.925", YELLOW) rhs.next_to(prob, RIGHT) expression = VGroup(prob, rhs) expression.scale_to_fit_width(FRAME_WIDTH - 1) @@ -1311,7 +1311,7 @@ class SubmitToTemptation(TemptingButWrongCalculation): title.generate_target() title.target.scale_in_place(1./1.5) new_words = TextMobject("and", "okay", "assuming independence.") - new_words.highlight_by_tex("okay", GREEN) + new_words.set_color_by_tex("okay", GREEN) new_words.next_to(title.target, RIGHT) VGroup(title.target, new_words).center().to_edge(UP) @@ -1566,7 +1566,7 @@ class ShowIndependenceSymbolically(Scene): def construct(self): filler_tex = "Filler" rhs = TexMobject("=", "0.8") - rhs.highlight_by_tex("0.8", YELLOW) + rhs.set_color_by_tex("0.8", YELLOW) rhs.next_to(ORIGIN, RIGHT, LARGE_BUFF) lhs = TexMobject("P(", filler_tex, "|", filler_tex, ")") lhs.next_to(rhs, LEFT) @@ -1587,9 +1587,9 @@ class ShowIndependenceSymbolically(Scene): ] arrow = Arrow(UP, DOWN) arrow.next_to(condition, UP) - arrow.highlight(RED) + arrow.set_color(RED) words = TextMobject("Doesn't matter") - words.highlight(RED) + words.set_color(RED) words.next_to(arrow, UP) self.add(rhs, lhs, arrow, words) @@ -1626,8 +1626,8 @@ class ComputeProbabilityOfOneWrong(Scene): probs[i] = "(%s)"%self.default_q lhs = get_probability_of_slot_group(bool_list) rhs = TexMobject("=", *probs) - rhs.highlight_by_tex("0.8", GREEN) - rhs.highlight_by_tex("0.2", RED) + rhs.set_color_by_tex("0.8", GREEN) + rhs.set_color_by_tex("0.2", RED) point_8s.add(*rhs.get_parts_by_tex("0.8")) point_2s.add(*rhs.get_parts_by_tex("0.2")) rhs.next_to(lhs, RIGHT) @@ -1656,14 +1656,14 @@ class ComputeProbabilityOfOneWrong(Scene): "P(", "\\text{Score} = %s"%self.score, ")", "=", *self.final_result_rhs_tex ) - result.highlight_by_tex_to_color_map({ + result.set_color_by_tex_to_color_map({ "0.8" : GREEN, "0.2" : RED, "Score" : YELLOW, }) - result[-1].highlight(YELLOW) - result.highlight_by_tex("0.8", GREEN) - result.highlight_by_tex("0.2", RED) + result[-1].set_color(YELLOW) + result.set_color_by_tex("0.8", GREEN) + result.set_color_by_tex("0.2", RED) result.to_edge(UP) self.play(Write(result)) @@ -1719,11 +1719,11 @@ class ShowFullDistribution(Scene): scores.shift(MED_LARGE_BUFF*UP) scores.to_edge(LEFT) for score in scores: - score.highlight_by_tex_to_color_map({ + score.set_color_by_tex_to_color_map({ "0.8" : GREEN, "0.2" : RED, }) - score[-1].highlight(YELLOW) + score[-1].set_color(YELLOW) self.add(*scores[1:3]) self.scores = scores @@ -1771,7 +1771,7 @@ class ShowFullDistribution(Scene): for k in range(4) ]) for term, bar in zip(new_p_terms, chart.bars): - term[1].highlight(YELLOW) + term[1].set_color(YELLOW) term.scale_to_fit_width(1.5*bar.get_width()) term.next_to(bar, UP) @@ -1832,7 +1832,7 @@ class ShowFullDistribution(Scene): new_prob = TexMobject( "P(", "\\text{Correct}", ")", "=", "0.8" ) - new_prob.highlight_by_tex("Correct", GREEN) + new_prob.set_color_by_tex("Correct", GREEN) new_prob.shift(FRAME_X_RADIUS*RIGHT/2) new_prob.to_edge(UP) @@ -1841,7 +1841,7 @@ class ShowFullDistribution(Scene): alt_charts = VGroup() for p in alt_ps: rhs = TexMobject(str(p)) - rhs.highlight(YELLOW) + rhs.set_color(YELLOW) rhs.move_to(new_prob[-1]) alt_rhss.add(rhs) @@ -1915,7 +1915,7 @@ class ShowTrueDistribution(PiCreatureScene): def add_title(self): title = TexMobject("P(", "\\text{Correct}", ")", "=", "0.65") title.to_edge(UP) - title.highlight_by_tex("Correct", GREEN) + title.set_color_by_tex("Correct", GREEN) self.add(title) self.title = title @@ -1936,7 +1936,7 @@ class ShowTrueDistribution(PiCreatureScene): mob.get_corner(DOWN+vect), mob.target.stretch, 0.5, 0 ) - old_bar.target.highlight(average_color(RED_E, BLACK)) + old_bar.target.set_color(average_color(RED_E, BLACK)) old_bar.target.set_stroke(width = 0) arrow = Arrow(ORIGIN, UP, buff = 0, color = GREEN) arrow.move_to(bar.get_bottom()) @@ -1944,7 +1944,7 @@ class ShowTrueDistribution(PiCreatureScene): arrows.add(arrow) for arrow in arrows[1:3]: arrow.rotate_in_place(np.pi) - arrow.highlight(RED) + arrow.set_color(RED) arrows.gradient_highlight(BLUE, YELLOW) self.add(chart) @@ -2009,7 +2009,7 @@ class TeacherAssessingLiklihoodOfZero(TeacherStudentsScene): def add_title(self): title = TexMobject("P(", "\\text{Correct}", ")", "=", "0.65") title.to_edge(UP) - title.highlight_by_tex("Correct", GREEN) + title.set_color_by_tex("Correct", GREEN) q_mark = TexMobject("?") q_mark.next_to(title[-2], UP, SMALL_BUFF) title.add(q_mark) @@ -2025,7 +2025,7 @@ class TeacherAssessingLiklihoodOfZero(TeacherStudentsScene): def show_independence_probability(self): prob = get_probability_of_slot_group(3*[False]) rhs = TexMobject("=", "(0.35)", "^3", "\\approx 4.3\\%") - rhs.highlight_by_tex("0.35", RED) + rhs.set_color_by_tex("0.35", RED) rhs.next_to(prob, RIGHT) prob.add(rhs) prob.next_to(self.teacher, UP+LEFT) @@ -2101,7 +2101,7 @@ class CorrelationsWith35Percent(ThousandPossibleQuizzes): for part, color in zip(parts, [GREEN, RED]): part.generate_target() for quiz in part.target: - quiz[0].highlight(color) + quiz[0].set_color(color) top_part.target.shift(UP) brace = Brace(bottom_part, LEFT) prop = TexMobject("0.35") @@ -2136,7 +2136,7 @@ class CorrelationsWith35Percent(ThousandPossibleQuizzes): for part, color in zip(parts, [GREEN, RED_E]): part.generate_target() for quiz in part.target: - quiz[1].highlight(color) + quiz[1].set_color(color) left_part.target.shift(LEFT) brace = Brace(right_part, UP) prop = TexMobject(">0.35") @@ -2169,7 +2169,7 @@ class CorrelationsWith35Percent(ThousandPossibleQuizzes): for part, color in zip(parts, [GREEN, RED_B]): part.generate_target() for quiz in part.target: - quiz[2].highlight(color) + quiz[2].set_color(color) top_part.target.shift(0.5*UP) brace = Brace(bottom_part, LEFT) prop = TexMobject("\\gg 0.35") @@ -2218,8 +2218,8 @@ class WeighingIndependenceAssumption(PiCreatureScene): "P(", "A", "B", ")", "=" "P(", "A", ")", "P(", "B", ")" ) - formula.highlight_by_tex("A", BLUE) - formula.highlight_by_tex("B", GREEN) + formula.set_color_by_tex("A", BLUE) + formula.set_color_by_tex("B", GREEN) clean = TextMobject("Clean") clean.next_to(formula, UP) @@ -2272,7 +2272,7 @@ class NameBinomial(Scene): probability = TexMobject( "P(", "\\checkmark", ")", "=", str(p) ) - probability.highlight_by_tex("checkmark", GREEN) + probability.set_color_by_tex("checkmark", GREEN) probability.move_to(charts, UP) title = TextMobject("``Binomial distribution''") @@ -2285,11 +2285,11 @@ class NameBinomial(Scene): "(1-", "p", ")", "^{n-", "k}", arg_separator = "" ) - formula.highlight_by_tex("p", YELLOW) - formula.highlight_by_tex("k", GREEN) + formula.set_color_by_tex("p", YELLOW) + formula.set_color_by_tex("k", GREEN) choose_part = formula.get_part_by_tex("choose") - choose_part.highlight(WHITE) - choose_part[-2].highlight(GREEN) + choose_part.set_color(WHITE) + choose_part[-2].set_color(GREEN) formula.to_corner(UP+RIGHT) self.add(charts[0], probability) @@ -2312,7 +2312,7 @@ class NameBinomial(Scene): def add_quiz_questions(self): n = 10 checkmarks = VGroup(*[ - TexMobject("\\checkmark").highlight(GREEN) + TexMobject("\\checkmark").set_color(GREEN) for x in range(n) ]) checkmarks.arrange_submobjects(DOWN, buff = 0.3) @@ -2320,7 +2320,7 @@ class NameBinomial(Scene): arrows = VGroup() for checkmark in checkmarks: cross = TexMobject("\\times") - cross.highlight(RED) + cross.set_color(RED) cross.next_to(checkmark, RIGHT, LARGE_BUFF) crosses.add(cross) arrow = Arrow( @@ -2448,9 +2448,9 @@ class NameBinomial(Scene): prob = TexMobject( "P(", "\\# \\text{Girls}", "=", "6", ")" ) - prob.highlight_by_tex("Girls", MAROON_B) + prob.set_color_by_tex("Girls", MAROON_B) arrow = Arrow(UP, ORIGIN, tip_length = 0.15) - arrow.highlight(MAROON_B) + arrow.set_color(MAROON_B) arrow.next_to(prob, DOWN) prob.add(arrow) prob.next_to(chart_rect, UP) @@ -2513,10 +2513,10 @@ class NameBinomial(Scene): ## def get_male(self): - return TexMobject("\\male").scale(1.3).highlight(BLUE) + return TexMobject("\\male").scale(1.3).set_color(BLUE) def get_female(self): - return TexMobject("\\female").scale(1.3).highlight(MAROON_B) + return TexMobject("\\female").scale(1.3).set_color(MAROON_B) class CycleThroughPatterns(NameBinomial): CONFIG = { @@ -2536,8 +2536,8 @@ class CycleThroughPatterns(NameBinomial): "?", arg_separator = "" ) - question.highlight_by_tex("male", BLUE) - question.highlight_by_tex("female", MAROON_B) + question.set_color_by_tex("male", BLUE) + question.set_color_by_tex("female", MAROON_B) question.scale_to_fit_width(FRAME_WIDTH - 1) question.to_edge(UP, buff = LARGE_BUFF) self.add(question) @@ -2600,7 +2600,7 @@ class Compute6of10GirlsProbability(CycleThroughPatterns): ten_choose_six = brace.get_tex("{10 \\choose 6}") see_chapter_one = TextMobject("(See chapter 1)") see_chapter_one.next_to(ten_choose_six, DOWN) - see_chapter_one.highlight(GREEN) + see_chapter_one.set_color(GREEN) computation = TexMobject( "=\\frac{%s}{%s}"%( "\\cdot ".join(map(str, range(10, 4, -1))), @@ -2651,11 +2651,11 @@ class ProbabilityOfAGivenBoyGirlPattern(CycleThroughPatterns): prob.next_to(self.count, DOWN, LARGE_BUFF) gp = TexMobject("P(\\female)") - gp[2].highlight(MAROON_B) + gp[2].set_color(MAROON_B) bp = TexMobject("P(\\male)") - bp[2].highlight(BLUE) - gp_num = TexMobject("(0.49)").highlight(MAROON_B) - bp_num = TexMobject("(0.51)").highlight(BLUE) + bp[2].set_color(BLUE) + gp_num = TexMobject("(0.49)").set_color(MAROON_B) + bp_num = TexMobject("(0.51)").set_color(BLUE) gp_nums = VGroup() bp_nums = VGroup() factored = VGroup() @@ -2680,8 +2680,8 @@ class ProbabilityOfAGivenBoyGirlPattern(CycleThroughPatterns): final_probability = TexMobject( "(0.49)^6", "(0.51)^4" ) - final_probability.highlight_by_tex("0.49", MAROON_B) - final_probability.highlight_by_tex("0.51", BLUE) + final_probability.set_color_by_tex("0.49", MAROON_B) + final_probability.set_color_by_tex("0.51", BLUE) final_probability.next_to(factored_in_nums, DOWN, LARGE_BUFF) self.play(FadeIn(prob)) @@ -2717,7 +2717,7 @@ class ProbabilityOfAGivenBoyGirlPattern(CycleThroughPatterns): ten_choose_six.generate_target() ten_choose_six.target.move_to(self.final_probability) p_tex = TexMobject("P(", "\\text{6 Girls}", ")", "=") - p_tex.highlight_by_tex("Girls", MAROON_B) + p_tex.set_color_by_tex("Girls", MAROON_B) p_tex.next_to(ten_choose_six.target, LEFT) self.play( @@ -2919,7 +2919,7 @@ class GeneralBinomialDistributionValues(Scene): triangle.scale_to_fit_height(0.25) triangle.move_to(interval.number_to_point(p), DOWN) p_mob = TexMobject("p") - p_mob.highlight(MAROON_B) + p_mob.set_color(MAROON_B) p_mob.next_to(triangle, UP, SMALL_BUFF) triangle.add(p_mob) @@ -2962,11 +2962,11 @@ class GeneralBinomialDistributionValues(Scene): p : MAROON_B, q : BLUE, } - result.highlight_by_tex_to_color_map(color_map) + result.set_color_by_tex_to_color_map(color_map) choose_part = result.get_part_by_tex("choose") - choose_part.highlight(WHITE) - VGroup(*choose_part[1:1+len(n)]).highlight(color_map[n]) - VGroup(*choose_part[-1-len(k):-1]).highlight(color_map[k]) + choose_part.set_color(WHITE) + VGroup(*choose_part[1:1+len(n)]).set_color(color_map[n]) + VGroup(*choose_part[-1-len(k):-1]).set_color(color_map[k]) return result class PointOutSimplicityOfFormula(TeacherStudentsScene, GeneralBinomialDistributionValues): @@ -3035,7 +3035,7 @@ class CorrectForDependence(NameBinomial): for trip in zip(checkmarks, arrows, crosses) ] top_rect = SurroundingRectangle(groups[0]) - top_rect.highlight(GREEN) + top_rect.set_color(GREEN) indices_to_follow = [1, 4, 5, 7] self.play(ShowCreation(top_rect)) @@ -3056,7 +3056,7 @@ class CorrectForDependence(NameBinomial): bar.stretch(0.5, 0) bar.move_to(side, vect) for bar in old_bars.target: - bar.highlight(average_color(RED_E, BLACK)) + bar.set_color(average_color(RED_E, BLACK)) dist = get_binomial_distribution(10, 0.65) values = np.array(map(dist, range(11))) @@ -3148,7 +3148,7 @@ class PermuteQuizQuestions(Scene): ] colors = [BLUE, GREEN, RED] for color, question in zip(colors, questions): - question.highlight(color) + question.set_color(color) quiz.scale(2) self.add(quiz) @@ -3227,7 +3227,7 @@ class AssumeOrderDoesntMatter(Scene): "But what is ", "``correlation''", "?", arg_separator = "" ) - question.highlight(BLUE) + question.set_color(BLUE) question.to_edge(UP) bottom = question.get_bottom() @@ -3259,7 +3259,7 @@ class AssumeOrderDoesntMatter(Scene): words = brace.get_text("Coming soon!") self.play( GrowFromCenter(brace), - part.highlight, YELLOW + part.set_color, YELLOW ) self.play(Write(words)) self.wait() @@ -3294,7 +3294,7 @@ class CompareTwoSituations(PiCreatureScene): for vect in UP+LEFT, UP+RIGHT ] arrow = DoubleArrow(*screens, buff = SMALL_BUFF) - arrow.highlight(BLUE) + arrow.set_color(BLUE) for screen, s in zip(screens, ["left", "right"]): self.play( diff --git a/animation/transform.py b/animation/transform.py index d7499559..2415234a 100644 --- a/animation/transform.py +++ b/animation/transform.py @@ -109,9 +109,9 @@ class GrowFromPoint(Transform): target = mobject.copy() point_mob = Point(point) if self.point_color: - point_mob.highlight(self.point_color) + point_mob.set_color(self.point_color) mobject.replace(point_mob) - mobject.highlight(point_mob.get_color()) + mobject.set_color(point_mob.get_color()) Transform.__init__(self, mobject, target, **kwargs) class GrowFromCenter(GrowFromPoint): @@ -214,7 +214,7 @@ class Indicate(Transform): digest_config(self, kwargs) target = mobject.copy() target.scale_in_place(self.scale_factor) - target.highlight(self.color) + target.set_color(self.color) Transform.__init__(self, mobject, target, **kwargs) class CircleIndicate(Indicate): @@ -260,7 +260,7 @@ class ApplyPointwiseFunction(ApplyMethod): class FadeToColor(ApplyMethod): def __init__(self, mobject, color, **kwargs): - ApplyMethod.__init__(self, mobject.highlight, color, **kwargs) + ApplyMethod.__init__(self, mobject.set_color, color, **kwargs) class ScaleInPlace(ApplyMethod): def __init__(self, mobject, scale_factor, **kwargs): diff --git a/mobject/image_mobject.py b/mobject/image_mobject.py index 09d5ed4b..e01ba6a4 100644 --- a/mobject/image_mobject.py +++ b/mobject/image_mobject.py @@ -47,13 +47,14 @@ class ImageMobject(Mobject): pa = np.append(pa, alphas, axis = 2) self.pixel_array = pa - def highlight(self, color, alpha = None, family = True): + def set_color(self, color, alpha = None, family = True): rgb = color_to_int_rgb(color) self.pixel_array[:,:,:3] = rgb if alpha is not None: self.pixel_array[:,:,3] = int(255*alpha) for submob in self.submobjects: - submob.highlight(color, alpha, family) + submob.set_color(color, alpha, family) + self.color = color return self def init_points(self): diff --git a/mobject/mobject.py b/mobject/mobject.py index 01a228d4..29dee8c9 100644 --- a/mobject/mobject.py +++ b/mobject/mobject.py @@ -453,7 +453,7 @@ class Mobject(Container): ## Match other mobvject properties def match_color(self, mobject): - return self.highlight(mobject.get_color()) + return self.set_color(mobject.get_color()) def match_dim(self, mobject, dim, **kwargs): return self.rescale_to_fit( @@ -472,7 +472,7 @@ class Mobject(Container): ## Color functions - def highlight(self, color = YELLOW_C, family = True): + def set_color(self, color = YELLOW_C, family = True): """ Condition is function which takes in one arguments, (x, y, z). Here it just recurses to submobjects, but in subclasses this @@ -481,7 +481,8 @@ class Mobject(Container): """ if family: for submob in self.submobjects: - submob.highlight(color, family = family) + submob.set_color(color, family = family) + self.color = color return self def gradient_highlight(self, *colors): @@ -496,13 +497,13 @@ class Mobject(Container): if len(colors) == 0: raise Exception("Need at least one color") elif len(colors) == 1: - return self.highlight(*colors) + return self.set_color(*colors) mobs = self.family_members_with_points() new_colors = color_gradient(colors, len(mobs)) for mob, color in zip(mobs, new_colors): - mob.highlight(color, family = False) + mob.set_color(color, family = False) return self def submobject_radial_gradient_highlight(self, center = None, radius = 1, inner_color = WHITE, outer_color = BLACK): @@ -514,17 +515,12 @@ class Mobject(Container): t = np.linalg.norm(mob.get_center() - center)/radius t = min(t,1) mob_color = interpolate_color(inner_color, outer_color, t) - mob.highlight(mob_color, family = False) + mob.set_color(mob_color, family = False) return self - def set_color(self, color): - self.highlight(color) - self.color = Color(color) - return self - def to_original_color(self): - self.highlight(self.color) + self.set_color(self.color) return self # Some objects (e.g., VMobjects) have special fading @@ -540,7 +536,7 @@ class Mobject(Container): start = color_to_rgb(self.get_color()) end = color_to_rgb(color) new_rgb = interpolate(start, end, alpha) - self.highlight(Color(rgb = new_rgb), family = False) + self.set_color(Color(rgb = new_rgb), family = False) return self def fade_to(self, color, alpha): diff --git a/mobject/point_cloud_mobject.py b/mobject/point_cloud_mobject.py index 7db62125..cd9d40f1 100644 --- a/mobject/point_cloud_mobject.py +++ b/mobject/point_cloud_mobject.py @@ -30,11 +30,12 @@ class PMobject(Mobject): self.rgbas = np.append(self.rgbas, rgbas, axis = 0) return self - def highlight(self, color = YELLOW_C, family = True): + def set_color(self, color = YELLOW_C, family = True): rgba = color_to_rgba(color) mobs = self.family_members_with_points() if family else [self] for mob in mobs: mob.rgbas[:,:] = rgba + self.color = color return self # def gradient_highlight(self, start_color, end_color): diff --git a/mobject/tex_mobject.py b/mobject/tex_mobject.py index 5fc1b14e..69ddd96a 100644 --- a/mobject/tex_mobject.py +++ b/mobject/tex_mobject.py @@ -170,22 +170,22 @@ class TexMobject(SVGMobject): all_parts = self.get_parts_by_tex(tex, **kwargs) return all_parts[0] if all_parts else None - def highlight_by_tex(self, tex, color, **kwargs): + def set_color_by_tex(self, tex, color, **kwargs): parts_to_color = self.get_parts_by_tex(tex, **kwargs) for part in parts_to_color: - part.highlight(color) + part.set_color(color) return self - def highlight_by_tex_to_color_map(self, texs_to_color_map, **kwargs): + def set_color_by_tex_to_color_map(self, texs_to_color_map, **kwargs): for texs, color in texs_to_color_map.items(): try: # If the given key behaves like strings texs + '' - self.highlight_by_tex(texs, color, **kwargs) + self.set_color_by_tex(texs, color, **kwargs) except TypeError: # If the given key is a tuple for tex in texs: - self.highlight_by_tex(tex, color, **kwargs) + self.set_color_by_tex(tex, color, **kwargs) return self def index_of_part(self, part): diff --git a/mobject/vectorized_mobject.py b/mobject/vectorized_mobject.py index f0047dd9..353c07ae 100644 --- a/mobject/vectorized_mobject.py +++ b/mobject/vectorized_mobject.py @@ -78,12 +78,13 @@ class VMobject(Mobject): family = family ) - def highlight(self, color, family = True): + def set_color(self, color, family = True): self.set_style_data( stroke_color = color, fill_color = color, family = family ) + self.color = color return self def match_style(self, vmobject): @@ -150,7 +151,7 @@ class VMobject(Mobject): def color_using_background_image(self, background_image_file): self.background_image_file = background_image_file - self.highlight(WHITE) + self.set_color(WHITE) for submob in self.submobjects: submob.color_using_background_image(background_image_file) return self diff --git a/old_projects/256.py b/old_projects/256.py index 83fc1b6d..357a8435 100644 --- a/old_projects/256.py +++ b/old_projects/256.py @@ -46,7 +46,7 @@ def get_google_logo(): class LastVideo(Scene): def construct(self): title = TextMobject("Crypto", "currencies", arg_separator = "") - title[0].highlight(YELLOW) + title[0].set_color(YELLOW) title.scale(1.5) title.to_edge(UP) screen_rect = ScreenRectangle(height = 6) @@ -82,7 +82,7 @@ class BreakUp2To256(PiCreatureScene): number, possibilities = expression = TextMobject( "$2^{256}$", "possibilities" ) - number.highlight(YELLOW) + number.set_color(YELLOW) expression.next_to(brace, RIGHT) words = TextMobject("Seems big...I guess...") @@ -121,7 +121,7 @@ class BreakUp2To256(PiCreatureScene): subexpression = TextMobject( "$2^{32}$", "possibilities" ) - subexpression[0].highlight(GREEN) + subexpression[0].set_color(GREEN) subexpression.next_to(subgroup, RIGHT) subexpressions.add(subexpression) @@ -145,7 +145,7 @@ class BreakUp2To256(PiCreatureScene): new_subexpression = TextMobject( "4 Billion", "possibilities" ) - new_subexpression[0].highlight(YELLOW) + new_subexpression[0].set_color(YELLOW) new_subexpression.move_to(subexpression, LEFT) new_subexpressions.add(new_subexpression) @@ -174,7 +174,7 @@ class BreakUp2To256(PiCreatureScene): [t[0], t[2]] for t in target ])) target_four_billions = VGroup(*[t[1] for t in target]) - target_four_billions.highlight(YELLOW) + target_four_billions.set_color(YELLOW) four_billions, to_fade = [ VGroup(*[se[i] for se in self.subexpressions]) for i in range(2) @@ -242,7 +242,7 @@ class MainBreakdown(Scene): top_line.arrange_submobjects(RIGHT, buff = SMALL_BUFF) top_line.scale_to_fit_width(FRAME_WIDTH - LARGE_BUFF) top_line.to_edge(UP) - four_billions.highlight(YELLOW) + four_billions.set_color(YELLOW) self.add(top_line) self.top_line = top_line @@ -260,7 +260,7 @@ class MainBreakdown(Scene): ) name = TextMobject("Graphics", "Processing", "Unit") for word in name: - word[0].highlight(BLUE) + word[0].set_color(BLUE) name.to_edge(LEFT) gpu.next_to(name, UP) @@ -338,7 +338,7 @@ class MainBreakdown(Scene): laptop.to_edge(RIGHT) new_rate_words = TextMobject("4 Billion", "Hashes/sec") new_rate_words.move_to(rate_words) - new_rate_words[0].highlight(BLUE) + new_rate_words[0].set_color(BLUE) hps, h_line, target_laptop = self.get_fraction( 0, TextMobject("H/s"), Laptop() @@ -372,10 +372,10 @@ class MainBreakdown(Scene): self.wait() self.play( Transform( - rate_words[0], four_billion.copy().highlight(BLUE), + rate_words[0], four_billion.copy().set_color(BLUE), remover = True, ), - four_billion.highlight, BLUE, + four_billion.set_color, BLUE, Transform(rate_words[1], hps), ) self.play( @@ -506,7 +506,7 @@ class MainBreakdown(Scene): def four_billion_galxies(self): self.create_four_billion_copies(4, self.get_galaxy()) num, h_line, denom = fraction = self.get_fraction( - 4, self.get_galaxy(), TextMobject("GGSC").highlight(BLUE) + 4, self.get_galaxy(), TextMobject("GGSC").set_color(BLUE) ) name = TextMobject( @@ -514,7 +514,7 @@ class MainBreakdown(Scene): arg_separator = "" ) for word in name: - word[0].highlight(BLUE) + word[0].set_color(BLUE) name.next_to(self.group_of_four_billion_things, UP) self.play(Write(name)) @@ -554,7 +554,7 @@ class MainBreakdown(Scene): self.play( fb.scale, 1.3, fb.next_to, words, LEFT, - fb.highlight, BLUE, + fb.set_color, BLUE, Write(words) ) self.wait() @@ -569,7 +569,7 @@ class MainBreakdown(Scene): ) words.next_to(four_billion, DOWN, buff = MED_LARGE_BUFF) words.to_edge(RIGHT) - words[1].highlight(BLUE) + words[1].set_color(BLUE) self.play( Write(VGroup(*words[::2])), @@ -582,7 +582,7 @@ class MainBreakdown(Scene): def create_four_billion_copies(self, index, mobject): four_billion = self.four_billions[index] - four_billion.highlight(BLUE) + four_billion.set_color(BLUE) four_billion.save_state() group = VGroup(*[ @@ -681,7 +681,7 @@ class MainBreakdown(Scene): class WriteTWoTo160(Scene): def construct(self): mob = TextMobject("$2^{160}$ ", "Hashes/sec") - mob[0].highlight(BLUE) + mob[0].set_color(BLUE) mob.scale(2) self.play(Write(mob)) self.wait() @@ -724,7 +724,7 @@ class StateOfBitcoin(TeacherStudentsScene): ) gpu.shift(0.5*FRAME_X_RADIUS*RIGHT) gpu_name = TextMobject("GPU") - gpu_name.highlight(BLUE) + gpu_name.set_color(BLUE) gpu_name.next_to(gpu, UP) gpu_group = VGroup(gpu, gpu_name) gpu_group.to_edge(UP) @@ -735,7 +735,7 @@ class StateOfBitcoin(TeacherStudentsScene): "Application", "Specific\\\\", "Integrated", "Circuit" ) for word in asic: - word[0].highlight(YELLOW) + word[0].set_color(YELLOW) asic.move_to(gpu) asic.to_edge(UP) asic.shift(LEFT) @@ -749,7 +749,7 @@ class StateOfBitcoin(TeacherStudentsScene): circuit.next_to(asic, RIGHT) asic_rate = TextMobject("Trillion hashes/sec") asic_rate.next_to(asic, DOWN, MED_LARGE_BUFF) - asic_rate.highlight(GREEN) + asic_rate.set_color(GREEN) self.play( Write(title), @@ -804,7 +804,7 @@ class QAndA(PiCreatureScene): ) num_subscriber_words.to_edge(UP) num_subscriber_words.shift(RIGHT) - num_subscriber_words.highlight_by_tex("subscribers", RED) + num_subscriber_words.set_color_by_tex("subscribers", RED) q_and_a = TextMobject("Q\\&A") q_and_a.next_to(self.pi_creature.get_corner(UP+LEFT), UP) @@ -815,7 +815,7 @@ class QAndA(PiCreatureScene): reddit = TextMobject("reddit.com/r/3blue1brown") reddit.next_to(num_subscriber_words, DOWN, LARGE_BUFF) twitter = TextMobject("@3blue1brown") - twitter.highlight(BLUE_C) + twitter.set_color(BLUE_C) twitter.next_to(reddit, DOWN) self.play(Write(num_subscriber_words)) @@ -883,7 +883,7 @@ class Thumbnail(Scene): def construct(self): num = TexMobject("2^{256}") num.scale_to_fit_height(2) - num.highlight(BLUE_C) + num.set_color(BLUE_C) num.set_stroke(BLUE_B, 3) num.shift(MED_SMALL_BUFF*UP) num.add_background_rectangle(opacity = 1) @@ -906,7 +906,7 @@ class Thumbnail(Scene): secure = TextMobject("Secure?") secure.scale(4) secure.shift(FRAME_Y_RADIUS*DOWN/2) - secure.highlight(RED) + secure.set_color(RED) secure.set_stroke(RED_A, 3) lock = SVGMobject( diff --git a/old_projects/WindingNumber_G.py b/old_projects/WindingNumber_G.py index a705c632..83a008dd 100644 --- a/old_projects/WindingNumber_G.py +++ b/old_projects/WindingNumber_G.py @@ -123,7 +123,7 @@ class IntroSceneWrapper(PiCreatureScene): 3y \\end{array}\\right] """) - # xy_equation.highlight_by_tex_to_color_map({ + # xy_equation.set_color_by_tex_to_color_map({ # "x" : BLUE, # "y" : YELLOW # }) @@ -131,11 +131,11 @@ class IntroSceneWrapper(PiCreatureScene): xy_equation.next_to(solver, DOWN, MED_LARGE_BUFF) z_equation = TexMobject("z", "^5", "+", "z", "+", "1", "=", "0") - z_equation.highlight_by_tex("z", GREEN) + z_equation.set_color_by_tex("z", GREEN) z_equation.move_to(xy_equation, UP) zeta = TexMobject("\\zeta(s) = 0") - zeta[2].highlight(GREEN) + zeta[2].set_color(GREEN) zeta.next_to(z_equation, DOWN, MED_LARGE_BUFF) self.play(Write(solver)) @@ -543,12 +543,12 @@ class Introduce1DFunctionCase(Scene): if mention_signs: if too_high: sign_word = TextMobject("Positive") - sign_word.highlight(GREEN) + sign_word.set_color(GREEN) sign_word.scale(0.7) sign_word.next_to(arrow.get_end(), RIGHT) else: sign_word = TextMobject("Negative") - sign_word.highlight(RED) + sign_word.set_color(RED) sign_word.scale(0.7) sign_word.next_to(arrow.get_end(), LEFT) sign_word.add_background_rectangle() @@ -598,7 +598,7 @@ class TransitionFromEquationSolverToZeroFinder(Introduce1DFunctionCase): equation.add(tex_mob) find_sqrt_2 = self.find_sqrt_2 rect = SurroundingRectangle(VGroup(equation, find_sqrt_2)) - rect.highlight(WHITE) + rect.set_color(WHITE) f_graph = self.squared_graph g_graph = self.two_graph @@ -670,7 +670,7 @@ class RewriteEquationWithTeacher(AltTeacherStudentsScene): for equation in root_two_equations: equation.sort_submobjects_alphabetically() for part in equation.get_parts_by_tex("text"): - part[2:-1].highlight(YELLOW) + part[2:-1].set_color(YELLOW) part[2:-1].scale(0.9) equation.move_to(self.hold_up_spot, DOWN) @@ -713,7 +713,7 @@ class RewriteEquationWithTeacher(AltTeacherStudentsScene): complex_group = VGroup(complex_equation, z_def) complex_group.arrange_submobjects(DOWN) for tex in complex_group: - tex.highlight_by_tex("z", GREEN) + tex.set_color_by_tex("z", GREEN) complex_group.move_to(self.hold_up_spot, DOWN) self.play( @@ -879,8 +879,8 @@ class IntroduceInputOutputScene(InputOutputScene): out_dot = in_dot.target for mob in in_dot, out_dot: mob.scale(1.5) - in_dot.highlight(YELLOW) - out_dot.highlight(PINK) + in_dot.set_color(YELLOW) + out_dot.set_color(PINK) input_label_arrow = Vector(DOWN+RIGHT) input_label_arrow.next_to(in_dot, UP+LEFT, SMALL_BUFF) @@ -1015,8 +1015,8 @@ class IntroduceVectorField(IntroduceInputOutputScene): out_dot_continual_update = self.get_output_dot_continual_update(in_dot, out_dot) for mob in in_dot, out_dot: mob.scale(1.5) - in_dot.highlight(YELLOW) - out_dot.highlight(PINK) + in_dot.set_color(YELLOW) + out_dot.set_color(PINK) out_vector = Arrow( LEFT, RIGHT, @@ -1255,7 +1255,7 @@ class DotsHoppingToColor(InputOutputScene): self.play( FadeIn(output_coloring), Animation(output_plane), - output_plane.white_parts.highlight, BLACK, + output_plane.white_parts.set_color, BLACK, output_plane.lines_to_fade.set_stroke, {"width" : 0}, ) self.wait() @@ -1284,7 +1284,7 @@ class DotsHoppingToColor(InputOutputScene): self.play( FadeIn(input_coloring), Animation(input_plane), - input_plane.white_parts.highlight, BLACK, + input_plane.white_parts.set_color, BLACK, input_plane.lines_to_fade.set_stroke, {"width" : 0}, FadeOut(dots), ) @@ -1304,7 +1304,7 @@ class DotsHoppingToColor(InputOutputScene): stroke_width = 3, stroke_color = WHITE, ) - inspector.add(*inspector.copy().highlight(BLACK).shift((TAU/24)*UP)) + inspector.add(*inspector.copy().set_color(BLACK).shift((TAU/24)*UP)) inspector.apply_complex_function(np.exp) inspector.scale(0.15) @@ -1317,7 +1317,7 @@ class DotsHoppingToColor(InputOutputScene): ) pink_points_label = TextMobject("Pink points") pink_points_label.scale(0.7) - pink_points_label.highlight(BLACK) + pink_points_label.set_color(BLACK) self.play( inspector.move_to, input_plane.coords_to_point(-2.75, 2.75), @@ -1385,7 +1385,7 @@ class DotsHoppingToColor(InputOutputScene): dot.scale(1.5) self.play( FadeOut(input_coloring), - input_plane.white_parts.highlight, WHITE, + input_plane.white_parts.set_color, WHITE, LaggedStart(GrowFromCenter, dots) ) self.wait() @@ -1454,8 +1454,8 @@ class Rearrange2DEquation(AltTeacherStudentsScene): zero_eq = brace.get_tex("%s = %s"%(f_tex, zero_tex)) for equation in equations: - equation.highlight_by_tex(g_tex, BLUE) - equation.highlight_by_tex(h_tex, YELLOW) + equation.set_color_by_tex(g_tex, BLUE) + equation.set_color_by_tex(h_tex, YELLOW) equation.sort_submobjects_alphabetically() @@ -1667,7 +1667,7 @@ class DirectionOfA2DFunctionAlongABoundary(InputOutputScene): lambda ov : ov.put_start_and_end_on( output_plane.coords_to_point(0, 0), rect_image.points[-1] - ).highlight(get_color()) + ).set_color(get_color()) ) dot = Dot() @@ -1680,7 +1680,7 @@ class DirectionOfA2DFunctionAlongABoundary(InputOutputScene): def update_in_vect(in_vect): in_vect.put_start_and_end_on(ORIGIN, 0.5*RIGHT) in_vect.rotate(get_angle()) - in_vect.highlight(get_color()) + in_vect.set_color(get_color()) in_vect.shift(get_input_point() - in_vect.get_start()) return in_vect in_vect_update_anim = UpdateFromFunc(in_vect, update_in_vect) @@ -1724,7 +1724,7 @@ class AskAboutHowToGeneralizeSigns(AltTeacherStudentsScene): question = TextMobject( "Wait...what would \\\\ positive and negative \\\\ be in 2d?", ) - # question.highlight_by_tex_to_color_map({ + # question.set_color_by_tex_to_color_map({ # "+" : "green", # "textminus" : "red" # }) @@ -1767,7 +1767,7 @@ class HypothesisAboutFullyColoredBoundary(ColorMappedObjectsScene): alignment = "", ) hypothesis[0].next_to(hypothesis[1:], UP) - hypothesis[0].highlight(YELLOW) + hypothesis[0].set_color(YELLOW) s = hypothesis[1].get_tex_string() s = filter(lambda c : c not in string.whitespace, s) n = s.index("colors") @@ -1824,7 +1824,7 @@ class ForeverNarrowingLoop(InputOutputScene): input_coloring, output_coloring = colorings = VGroup(*self.get_colorings()) input_plane, output_plane = planes = VGroup(*self.get_planes()) for plane in planes: - plane.white_parts.highlight(BLACK) + plane.white_parts.set_color(BLACK) plane.lines_to_fade.set_stroke(width = 0) v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) @@ -1837,7 +1837,7 @@ class ForeverNarrowingLoop(InputOutputScene): for coloring in colorings ], [ - ApplyMethod(plane.white_parts.highlight, WHITE) + ApplyMethod(plane.white_parts.set_color, WHITE) for plane in planes ] ), run_time = 2) @@ -1965,7 +1965,7 @@ class FailureOfComposition(ColorMappedObjectsScene): all_squares.set_stroke(width = 6) for square in all_squares: - square.highlight(WHITE) + square.set_color(WHITE) square.color_using_background_image(self.background_image_file) question = TextMobject("Does my border go through every color?") @@ -1975,11 +1975,11 @@ class FailureOfComposition(ColorMappedObjectsScene): for square in all_squares: if square is big_square: square.answer = TextMobject("Yes") - square.answer.highlight(GREEN) + square.answer.set_color(GREEN) yes_answers.add(square.answer) else: square.answer = TextMobject("No") - square.answer.highlight(RED) + square.answer.set_color(RED) no_answers.add(square.answer) square.answer.move_to(square) @@ -2092,7 +2092,7 @@ class PathContainingZero(InputOutputScene, PiCreatureScene): planes = VGroup(*self.get_planes()) self.input_plane, self.output_plane = planes for plane in planes: - # plane.white_parts.highlight(BLACK) + # plane.white_parts.set_color(BLACK) plane.lines_to_fade.set_stroke(width = 0) v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) @@ -2779,11 +2779,11 @@ class ShowComplexFunction(Scene): fx_label = TexMobject("f(x) = x^5 - x - 1") fx_label.next_to(fx_dot, DOWN, SMALL_BUFF) - fx_label.highlight(YELLOW) + fx_label.set_color(YELLOW) fx_label.add_background_rectangle() fx_label.generate_target() fx_label.target.move_to(title) - fx_label.target[1].highlight(WHITE) + fx_label.target[1].set_color(WHITE) self.play( Write(plane), @@ -2847,7 +2847,7 @@ class WindingNumbersInInputOutputContext(PathContainingZero): ) update_out_arrow_color = ContinualUpdateFromFunc( out_arrow, - lambda a : a.highlight(rev_to_color(a.get_angle()/TAU)) + lambda a : a.set_color(rev_to_color(a.get_angle()/TAU)) ) self.add(update_out_arrow, update_out_arrow_color) @@ -2961,7 +2961,7 @@ class EndingCredits(Scene): class MentionQAndA(Scene): def construct(self): title = TextMobject("Q\\&A with ", "Ben", "and", "Sridhar\\\\", "at", "Patreon") - title.highlight_by_tex_to_color_map({ + title.set_color_by_tex_to_color_map({ "Ben" : MAROON, "Sridhar" : YELLOW, }) @@ -3000,7 +3000,7 @@ class TickingClock(Scene): lines = [clock.hour_hand, clock.minute_hand] def update_line(line): rev = line.get_angle()/TAU - line.highlight(rev_to_color(rev)) + line.set_color(rev_to_color(rev)) for line in lines: self.add(ContinualUpdateFromFunc(line, update_line)) @@ -3082,7 +3082,7 @@ class MentionFree(PiCreatureScene): items.next_to(morty, UP, LARGE_BUFF) right_x = morty.get_right()[0] for item in items: - item[1].highlight(GREEN) + item[1].set_color(GREEN) item.shift((right_x - item[0].get_right()[0])*RIGHT) self.play( diff --git a/old_projects/basel/basel.py b/old_projects/basel/basel.py index 37065597..76790335 100644 --- a/old_projects/basel/basel.py +++ b/old_projects/basel/basel.py @@ -344,7 +344,7 @@ class IntroScene(PiCreatureScene): self.wait() - self.q_marks = TextMobject("???").highlight(LIGHT_COLOR) + self.q_marks = TextMobject("???").set_color(LIGHT_COLOR) self.q_marks.move_to(self.partial_sum_decimal) self.play( @@ -394,7 +394,7 @@ class IntroScene(PiCreatureScene): rect = Rectangle() rect.stroke_width = 0 rect.fill_opacity = 1 - rect.highlight(color) + rect.set_color(color) rect.stretch_to_fit_height( self.rect_height, ) @@ -464,7 +464,7 @@ class IntroScene(PiCreatureScene): def show_pi_answer(self): - self.pi_answer = TexMobject("{\\pi^2 \\over 6}").highlight(YELLOW) + self.pi_answer = TexMobject("{\\pi^2 \\over 6}").set_color(YELLOW) self.pi_answer.move_to(self.partial_sum_decimal) self.pi_answer.next_to(self.euler_sum[-1], RIGHT, buff = 1, submobject_to_align = self.pi_answer[-2]) @@ -1128,7 +1128,7 @@ class EarthScene(Scene): 0])) polar_morty = morty.copy().scale(0.5).next_to(screen_on_earth,DOWN,buff = 0.5) - polar_morty.highlight(BLUE_C) + polar_morty.set_color(BLUE_C) self.play( Transform(self.screen, screen_on_earth), @@ -1140,7 +1140,7 @@ class EarthScene(Scene): tropical_morty = polar_morty.copy() tropical_morty.move_to(np.array([0,0,0])) - tropical_morty.highlight(RED) + tropical_morty.set_color(RED) morty.target = tropical_morty @@ -3960,7 +3960,7 @@ class FinalSumManipulationScene(PiCreatureScene): sum_vertical_spacing = 1.5 randy = self.get_primary_pi_creature() - randy.highlight(MAROON_D) + randy.set_color(MAROON_D) randy.color = MAROON_D randy.scale(0.7).flip().to_edge(DOWN + LEFT) self.wait() @@ -4397,7 +4397,7 @@ class InfiniteCircleScene(PiCreatureScene): def construct(self): morty = self.get_primary_pi_creature() - morty.highlight(MAROON_D).flip() + morty.set_color(MAROON_D).flip() morty.color = MAROON_D morty.scale(0.5).move_to(ORIGIN) diff --git a/old_projects/basel/basel2.py b/old_projects/basel/basel2.py index 5287f947..08bac0c4 100644 --- a/old_projects/basel/basel2.py +++ b/old_projects/basel/basel2.py @@ -470,7 +470,7 @@ class IntroScene(PiCreatureScene): brace = self.brace = Brace(partial_sum_decimal, DOWN) q_marks = self.q_marks = TextMobject("???") q_marks.next_to(brace, DOWN) - q_marks.highlight(LIGHT_COLOR) + q_marks.set_color(LIGHT_COLOR) self.play( GrowFromCenter(brace), @@ -508,7 +508,7 @@ class IntroScene(PiCreatureScene): euler.next_to(FRAME_X_RADIUS*RIGHT, RIGHT) pi_answer = self.pi_answer = TexMobject("{\\pi^2 \\over 6}") - pi_answer.highlight(YELLOW) + pi_answer.set_color(YELLOW) pi_answer.move_to(self.partial_sum_decimal, LEFT) equals_sign = TexMobject("=") equals_sign.next_to(pi_answer, RIGHT) @@ -665,7 +665,7 @@ class MathematicalWebOfConnections(PiCreatureScene): "fundamentally \\\\", "about circles" ) - words.highlight_by_tex("fundamentally", YELLOW) + words.set_color_by_tex("fundamentally", YELLOW) self.play(PiCreatureSays( jerk, words, @@ -744,7 +744,7 @@ class MathematicalWebOfConnections(PiCreatureScene): question.set_stroke(WHITE, 0.5) question.next_to(fundamentally, DOWN, LARGE_BUFF) arrow = Arrow(question, fundamentally) - arrow.highlight(WHITE) + arrow.set_color(WHITE) self.play( FadeIn(question), @@ -758,8 +758,8 @@ class MathematicalWebOfConnections(PiCreatureScene): def draw_circle(self): semi_circle = Arc(angle = np.pi, radius = 2) radius = Line(ORIGIN, semi_circle.points[0]) - radius.highlight(BLUE) - semi_circle.highlight(YELLOW) + radius.set_color(BLUE) + semi_circle.set_color(YELLOW) VGroup(radius, semi_circle).move_to( FRAME_X_RADIUS*LEFT/2 + FRAME_Y_RADIUS*UP/2, @@ -849,7 +849,7 @@ class MathematicalWebOfConnections(PiCreatureScene): circle = Circle(color = YELLOW, radius = 1) radius = Line(circle.get_center(), circle.get_right()) - radius.highlight(BLUE) + radius.set_color(BLUE) VGroup(circle, radius).next_to(path_dots[-1], RIGHT) self.play( @@ -857,11 +857,11 @@ class MathematicalWebOfConnections(PiCreatureScene): LaggedStart(ShowCreation, edges, run_time = 3), LaggedStart(GrowFromCenter, dots, run_time = 3) ) - self.play(path_dots[0].highlight, RED) + self.play(path_dots[0].set_color, RED) for dot, edge in zip(path_dots[1:], path_edges): self.play( ShowCreation(edge), - dot.highlight, RED + dot.set_color, RED ) self.play(ShowCreation(radius)) radius.set_points_as_corners(radius.get_anchors()) @@ -1421,7 +1421,7 @@ class IntroduceScreen(Scene): for ray in rays ]) self.play(*[ - ApplyMethod(ray.highlight, ray.target_color) + ApplyMethod(ray.set_color, ray.target_color) for ray in rays ]) self.wait() @@ -1684,7 +1684,7 @@ class InverseSquareLaw(ThreeDScene): one_arrow = DoubleArrow(ORIGIN, unit_distance*RIGHT, buff = 0) two_arrow = DoubleArrow(ORIGIN, 2*unit_distance*RIGHT, buff = 0) arrows = VGroup(one_arrow, two_arrow) - arrows.highlight(WHITE) + arrows.set_color(WHITE) one_arrow.move_to(source_point + DOWN, LEFT) two_arrow.move_to(source_point + 1.75*DOWN, LEFT) one = Integer(1).next_to(one_arrow, UP, SMALL_BUFF) @@ -1868,7 +1868,7 @@ class InverseSquareLaw(ThreeDScene): self.begin_ambient_camera_rotation(rate = -0.01) self.play(LaggedStart( ApplyMethod, screen_copy_groups[2], - lambda m : (m.highlight, RED), + lambda m : (m.set_color, RED), run_time = 5, rate_func = there_and_back, )) @@ -2147,12 +2147,12 @@ class TwoLightSourcesScene(ManipulateLightsourceSetups): #Lines line_a = Line(C, A) - line_a.highlight(BLUE) + line_a.set_color(BLUE) line_b = Line(C, B) - line_b.highlight(RED) + line_b.set_color(RED) line_c = Line(A, B) line_h = Line(H, C) - line_h.highlight(GREEN) + line_h.set_color(GREEN) label_a = TexMobject("a") label_a.match_color(line_a) @@ -2170,7 +2170,7 @@ class TwoLightSourcesScene(ManipulateLightsourceSetups): perp_mark.scale(0.25, about_point = ORIGIN) perp_mark.rotate(line_c.get_angle() + TAU/4, about_point = ORIGIN) perp_mark.shift(H) - # perp_mark.highlight(BLACK) + # perp_mark.set_color(BLACK) #Indicators indicator = LightIndicator( @@ -2210,7 +2210,7 @@ class TwoLightSourcesScene(ManipulateLightsourceSetups): "{1 \over ", "a^2}", "+", "{1 \over", "b^2}", "=", "{1 \over","h^2}" ) - theorem.highlight_by_tex_to_color_map({ + theorem.set_color_by_tex_to_color_map({ "a" : line_a.get_color(), "b" : line_b.get_color(), "h" : line_h.get_color(), @@ -2424,7 +2424,7 @@ class SimpleIPTProof(Scene): ) argument_lines.arrange_submobjects(DOWN) for line in argument_lines: - line.highlight_by_tex_to_color_map({ + line.set_color_by_tex_to_color_map({ "a" : BLUE, "b" : RED, "h" : GREEN, @@ -2536,12 +2536,12 @@ class IPTScene(TwoLightSourcesScene, ZoomedScene): #Lines line_a = Line(C, A) - line_a.highlight(BLUE) + line_a.set_color(BLUE) line_b = Line(C, B) - line_b.highlight(RED) + line_b.set_color(RED) line_c = Line(A, B) line_h = Line(H, C) - line_h.highlight(GREEN) + line_h.set_color(GREEN) label_a = TexMobject("a") label_a.match_color(line_a) @@ -2587,7 +2587,7 @@ class IPTScene(TwoLightSourcesScene, ZoomedScene): "{1 \over ", "a^2}", "+", "{1 \over", "b^2}", "=", "{1 \over","h^2}" ) - theorem.highlight_by_tex_to_color_map({ + theorem.set_color_by_tex_to_color_map({ "a" : line_a.get_color(), "b" : line_b.get_color(), "h" : line_h.get_color(), @@ -2690,7 +2690,7 @@ class IPTScene(TwoLightSourcesScene, ZoomedScene): for hyp, line in (m_hyp_a, m_a), (m_hyp_b, m_b): hyp.save_state() hyp.alt_version = line.copy() - hyp.alt_version.highlight(WHITE) + hyp.alt_version.set_color(WHITE) for x in range(2): self.play(*[ @@ -2863,7 +2863,7 @@ class InscribedeAngleThreorem(TeacherStudentsScene): angle_mark = Arc(start_angle = -TAU/8, angle = TAU/4) angle_mark.scale(0.3, about_point = ORIGIN) angle_mark.shift(circle.get_center()) - theta = TexMobject("\\theta").highlight(RED) + theta = TexMobject("\\theta").set_color(RED) theta.next_to(angle_mark, RIGHT, MED_SMALL_BUFF) angle_mark.match_color(theta) @@ -2871,7 +2871,7 @@ class InscribedeAngleThreorem(TeacherStudentsScene): half_angle_mark.scale(0.3, about_point = ORIGIN) half_angle_mark.shift(point.get_center()) half_angle_mark.add(point.copy()) - theta_halves = TexMobject("\\theta/2").highlight(GREEN) + theta_halves = TexMobject("\\theta/2").set_color(GREEN) theta_halves.scale(0.7) half_angle_mark.match_color(theta_halves) theta_halves_update = UpdateFromFunc( @@ -3968,7 +3968,7 @@ class FinalSumManipulationScene(PiCreatureScene): sum_vertical_spacing = 1.5 randy = self.get_primary_pi_creature() - randy.highlight(MAROON_D) + randy.set_color(MAROON_D) randy.color = MAROON_D randy.scale(0.7).flip().to_edge(DOWN + LEFT) self.wait() @@ -4342,7 +4342,7 @@ class InfiniteCircleScene(PiCreatureScene): def construct(self): morty = self.get_primary_pi_creature() - morty.highlight(MAROON_D).flip() + morty.set_color(MAROON_D).flip() morty.color = MAROON_D morty.scale(0.5).move_to(ORIGIN) @@ -4425,7 +4425,7 @@ class Credits(Scene): ] ]) for credit, color in zip(credits, [MAROON_D, BLUE_D, WHITE]): - credit[1].highlight(color) + credit[1].set_color(color) credit.arrange_submobjects(DOWN, buff = SMALL_BUFF) credits.arrange_submobjects(DOWN, buff = LARGE_BUFF) @@ -4584,7 +4584,7 @@ class BaselPatreonThanks(PatreonEndScreen): next_video = TextMobject("$\\uparrow$ Next video $\\uparrow$") next_video.to_edge(RIGHT, buff = 1.5) next_video.shift(MED_SMALL_BUFF*UP) - next_video.highlight(YELLOW) + next_video.set_color(YELLOW) self.add_foreground_mobject(next_video) PatreonEndScreen.construct(self) diff --git a/old_projects/bell.py b/old_projects/bell.py index 4b4e7f10..abcc848a 100644 --- a/old_projects/bell.py +++ b/old_projects/bell.py @@ -70,9 +70,9 @@ class PhotonPassesCompletelyOrNotAtAll(DirectionOfPolarizationScene): pol_filter.remove(pol_filter.label) passing_words = TextMobject("Photon", "passes through\\\\", "entirely") - passing_words.highlight(GREEN) + passing_words.set_color(GREEN) filtered_words = TextMobject("Photon", "is blocked\\\\", "entirely") - filtered_words.highlight(RED) + filtered_words.set_color(RED) for words in passing_words, filtered_words: words.next_to(ORIGIN, UP+LEFT) words.shift(2*UP) @@ -232,8 +232,8 @@ class PhotonsThroughPerpendicularFilters(PhotonPassesCompletelyOrNotAtAll): arg_separator = "" ) here1, here2 = prob_text.get_parts_by_tex("here") - here1.highlight(GREEN) - here2.highlight(RED) + here1.set_color(GREEN) + here2.set_color(RED) prob_text.add_background_rectangle() prob_text.next_to(ORIGIN, UP+RIGHT) prob_text.shift(2.5*UP+LEFT) @@ -410,7 +410,7 @@ class ShowALittleMath(TeacherStudentsScene): "psi" : BLUE } for exp in exp1, exp2: - exp.highlight_by_tex_to_color_map(color_map) + exp.set_color_by_tex_to_color_map(color_map) exp1.next_to(self.teacher.get_corner(UP+LEFT), UP, LARGE_BUFF) exp2.move_to(exp1) @@ -459,7 +459,7 @@ class BasicsOfPolarization(DirectionOfPolarizationScene): title = TextMobject("Waves in the ``electromagnetic field''") title.to_edge(UP) subtitle = TextMobject("Polarization = Direction of", "wiggling") - subtitle.highlight_by_tex("wiggling", BLUE) + subtitle.set_color_by_tex("wiggling", BLUE) subtitle.next_to(title, DOWN) for words in title, subtitle: words.add_background_rectangle() @@ -500,8 +500,8 @@ class BasicsOfPolarization(DirectionOfPolarizationScene): ) quantum_right_words.scale(0.8) quantum_right_words.next_to(quantum_left_words, buff = 0) - quantum_right_words.highlight_by_tex("through", GREEN) - quantum_right_words.highlight_by_tex("blocked", RED) + quantum_right_words.set_color_by_tex("through", GREEN) + quantum_right_words.set_color_by_tex("blocked", RED) quantum_words = VGroup(quantum_left_words, quantum_right_words) quantum_words.rotate(np.pi/2, RIGHT) @@ -509,7 +509,7 @@ class BasicsOfPolarization(DirectionOfPolarizationScene): "&P(", "\\text{Pass}", ")", "=", "p\\\\", "&P(", "\\text{Blocked}", ")", "=", "1-p", ) - prob_eq.highlight_by_tex_to_color_map({ + prob_eq.set_color_by_tex_to_color_map({ "Pass" : GREEN, "Blocked" : RED, }) @@ -574,7 +574,7 @@ class AngleToProbabilityChart(Scene): v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) v_line.next_to(left_title, RIGHT, MED_LARGE_BUFF) v_line.to_edge(UP, buff = 0) - VGroup(h_line, v_line).highlight(BLUE) + VGroup(h_line, v_line).set_color(BLUE) self.add(left_title, right_title, h_line, v_line) angles = [0, 22.5, 45, 67.5, 90] @@ -593,7 +593,7 @@ class AngleToProbabilityChart(Scene): TexMobject("%.1f"%(100*prob) + "\\%") for prob in probs ]) - prob_mobs.highlight(YELLOW) + prob_mobs.set_color(YELLOW) angle_prob_pairs = zip(angle_mobs, prob_mobs) for angle_mob, prob_mob in angle_prob_pairs: @@ -715,7 +715,7 @@ class ShowVariousFilterPairsWithPhotonsOverTime(PhotonsThroughPerpendicularFilte ) self.second_filter.filter_angle = pol_filter.filter_angle new_prob_text = self.get_probability_text(self.get_prob()) - new_prob_text[1][-2].highlight(YELLOW) + new_prob_text[1][-2].set_color(YELLOW) self.play(Transform(self.prob_text, new_prob_text)) #### @@ -849,7 +849,7 @@ class ShowVariousFilterPairs(ShowVariousFilterPairsWithPhotonsOverTime): prob_mob.scale(0.7) prob_mob.rotate(np.pi/2, RIGHT) prob_mob.next_to(pol_filter.arrow_label, RIGHT) - prob_mob.highlight( + prob_mob.set_color( list(Color(RED).range_to(GREEN, 11))[int(prob*10)] ) return prob_mob @@ -909,7 +909,7 @@ class ShowVariousFilterPairsFrom0To45(ShowVariousFilterPairs): for x in 45, 22.5 ]) cosines.scale(0.8) - # cosines.highlight(BLUE) + # cosines.set_color(BLUE) cosines.rotate(np.pi/2, RIGHT) for cos, rect in zip(cosines, rects[1:]): cos.next_to(rect, OUT, SMALL_BUFF) @@ -1015,7 +1015,7 @@ class ForgetPreviousActions(ShowVariousFilterPairs): if photon.filter_distance == FRAME_X_RADIUS + 2: added_anims.append( ApplyMethod( - self.second_filter.highlight, RED, + self.second_filter.set_color, RED, rate_func = squish_rate_func(there_and_back, 0.5, 0.7) ) ) @@ -1057,7 +1057,7 @@ class IntroduceLabeledFilters(ShowVariousFilterPairs): label = TextMobject(char) label.scale(0.9) label.add_background_rectangle() - label.highlight(color) + label.set_color(color) label.rotate(np.pi/2, RIGHT) label.rotate(np.pi/2, IN) label.next_to(pf.arrow_label, UP) @@ -1144,7 +1144,7 @@ class IntroduceLabeledFilters(ShowVariousFilterPairs): stroke_width = 5, ) words = TextMobject("50\\% blocked") - words.highlight(BLUE) + words.set_color(BLUE) words.next_to(arrow, RIGHT, buff = 0) group = VGroup(arrow, words) group.rotate(np.pi/2, RIGHT) @@ -1222,7 +1222,7 @@ class IntroduceLabeledFilters(ShowVariousFilterPairs): arrow2 = arrow1.copy() arrow2.next_to(arrow1, RIGHT, buff = LARGE_BUFF) words1 = TextMobject("15\\%", "blocked") - words1.highlight(GREEN) + words1.set_color(GREEN) words2 = words1.copy() words1.next_to(arrow1, DOWN, buff = SMALL_BUFF) words2.next_to(arrow2, DOWN, buff = SMALL_BUFF) @@ -1265,7 +1265,7 @@ class IntroduceLabeledFilters(ShowVariousFilterPairs): equals.next_to(fifteen2, RIGHT, 2*SMALL_BUFF) q_mark = TexMobject("?").rotate(np.pi/2, RIGHT) q_mark.next_to(equals, OUT, SMALL_BUFF) - q_mark.highlight(RED) + q_mark.set_color(RED) randy = Randolph(mode = "confused").flip() randy.scale(0.7) randy.rotate(np.pi/2, RIGHT) @@ -1278,11 +1278,11 @@ class IntroduceLabeledFilters(ShowVariousFilterPairs): blinked.rotate(np.pi/2, RIGHT) self.play( - fifteen1.highlight, YELLOW, + fifteen1.set_color, YELLOW, Write(plus) ) self.play( - fifteen2.highlight, YELLOW, + fifteen2.set_color, YELLOW, Write(equals) ) self.play( @@ -1420,7 +1420,7 @@ class VennDiagramProofByContradiction(Scene): TextMobject( "%s \\\\"%start, "through", char + "$\\! \\uparrow$" - ).highlight_by_tex(char, circle.get_color()) + ).set_color_by_tex(char, circle.get_color()) for start in "Would pass", "Pass" ] for mob in label, alt_label: @@ -1524,7 +1524,7 @@ class VennDiagramProofByContradiction(Scene): "Pass through B?", "No\\\\", "Pass through C?", "No\\\\", ) - answers.highlight_by_tex_to_color_map({ + answers.set_color_by_tex_to_color_map({ "Yes" : GREEN, "No" : RED, }) @@ -1625,21 +1625,21 @@ class VennDiagramProofByContradiction(Scene): ) words1 = TextMobject("85 also \\\\", "pass ", "B") - words1.highlight_by_tex("B", GREEN) + words1.set_color_by_tex("B", GREEN) words1.scale(0.8) words1.next_to(A_group, LEFT, LARGE_BUFF).shift(UP) arrow1 = Arrow( words1.get_right(), in_B.get_corner(UP+LEFT) + MED_LARGE_BUFF*(DOWN+RIGHT) ) - arrow1.highlight(GREEN) + arrow1.set_color(GREEN) words2 = TextMobject("15 blocked \\\\", "by ", "B") - words2.highlight_by_tex("B", GREEN) + words2.set_color_by_tex("B", GREEN) words2.scale(0.8) words2.next_to(A_group, LEFT, MED_LARGE_BUFF, UP) arrow2 = Arrow(words2.get_right(), out_of_B[-1]) - arrow2.highlight(RED) + arrow2.set_color(RED) self.play( Write(words1, run_time = 1), @@ -1700,7 +1700,7 @@ class VennDiagramProofByContradiction(Scene): "get blocked by ", "C", ) words.scale(0.8) - words.highlight_by_tex_to_color_map({ + words.set_color_by_tex_to_color_map({ "B" : GREEN, "C" : BLUE, }) @@ -1714,7 +1714,7 @@ class VennDiagramProofByContradiction(Scene): arrow = Arrow(words.get_right(), out_of_C) - arrow.highlight(GREEN) + arrow.set_color(GREEN) C_copy = C.copy() C_copy.set_fill(BLACK, opacity = 1) @@ -1788,9 +1788,9 @@ class VennDiagramProofByContradiction(Scene): terms.arrange_submobjects(RIGHT) terms.to_edge(UP) for term, index, group in zip(terms, [-3, -2, -2], photon_groups): - term.highlight_by_tex("checkmark", "#00ff00") + term.set_color_by_tex("checkmark", "#00ff00") cross = Cross(term[index]) - cross.highlight("#ff0000") + cross.set_color("#ff0000") cross.set_stroke(width = 8) term[index].add(cross) @@ -1820,7 +1820,7 @@ class VennDiagramProofByContradiction(Scene): nums = [should_be_50, lt_fifteen, fifteen] cross = Cross(less_than) - cross.highlight("#ff0000") + cross.set_color("#ff0000") cross.set_stroke(width = 8) tweaser_group = VGroup( @@ -1938,7 +1938,7 @@ class VennDiagramProofByContradiction(Scene): morty.to_corner(DOWN+RIGHT) contradiction = TextMobject("Contradiction!") contradiction.next_to(morty, UP, aligned_edge = RIGHT) - contradiction.highlight(RED) + contradiction.set_color(RED) self.play(FadeIn(morty)) self.play( @@ -1970,9 +1970,9 @@ class VennDiagramProofByContradiction(Scene): photon.target.center().to_edge(LEFT).shift(DOWN) bubble = ThoughtBubble() content = TexMobject("A", "\\checkmark", ",", "C") - content.highlight_by_tex("checkmark", "#00ff00") + content.set_color_by_tex("checkmark", "#00ff00") cross = Cross(content[-1]) - cross.highlight("#ff0000") + cross.set_color("#ff0000") content.add(cross) bubble.add_content(content) bubble.resize_to_content() @@ -2100,7 +2100,7 @@ class ReEmphasizeVennDiagram(VennDiagramProofByContradiction): words = TextMobject("Should be 15\\% \\\\ of circle ", "A") words.scale(0.7) - words.highlight_by_tex("A", RED) + words.set_color_by_tex("A", RED) words.next_to(A, UP, LARGE_BUFF) words.shift(RIGHT) arrow = Arrow( @@ -2139,7 +2139,7 @@ class ReEmphasizeVennDiagram(VennDiagramProofByContradiction): words = TextMobject("Should be 15\\% \\\\ of circle ", "B") words.scale(0.7) - words.highlight_by_tex("B", GREEN) + words.set_color_by_tex("B", GREEN) words.next_to(B, LEFT) words.shift(2.5*UP) arrow = Arrow( @@ -2230,7 +2230,7 @@ class ReEmphasizeVennDiagram(VennDiagramProofByContradiction): ) inequality.arrange_submobjects(RIGHT) for tex in inequality: - tex.highlight_by_tex("checkmark", "#00ff00") + tex.set_color_by_tex("checkmark", "#00ff00") if len(tex) > 1: cross = Cross(tex[-2], color = "#ff0000") cross.set_stroke(width = 8) @@ -2325,7 +2325,7 @@ class ReEmphasizeVennDiagram(VennDiagramProofByContradiction): "...somehow" ) words.scale(0.7) - words.highlight_by_tex("A", RED) + words.set_color_by_tex("A", RED) words.move_to(5*LEFT + 2*UP) self.play(Write(words)) @@ -2428,7 +2428,7 @@ class NoFirstMeasurementPreferenceBasedOnDirection(ShowVariousFilterPairs): pf.move_to(z*OUT) label = TextMobject(char) label.add_background_rectangle() - label.highlight(color) + label.set_color(color) label.scale(0.7) label.rotate(np.pi/2, RIGHT) label.rotate(-np.pi/2, OUT) diff --git a/old_projects/borsuk.py b/old_projects/borsuk.py index df8fe73b..001c30e3 100644 --- a/old_projects/borsuk.py +++ b/old_projects/borsuk.py @@ -139,14 +139,14 @@ class CheckOutMathologer(PiCreatureScene): logo.scale_to_fit_height(self.logo_height) logo.to_corner(UP+LEFT) if self.logo_color is not None: - logo.highlight(self.logo_color) + logo.set_color(self.logo_color) logo.stroke_width = 1 return logo def get_logo_intro_animation(self, logo): logo.save_state() logo.shift(DOWN) - logo.highlight(BLACK) + logo.set_color(BLACK) return ApplyMethod(logo.restore) class IntroduceStolenNecklaceProblem(ThreeDScene): @@ -603,7 +603,7 @@ class WriteWords(Scene): } def construct(self): words = TextMobject(self.words) - words.highlight(self.color) + words.set_color(self.color) words.scale_to_fit_width(FRAME_WIDTH-1) words.to_edge(DOWN) self.play(Write(words)) @@ -692,7 +692,7 @@ class TemperaturePressurePlane(GraphScene): def add_example_coordinates(self): dot = Dot(self.coords_to_point(*self.example_point_coords)) - dot.highlight(YELLOW) + dot.set_color(YELLOW) tex = TexMobject("(25^\\circ\\text{C}, 101 \\text{ kPa})") tex.next_to(dot, UP+RIGHT, buff = SMALL_BUFF) @@ -710,7 +710,7 @@ class TemperaturePressurePlane(GraphScene): point = self.coords_to_point(*self.example_point_coords) path.shift(point) - path.highlight(GREEN) + path.set_color(GREEN) self.play(ShowCreation(path, run_time = 10, rate_func = None)) self.wait() @@ -783,7 +783,7 @@ class WalkEquatorPostTransform(GraphScene): def walk_equator(self): equator = self.great_arc_images[0] dots = VGroup(Dot(), Dot()) - dots.highlight(MAROON_B) + dots.set_color(MAROON_B) dot_movement = self.get_arc_walk_dot_movement(equator, dots) dot_movement.update(0) @@ -820,7 +820,7 @@ class WalkEquatorPostTransform(GraphScene): tilted_eq = self.great_arc_images[1] dots = VGroup(Dot(), Dot()) - dots.highlight(MAROON_B) + dots.set_color(MAROON_B) dot_movement = self.get_arc_walk_dot_movement(tilted_eq, dots) dot_movement.update(0) @@ -903,7 +903,7 @@ class WalkEquatorPostTransform(GraphScene): rate_func = lambda t : 0.455*smooth(t) ) self.play( - dots.highlight, YELLOW, + dots.set_color, YELLOW, dots.scale_in_place, 1.2, rate_func = there_and_back ) @@ -942,8 +942,8 @@ class WalkEquatorPostTransform(GraphScene): for s in np.arange(0, 1, 1./self.num_great_arcs) # for s in [0] ]) - curves.highlight(YELLOW) - curves[0].highlight(RED) + curves.set_color(YELLOW) + curves[0].set_color(RED) for curve in curves: antipodal_x_diff = lambda x : \ curve.point_from_proportion(x+0.5)[0]-\ @@ -974,7 +974,7 @@ class WalkEquatorPostTransform(GraphScene): ])) full_curve = VMobject(close_new_points = True) full_curve.set_points_smoothly(points + [points[0]]) - full_curve.highlight(MAROON_B) + full_curve.set_color(MAROON_B) first_half = full_curve.copy().pointwise_become_partial( full_curve, 0, 0.5 ) @@ -1049,7 +1049,7 @@ class PointsIn3D(Scene): for index, subindex_list in (1, [1, 2, 4, 5, 7, 8]), (3, [0, 2, 4, 6, 8, 10]): colors = np.repeat(self.colors, 2) for subindex, color in zip(subindex_list, colors): - sphere_def[index][subindex].highlight(color) + sphere_def[index][subindex].set_color(color) point_ex = TextMobject( "For example, ", @@ -1057,7 +1057,7 @@ class PointsIn3D(Scene): arg_separator = "" ) for index, color in zip([2, 4, 6], self.colors): - point_ex[index].highlight(color) + point_ex[index].set_color(color) point_ex.scale(0.8) point_ex.next_to( sphere_def[1], UP+RIGHT, @@ -1115,7 +1115,7 @@ class WritePointCoordinates(Scene): arg_separator = "" ) for index, color in zip([1, 3, 5], self.colors): - coords[index].highlight(color) + coords[index].set_color(color) return coords class WriteAntipodalCoordinates(WritePointCoordinates): @@ -1130,8 +1130,8 @@ class WriteAntipodalCoordinates(WritePointCoordinates): arg_separator = "" ) for index, color in zip([2, 5, 8], self.colors): - coords[index].highlight(color) - coords[index-1].highlight(self.sign_color) + coords[index].set_color(color) + coords[index-1].set_color(self.sign_color) return coords class GeneralizeBorsukUlam(Scene): @@ -1182,8 +1182,8 @@ class GeneralizeBorsukUlam(Scene): for d in range(1, 1+self.n_dims) ]) for square, color in zip(squares, self.colors): - square[0].highlight(color) - square[-1].highlight(color) + square[0].set_color(color) + square[-1].set_color(color) plusses = [TexMobject("+") for x in range(self.n_dims-1)] plusses += [TexMobject("=1")] condition = VGroup(*it.chain(*zip(squares, plusses))) @@ -1198,7 +1198,7 @@ class GeneralizeBorsukUlam(Scene): ])) tup = TexMobject(*["("] + mid_parts + ["x_%d"%self.n_dims, ")"]) for index, color in zip(it.count(1, 2), self.colors): - tup[index].highlight(color) + tup[index].set_color(color) return tup @@ -1209,8 +1209,8 @@ class GeneralizeBorsukUlam(Scene): ])) tup = TexMobject(*["("] + mid_parts + ["-", "x_%d"%self.n_dims, ")"]) for index, color in zip(it.count(1, 3), self.colors): - tup[index].highlight(self.negative_color) - tup[index+1].highlight(color) + tup[index].set_color(self.negative_color) + tup[index+1].set_color(color) return tup @@ -1224,7 +1224,7 @@ class GeneralizeBorsukUlam(Scene): # ])) # tup = TexMobject(*["("] + mid_parts + ["y_%d"%n_dims, ")"]) # for index, color in zip(it.count(1, 2), colors): - # tup[index].highlight(color) + # tup[index].set_color(color) # return tup @@ -1289,7 +1289,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem): self.color_necklace() self.find_continuous_fair_division() self.show_continuous_fair_division() - self.highlight_continuous_groups() + self.set_color_continuous_groups() self.mention_equivalence_to_discrete_case() self.shift_divide_off_tick_marks() @@ -1504,7 +1504,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem): self.groups = groups - def highlight_continuous_groups(self): + def set_color_continuous_groups(self): top_group = VGroup(self.groups[0], self.groups[2]) bottom_group = self.groups[1] boxes = VGroup() @@ -1535,7 +1535,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem): self.play(Write(weight_description)) self.wait() - self.highlight_box = boxes + self.set_color_box = boxes self.weight_description = weight_description def mention_equivalence_to_discrete_case(self): @@ -1611,7 +1611,7 @@ class MakeTwoJewelCaseContinuous(IntroduceStolenNecklaceProblem): words.shift(2*UP) arrow1 = Arrow(words.get_bottom(), left_segment.parts[0].get_right()) arrow2 = Arrow(words.get_bottom(), right_segment.parts[1].get_left()) - VGroup(words, arrow1, arrow2).highlight(RED) + VGroup(words, arrow1, arrow2).set_color(RED) self.play(Write(words), ShowCreation(arrow1)) self.wait() @@ -1765,13 +1765,13 @@ class ChoicesInNecklaceCutting(ReconfigurableScene): VGroup( brace.label, brace.concrete_label - ).highlight(YELLOW) + ).set_color(YELLOW) words = TextMobject( "1) Choose", "$a$, $b$, $c$", "so that", "$a+b+c = 1$" ) - words[1].highlight(YELLOW) - words[3].highlight(YELLOW) + words[1].set_color(YELLOW) + words[3].set_color(YELLOW) words.to_corner(UP+LEFT) self.play(*it.chain(*[ @@ -1884,7 +1884,7 @@ class ChoicesInNecklaceCutting(ReconfigurableScene): ] for point, arrow_pair in zip(pre_arrow_points, arrow_pairs): for arrow, color in zip(arrow_pair, [GREEN, RED]): - arrow.highlight(color) + arrow.set_color(color) arrow.move_to(point.get_center()) return arrow_pairs, pre_arrow_points @@ -1893,7 +1893,7 @@ class ChoicesInNecklaceCutting(ReconfigurableScene): *it.chain(*[ [ line.rotate_in_place, np.pi/12, vect, - line.highlight, RED + line.set_color, RED ] for line, vect in zip(self.v_lines, [OUT, IN]) ]), @@ -1927,13 +1927,13 @@ class ChoicesForSpherePoint(GeneralizeBorsukUlam): def get_tuple(self): tup = TexMobject("(x, y, z)") for i, color in zip([1, 3, 5], self.colors): - tup[i].highlight(color) + tup[i].set_color(color) return tup def get_condition(self): condition = TexMobject("x^2+y^2+z^2 = 1") for i, color in zip([0, 3, 6], self.colors): - VGroup(*condition[i:i+2]).highlight(color) + VGroup(*condition[i:i+2]).set_color(color) return condition def add_sphere_set(self): @@ -1952,7 +1952,7 @@ class ChoicesForSpherePoint(GeneralizeBorsukUlam): ) for i in 1, 3: for j, color in zip([0, 3, 6], self.colors): - VGroup(*choice_one_words[i][j:j+2]).highlight(color) + VGroup(*choice_one_words[i][j:j+2]).set_color(color) choice_one_words.to_corner(UP+LEFT) choice_two_words = TextMobject( @@ -1969,7 +1969,7 @@ class ChoicesForSpherePoint(GeneralizeBorsukUlam): def show_example_choices(self): choices = VGroup(*[ - TexMobject(*tex).highlight(color) + TexMobject(*tex).set_color(color) for color, tex in zip(self.colors, [ ("x", "^2 = ", "1/6"), ("y", "^2 = ", "1/3"), @@ -2008,7 +2008,7 @@ class ChoicesForSpherePoint(GeneralizeBorsukUlam): sqrt.scale(0.6) sqrts.arrange_submobjects(DOWN) sqrts.next_to(choice, RIGHT, buff = LARGE_BUFF) - sqrts.highlight(choice.get_color()) + sqrts.set_color(choice.get_color()) arrows = VGroup(*[ Arrow( @@ -2049,7 +2049,7 @@ class NecklaceDivisionSphereAssociation(ChoicesInNecklaceCutting): ) for i, j_list in (0, [1, 3, 5]), (2, [0, 3, 6]): for j, color in zip(j_list, self.xyz_colors): - label[i][j].highlight(color) + label[i][j].set_color(color) label.to_corner(UP+RIGHT) ghost_sphere_point = VectorizedPoint() @@ -2079,7 +2079,7 @@ class NecklaceDivisionSphereAssociation(ChoicesInNecklaceCutting): "$%s^2$"%char, "$= 1/%d$"%denom, buff = SMALL_BUFF ) - brace.label.highlight(color) + brace.label.set_color(color) if brace.label.get_right()[0] > brace.get_right()[0]: brace.label.next_to( brace, UP, buff = SMALL_BUFF, @@ -2113,8 +2113,8 @@ class NecklaceDivisionSphereAssociation(ChoicesInNecklaceCutting): for sign in "+", "-" ] for choice, color in zip(choices, [GREEN, RED]): - # choice[0].highlight(brace.label.get_color()) - choice[2].highlight(color) + # choice[0].set_color(brace.label.get_color()) + choice[2].set_color(color) choice.scale(0.8) choice.move_to(group) if choice.get_width() > 0.8*group.get_width(): @@ -2147,7 +2147,7 @@ class NecklaceDivisionSphereAssociation(ChoicesInNecklaceCutting): def ask_about_antipodal_pairs(self): question = TextMobject("What do antipodal points signify?") question.move_to(self.sphere_point_label, LEFT) - question.highlight(MAROON_B) + question.set_color(MAROON_B) antipodal_tex = TexMobject( "(x, y, z) \\rightarrow (-x, -y, -z)" ) @@ -2380,7 +2380,7 @@ class ShowFunctionDiagram(TotalLengthOfEachJewelEquals, ReconfigurableScene): def add_sphere_arrow(self): up_down_arrow = TexMobject("\\updownarrow") up_down_arrow.scale(1.5) - up_down_arrow.highlight(YELLOW) + up_down_arrow.set_color(YELLOW) up_down_arrow.next_to(self.necklace, DOWN, buff = LARGE_BUFF) to_plane_arrow = Arrow( diff --git a/old_projects/brachistochrone/curves.py b/old_projects/brachistochrone/curves.py index bf4d6253..91c8da12 100644 --- a/old_projects/brachistochrone/curves.py +++ b/old_projects/brachistochrone/curves.py @@ -284,7 +284,7 @@ class TryManyPaths(PathSlidingScene): Line(3*UP+LEFT, LEFT), Arc(angle = np.pi/2, start_angle = np.pi), Line(DOWN, DOWN+3*RIGHT) - ).ingest_submobjects().highlight(GREEN) + ).ingest_submobjects().set_color(GREEN) paths = [ Arc( angle = np.pi/2, @@ -409,11 +409,11 @@ class MinimalPotentialEnergy(Scene): density = 3*DEFAULT_POINT_DENSITY_1D ) graph.stretch_to_fit_width(2*horiz_radius) - graph.highlight(YELLOW) + graph.set_color(YELLOW) min_point = Dot(graph.get_bottom()) nature_finds = TextMobject("Nature finds this point") nature_finds.scale(0.5) - nature_finds.highlight(GREEN) + nature_finds.set_color(GREEN) nature_finds.shift(2*RIGHT+3*UP) arrow = Arrow( nature_finds.get_bottom(), min_point, @@ -438,7 +438,7 @@ class MinimalPotentialEnergy(Scene): for words in last_side_words: words.next_to(side_words_start, DOWN) for words in top_words[1], last_side_words[1]: - words.highlight(RED) + words.set_color(RED) self.add( axes, top_words[0], side_words_start, @@ -650,7 +650,7 @@ class DefineCurveWithKnob(PathSlidingScene): self.path = self.get_path() self.path.shift(1.5*DOWN) self.path.show() - self.path.highlight(BLACK) + self.path.set_color(BLACK) randy = Randolph() randy.scale(RANDY_SCALE_FACTOR) @@ -673,7 +673,7 @@ class DefineCurveWithKnob(PathSlidingScene): d_angle = angle-self.last_angle self.knob.rotate_in_place(d_angle) self.last_angle = angle - self.path.highlight(BLUE_D, lambda p : p[0] < point[0]) + self.path.set_color(BLUE_D, lambda p : p[0] < point[0]) diff --git a/old_projects/brachistochrone/cycloid.py b/old_projects/brachistochrone/cycloid.py index 20dc6358..31c0c348 100644 --- a/old_projects/brachistochrone/cycloid.py +++ b/old_projects/brachistochrone/cycloid.py @@ -240,7 +240,7 @@ class LeviSolution(CycloidScene): tangent_line = Line(3*LEFT, 3*RIGHT) tangent_line.rotate(line_angle-np.pi/2) tangent_line.shift(self.p_point) - tangent_line.highlight(arc_color) + tangent_line.set_color(arc_color) right_angle_symbol = Mobject( Line(UP, UP+RIGHT), Line(UP+RIGHT, RIGHT) @@ -382,7 +382,7 @@ class LeviSolution(CycloidScene): self.play(FadeIn(triangle1)) self.wait() self.play(Transform(triangle1, triangle2)) - self.play(ApplyMethod(triangle1.highlight, MAROON)) + self.play(ApplyMethod(triangle1.set_color, MAROON)) self.wait() self.remove(triangle1) self.add(y_line) diff --git a/old_projects/brachistochrone/graveyard.py b/old_projects/brachistochrone/graveyard.py index 7a4d58db..a3e5bf2c 100644 --- a/old_projects/brachistochrone/graveyard.py +++ b/old_projects/brachistochrone/graveyard.py @@ -35,7 +35,7 @@ class MultilayeredGlass(PhotonScene, ZoomedScene): } def construct(self): self.cycloid = Cycloid(end_theta = np.pi) - self.cycloid.highlight(YELLOW) + self.cycloid.set_color(YELLOW) self.top = self.cycloid.get_top()[1] self.bottom = self.cycloid.get_bottom()[1]-1 self.generate_layers() diff --git a/old_projects/brachistochrone/light.py b/old_projects/brachistochrone/light.py index c6865964..5d749fde 100644 --- a/old_projects/brachistochrone/light.py +++ b/old_projects/brachistochrone/light.py @@ -69,7 +69,7 @@ class PhotonScene(Scene): if "rate_func" not in kwargs: kwargs["rate_func"] = None photon = self.wavify(path) - photon.highlight(color) + photon.set_color(color) return ShowPassingFlash(photon, **kwargs) @@ -92,7 +92,7 @@ class MultipathPhotonScene(PhotonScene): paths = self.get_paths() colors = Color(YELLOW).range_to(WHITE, len(paths)) for path, color in zip(paths, colors): - path.highlight(color) + path.set_color(color) photon_runs = [ self.photon_run_along_path(path) for path in paths @@ -165,7 +165,7 @@ class TransitionToOptics(PhotonThroughLens): class PhotonOffMirror(MultipathPhotonScene): def construct(self): self.mirror = Line(*FRAME_Y_RADIUS*np.array([DOWN, UP])) - self.mirror.highlight(GREY) + self.mirror.set_color(GREY) self.add(self.mirror) self.run_along_paths() @@ -267,7 +267,7 @@ class ShowMultiplePathsThroughLens(ShowMultiplePathsScene): Line(self.start_point, a), Line(a, b), Line(b, self.end_point) - ).highlight(color) + ).set_color(color) for (a, b), color in zip( [ (upper_left, upper_right), @@ -283,7 +283,7 @@ class ShowMultiplePathsThroughLens(ShowMultiplePathsScene): class ShowMultiplePathsOffMirror(ShowMultiplePathsScene): def construct(self): mirror = Line(*FRAME_Y_RADIUS*np.array([DOWN, UP])) - mirror.highlight(GREY) + mirror.set_color(GREY) self.add(mirror) ShowMultiplePathsScene.construct(self) @@ -296,7 +296,7 @@ class ShowMultiplePathsOffMirror(ShowMultiplePathsScene): Mobject( Line(self.start_point, midpoint), Line(midpoint, self.end_point) - ).highlight(color) + ).set_color(color) for midpoint, color in zip( [2*UP, 2*DOWN], Color(YELLOW).range_to(WHITE, 2) @@ -347,7 +347,7 @@ class ShowMultiplePathsInWater(ShowMultiplePathsScene): Mobject( Line(self.start_point, midpoint), Line(midpoint, self.end_point) - ).highlight(color) + ).set_color(color) for midpoint, color in zip( [3*LEFT, 3*RIGHT], Color(YELLOW).range_to(WHITE, 2) @@ -390,7 +390,7 @@ class StraightLinesFastestInConstantMedium(PhotonScene): line = Line(start, end) result = [squaggle, line] for mob in result: - mob.highlight(BLUE_D) + mob.set_color(BLUE_D) return result class PhtonBendsInWater(PhotonScene, ZoomedScene): @@ -406,14 +406,14 @@ class PhtonBendsInWater(PhotonScene, ZoomedScene): path2 = Mobject(top_line, bottom_line) for mob in path1, path2: mob.ingest_submobjects() - extension.highlight(RED) + extension.set_color(RED) theta1 = np.arctan(bottom_line.get_slope()) theta2 = np.arctan(extension.get_slope()) arc = Arc(theta2-theta1, start_angle = theta1, radius = 2) question_mark = TextMobject("$\\theta$?") question_mark.shift(arc.get_center()+0.5*DOWN+0.25*RIGHT) wave = self.wavify(path2) - wave.highlight(YELLOW) + wave.set_color(YELLOW) wave.scale(0.5) self.add(glass) @@ -506,7 +506,7 @@ class GeometryOfGlassSituation(ShowMultiplePathsInWater): x_min = -2, x_max = 4 ) - graph.highlight(YELLOW) + graph.set_color(YELLOW) Mobject(axes, graph).scale(0.2).to_corner(UP+RIGHT, buff = 1) axes.add(TexMobject("x", size = "\\small").next_to(axes, RIGHT)) axes.add(TextMobject("Travel time", size = "\\small").next_to( @@ -806,7 +806,7 @@ class SpringSetup(ShowMultiplePathsInWater): bars = Mobject(bar1, bar2) new_eq = equals.copy().center().shift(bars.get_center()) snells = TextMobject("Snell's Law") - snells.highlight(YELLOW) + snells.set_color(YELLOW) snells.shift(new_eq.get_center()[0]*RIGHT) snells.shift(UP) @@ -862,7 +862,7 @@ class WhichPathWouldLightTake(PhotonScene, TryManyPaths): words = TextMobject( ["Which path ", "would \\emph{light} take", "?"] ) - words.split()[1].highlight(YELLOW) + words.split()[1].set_color(YELLOW) words.to_corner(UP+RIGHT) self.add_cycloid_end_points() @@ -916,7 +916,7 @@ class StateSnellsLaw(PhotonScene): equation.to_corner(UP+RIGHT) exp1, equals, exp2 = equation.split() snells_law = TextMobject("Snell's Law:") - snells_law.highlight(YELLOW) + snells_law.set_color(YELLOW) snells_law.to_edge(UP) self.play(ShimmerIn(snells_law)) diff --git a/old_projects/brachistochrone/misc.py b/old_projects/brachistochrone/misc.py index aeec9eec..c5bc0c12 100644 --- a/old_projects/brachistochrone/misc.py +++ b/old_projects/brachistochrone/misc.py @@ -36,7 +36,7 @@ class PhysicalIntuition(Scene): Arrow(ORIGIN, np.sqrt(2)*point) for point in compass_directions(4, RIGHT+UP) ]) - arrows.highlight(YELLOW) + arrows.set_color(YELLOW) arrows.ingest_submobjects() all_arrows = Mobject(*[ arrows.copy().scale(0.3/(x)).shift(x*RIGHT) @@ -49,7 +49,7 @@ class PhysicalIntuition(Scene): terms.shift(2*UP) plane = NumberPlane(color = BLUE_E) axes = Mobject(NumberLine(), NumberLine().rotate(np.pi/2)) - axes.highlight(WHITE) + axes.set_color(WHITE) for term in terms.split(): self.play(ShimmerIn(term, run_time = 0.5)) @@ -148,7 +148,7 @@ class StayedUpAllNight(Scene): use_cache = False ) solution.stroke_width = 3 - solution.highlight(GREY) + solution.set_color(GREY) solution.scale_to_fit_width(5) solution.to_corner(UP+RIGHT) newton = ImageMobject("Old_Newton", invert = False) @@ -174,7 +174,7 @@ class StayedUpAllNight(Scene): ], size = "\\small") newton_complaint.to_edge(UP, buff = 0.2) dunned = newton_complaint.split()[1] - dunned.highlight() + dunned.set_color() dunned_def = TextMobject("(old timey term for making \\\\ demands on someone)") dunned_def.scale(0.7) dunned_def.next_to(phil_trans, LEFT) @@ -403,7 +403,7 @@ class ShortestPathProblem(Scene): ) path.scale(6/(2*np.pi)) path.shift(point_a - path.points[0]) - path.highlight(RED) + path.set_color(RED) line = Line(point_a, point_b) words = TextMobject("Shortest path from $A$ to $B$") words.to_edge(UP) diff --git a/old_projects/brachistochrone/multilayered.py b/old_projects/brachistochrone/multilayered.py index f59d0047..fd2fe63a 100644 --- a/old_projects/brachistochrone/multilayered.py +++ b/old_projects/brachistochrone/multilayered.py @@ -228,7 +228,7 @@ class ShowLayerVariables(MultilayeredScene, PhotonScene): ) eq_mob.shift(layer.get_center()+2*LEFT) v_eq = eq_mob.split() - v_eq[0].highlight(layer.get_color()) + v_eq[0].set_color(layer.get_color()) path = Line(FRAME_X_RADIUS*LEFT, FRAME_X_RADIUS*RIGHT) path.shift(layer.get_center()) brace_endpoints = Mobject( @@ -375,7 +375,7 @@ class ContinuouslyObeyingSnellsLaw(MultilayeredScene): self.freeze_background() cycloid = Cycloid(end_theta = np.pi) - cycloid.highlight(YELLOW) + cycloid.set_color(YELLOW) chopped_cycloid = cycloid.copy() n = cycloid.get_num_points() chopped_cycloid.filter_out(lambda p : p[1] > 1 and p[0] < 0) diff --git a/old_projects/brachistochrone/wordplay.py b/old_projects/brachistochrone/wordplay.py index 4b4eabce..af002f31 100644 --- a/old_projects/brachistochrone/wordplay.py +++ b/old_projects/brachistochrone/wordplay.py @@ -28,7 +28,7 @@ class Intro(Scene): def construct(self): logo = ImageMobject("LogoGeneration", invert = False) name_mob = TextMobject("3Blue1Brown").center() - name_mob.highlight("grey") + name_mob.set_color("grey") name_mob.shift(2*DOWN) self.add(name_mob, logo) @@ -160,10 +160,10 @@ class DisectBrachistochroneWord(Scene): overbrace2 = Brace(word.split()[-1], UP) shortest = TextMobject("Shortest") shortest.next_to(overbrace1, UP) - shortest.highlight(YELLOW) + shortest.set_color(YELLOW) time = TextMobject("Time") time.next_to(overbrace2, UP) - time.highlight(YELLOW) + time.set_color(YELLOW) chrono_example = TextMobject(""" As in ``Chronological'' \\\\ or ``Synchronize'' @@ -171,7 +171,7 @@ class DisectBrachistochroneWord(Scene): chrono_example.scale(0.5) chrono_example.to_edge(RIGHT) chrono_example.shift(2*UP) - chrono_example.highlight(BLUE_D) + chrono_example.set_color(BLUE_D) chrono_arrow = Arrow( word.get_right(), chrono_example.get_bottom(), @@ -181,7 +181,7 @@ class DisectBrachistochroneWord(Scene): brachy_example.scale(0.5) brachy_example.to_edge(LEFT) brachy_example.shift(2*DOWN) - brachy_example.highlight(GREEN) + brachy_example.set_color(GREEN) brachy_arrow = Arrow( word.get_left(), brachy_example.get_top(), @@ -199,7 +199,7 @@ class DisectBrachistochroneWord(Scene): for mob in latin, greek: mob.to_edge(LEFT) question_mark = TextMobject("?").next_to(greek, buff = 0.1) - stars = Stars().highlight(BLACK) + stars = Stars().set_color(BLACK) stars.scale(0.5).shift(question_mark.get_center()) self.play(Transform(original_word, word), ShowCreation(dots)) @@ -265,11 +265,11 @@ class CircleOfIdeas(Scene): words = map(TextMobject, [ "optics", "calculus", "mechanics", "geometry", "history" ]) - words[0].highlight(YELLOW) - words[1].highlight(BLUE_D) - words[2].highlight(GREY) - words[3].highlight(GREEN) - words[4].highlight(MAROON) + words[0].set_color(YELLOW) + words[1].set_color(BLUE_D) + words[2].set_color(GREY) + words[3].set_color(GREEN) + words[4].set_color(MAROON) brachistochrone = TextMobject("Brachistochrone") displayed_words = [] for word in words: @@ -284,7 +284,7 @@ class CircleOfIdeas(Scene): self.play(*self.get_spinning_anims(displayed_words)) self.play(*[ Transform( - word, word.copy().highlight(BLACK).center().scale(0.1), + word, word.copy().set_color(BLACK).center().scale(0.1), path_func = path_along_arc(np.pi), rate_func = None, run_time = 2 @@ -319,7 +319,7 @@ class FermatsPrincipleStatement(Scene): fastest path possible. """ ]) - words.split()[0].highlight(BLUE) + words.split()[0].set_color(BLUE) everything = MobjectFromRegion(Region()) everything.scale(0.9) angles = np.apply_along_axis( @@ -342,7 +342,7 @@ class FermatsPrincipleStatement(Scene): Animation(words) ) self.play( - ApplyMethod(everything.highlight, WHITE), + ApplyMethod(everything.set_color, WHITE), ) self.wait() @@ -385,7 +385,7 @@ class VideoProgression(Scene): FadeOut(light_in_two), GrowFromCenter(snells), DelayByOrder( - ApplyMethod(arrow2.highlight, BLUE_D) + ApplyMethod(arrow2.set_color, BLUE_D) ) ) self.wait() @@ -393,7 +393,7 @@ class VideoProgression(Scene): FadeOut(optics), GrowFromCenter(multi), DelayByOrder( - ApplyMethod(arrow1.highlight, BLUE_D) + ApplyMethod(arrow1.set_color, BLUE_D) ) ) self.wait() @@ -414,7 +414,7 @@ class BalanceCompetingFactors(Scene): def construct(self, *words): factor1, factor2 = [ - TextMobject("Factor %d"%x).highlight(c) + TextMobject("Factor %d"%x).set_color(c) for x, c in [ (1, RED_D), (2, BLUE_D) @@ -424,10 +424,10 @@ class BalanceCompetingFactors(Scene): for word in factor1, factor2, real_factor1, real_factor2: word.shift(0.2*UP-word.get_bottom()) for f1 in factor1, real_factor1: - f1.highlight(RED_D) + f1.set_color(RED_D) f1.shift(2*LEFT) for f2 in factor2, real_factor2: - f2.highlight(BLUE_D) + f2.set_color(BLUE_D) f2.shift(2*RIGHT) line = Line( factor1.get_left(), diff --git a/old_projects/complex_multiplication_article.py b/old_projects/complex_multiplication_article.py index 3b48eab4..1c607748 100644 --- a/old_projects/complex_multiplication_article.py +++ b/old_projects/complex_multiplication_article.py @@ -204,7 +204,7 @@ class DrawComplexAngleAndMagnitude(Scene): edge = label.get_edge_center(-dot_to_label_dir) buff = 0.1 label.shift(point - edge + buff*dot_to_label_dir) - label.highlight(YELLOW) + label.set_color(YELLOW) self.add_mobjects_among(locals().values()) diff --git a/old_projects/counting_in_binary.py b/old_projects/counting_in_binary.py index f777c1ac..e71deb8c 100644 --- a/old_projects/counting_in_binary.py +++ b/old_projects/counting_in_binary.py @@ -107,8 +107,8 @@ class Hand(ImageMobject): def shrink(self): self.scale_in_place(0.8).to_edge(DOWN, buff = 0.0) - # def highlight_thumb(self, color = "yellow"): - # self.highlight( + # def set_color_thumb(self, color = "yellow"): + # self.set_color( # color = color, # condition = lambda p : p[0] > 4.5 and p[1] > -1.5 # ) @@ -338,7 +338,7 @@ class ShowIncrementRule(Scene): def get_arrow_set(self, num): arrow = TexMobject("\\downarrow", size = "\\Huge") - arrow.highlight("green") + arrow.set_color("green") arrow.shift(-arrow.get_bottom()) if num == 12: tips = [(4, 1, 0)] @@ -392,7 +392,7 @@ class MindFindsShortcuts(Scene): ) self.wait() self.play( - Transform(compound, Arrow(hand, seven).highlight("yellow")), + Transform(compound, Arrow(hand, seven).set_color("yellow")), ShimmerIn(TextMobject("Directly recognize").shift(1.5*DOWN+2*RIGHT)) ) self.wait() @@ -415,11 +415,11 @@ class MindFindsShortcuts(Scene): self.wait() self.play( Transform( - deepcopy(hands[16]).highlight("black").center().shift(hands[23].get_center()), + deepcopy(hands[16]).set_color("black").center().shift(hands[23].get_center()), hands[16] ), Transform( - deepcopy(hands[7]).highlight("black").center().shift(hands[23].get_center()), + deepcopy(hands[7]).set_color("black").center().shift(hands[23].get_center()), hands[7] ), Animation(hands[23]), diff --git a/old_projects/crypto.py b/old_projects/crypto.py index 0b3ed42f..88a55cb4 100644 --- a/old_projects/crypto.py +++ b/old_projects/crypto.py @@ -81,7 +81,7 @@ class EthereumLogo(SVGMobject): def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) for part, char in zip(self.submobjects, self.color_chars): - part.highlight("#" + 6*char) + part.set_color("#" + 6*char) class LitecoinLogo(SVGMobject): CONFIG = { @@ -127,7 +127,7 @@ class TenDollarBill(VGroup): ten = TexMobject("\\$10") ten.scale_to_fit_height(0.25*self.height) ten.next_to(self.get_corner(vect), -vect, SMALL_BUFF) - ten.highlight(GREEN_C) + ten.set_color(GREEN_C) self.add(ten) @@ -143,7 +143,7 @@ class AskQuestion(Scene): "have ", "a", "Bitcoin?" ] question = TextMobject(*strings) - question.highlight_by_tex("have", YELLOW) + question.set_color_by_tex("have", YELLOW) self.wait() for word, part in zip(strings, question): n_chars = len(word.strip()) @@ -199,7 +199,7 @@ class UnknownAuthor(Scene): question = TextMobject("Who is this?") question.next_to(rect, RIGHT, buff = 1.5) arrow = Arrow(question, rect, buff = SMALL_BUFF) - VGroup(question, arrow, rect).highlight(RED_D) + VGroup(question, arrow, rect).set_color(RED_D) self.play(ShowCreation(rect)) self.play( @@ -218,7 +218,7 @@ class DisectQuestion(TeacherStudentsScene): question = TextMobject( "What does it mean to", "have", "a", "Bitcoin?" ) - question.highlight_by_tex("have", YELLOW) + question.set_color_by_tex("have", YELLOW) question.next_to(self.teacher, UP) question.to_edge(RIGHT, buff = LARGE_BUFF) question.save_state() @@ -242,9 +242,9 @@ class DisectQuestion(TeacherStudentsScene): ) topics.scale_to_fit_width(FRAME_WIDTH - LARGE_BUFF) topics.to_edge(UP) - topics.highlight_by_tex("Digital", BLUE) - topics.highlight_by_tex("Proof", GREEN) - topics.highlight_by_tex("hash", YELLOW) + topics.set_color_by_tex("Digital", BLUE) + topics.set_color_by_tex("Proof", GREEN) + topics.set_color_by_tex("hash", YELLOW) for word in topics: anims = [Write(word, run_time = 1)] @@ -281,7 +281,7 @@ class CryptocurrencyEquation(Scene): "+ Cryptography", "= Cryptocurrency" ) - VGroup(*parts[-1][1:]).highlight(YELLOW) + VGroup(*parts[-1][1:]).set_color(YELLOW) parts.scale_to_fit_width(FRAME_WIDTH - LARGE_BUFF) for part in parts: @@ -421,7 +421,7 @@ class NoCommentOnSpeculation(TeacherStudentsScene): FRAME_WIDTH*RIGHT ) black_words = TextMobject("Random words\\\\Blah blah") - black_words.highlight(BLACK) + black_words.set_color(BLACK) self.teacher_thinks(black_words) self.zoom_in_on_thought_bubble() @@ -477,7 +477,7 @@ class LedgerScene(PiCreatureScene): if self.enumerate_lines: num = TexMobject(str(len(items)) + ".") num.scale(0.8) - num.highlight(self.line_number_color) + num.set_color(self.line_number_color) num.next_to(mob, LEFT, MED_SMALL_BUFF) mob.add_to_back(num) mob.next_to( @@ -507,17 +507,17 @@ class LedgerScene(PiCreatureScene): line = TextMobject(*line_tex_parts) for name in from_name, to_name: color = self.get_color_from_name(name) - line.highlight_by_tex(name.capitalize(), color) + line.set_color_by_tex(name.capitalize(), color) if self.sign_transactions: from_part = line.get_part_by_tex(from_name.capitalize()) - line[-1].highlight(from_part.get_color()) + line[-1].set_color(from_part.get_color()) amount_color = { "USD" : GREEN, "BTC" : YELLOW, "LD" : YELLOW, }.get(self.denomination, WHITE) - line.highlight_by_tex(amount_str, amount_color) + line.set_color_by_tex(amount_str, amount_color) return self.add_line_to_ledger(line) @@ -587,7 +587,7 @@ class LedgerScene(PiCreatureScene): def get_signature(self, color = BLUE_C): result = TexMobject(self.get_signature_tex()) - result.highlight(color) + result.set_color(color) return result def add_ellipsis(self): @@ -637,7 +637,7 @@ class LayOutPlan(LedgerScene): cash = TexMobject("\\$"*(amount/10)) cash.scale(0.5) cash.move_to(from_pi) - cash.highlight(GREEN) + cash.set_color(GREEN) self.play( cash.move_to, to_pi, @@ -675,10 +675,10 @@ class UnderlyingSystemVsUserFacing(Scene): protocol = TextMobject("Bitcoin protocol") protocol.next_to(underlying, RIGHT, MED_LARGE_BUFF) - protocol.highlight(BITCOIN_COLOR) + protocol.set_color(BITCOIN_COLOR) banking = TextMobject("Banking system") banking.next_to(protocol, RIGHT, MED_LARGE_BUFF) - banking.highlight(GREEN) + banking.set_color(GREEN) phone = SVGMobject( file_name = "phone", @@ -701,7 +701,7 @@ class UnderlyingSystemVsUserFacing(Scene): btc.next_to(phone, UP, MED_LARGE_BUFF) dollar = TexMobject("\\$") dollar.scale_to_fit_height(1) - dollar.highlight(GREEN) + dollar.set_color(GREEN) dollar.next_to(card, UP, MED_LARGE_BUFF) card.save_state() card.shift(2*RIGHT) @@ -757,7 +757,7 @@ class IntroduceLedgerSystem(LedgerScene): for from_name, to_name, num in self.payments: from_pi = getattr(self, from_name.lower()) to_pi = getattr(self, to_name.lower()) - cash = TexMobject("\\$"*(num/10)).highlight(GREEN) + cash = TexMobject("\\$"*(num/10)).set_color(GREEN) cash.scale_to_fit_height(0.5) cash.move_to(from_pi) self.play( @@ -798,7 +798,7 @@ class IntroduceLedgerSystem(LedgerScene): creature = getattr(self, name) creature.cash = TexMobject("\\$"*abs(amount/10)) creature.cash.next_to(creature, UP+LEFT, SMALL_BUFF) - creature.cash.highlight(GREEN) + creature.cash.set_color(GREEN) if amount < 0: verb = "Owes" debtors.add(creature) @@ -810,8 +810,8 @@ class IntroduceLedgerSystem(LedgerScene): result = TextMobject( verb, "\\$%d"%abs(amount) ) - result.highlight_by_tex("Owe", RED) - result.highlight_by_tex("Get", GREEN) + result.set_color_by_tex("Owe", RED) + result.set_color_by_tex("Get", GREEN) result.add_background_rectangle() result.scale(0.7) result.next_to(creature.label, DOWN) @@ -897,7 +897,7 @@ class AddFraudulentLine(LedgerScene): def anyone_can_add_a_line(self): words = TextMobject("Anyone can add a line") words.to_corner(UP+RIGHT) - words.highlight(YELLOW) + words.set_color(YELLOW) arrow = Arrow( words.get_left(), self.ledger.content.get_center() + DOWN, @@ -980,7 +980,7 @@ class IntroduceSignatures(LedgerScene): ]) for signature, transaction in zip(signatures, self.ledger.content[1:]): signature.next_to(transaction, RIGHT) - signature.highlight(transaction[0].get_color()) + signature.set_color(transaction[0].get_color()) self.play(Write(signature, run_time = 2)) transaction.add(signature) self.wait(2) @@ -996,7 +996,7 @@ class AskHowDigitalSignaturesArePossible(TeacherStudentsScene): def construct(self): signature = get_cursive_name("Alice") signature.scale(1.5) - signature.highlight(BLUE_C) + signature.set_color(BLUE_C) signature.to_corner(UP+LEFT) signature_copy = signature.copy() signature_copy.shift(3*RIGHT) @@ -1055,11 +1055,11 @@ class DescribeDigitalSignatures(LedgerScene): title = TextMobject("Private", "key /", "Public", "key") title.to_edge(UP) private, public = map(title.get_part_by_tex, ["Private", "Public"]) - private.highlight(self.private_color) - public.highlight(self.public_color) + private.set_color(self.private_color) + public.set_color(self.public_color) secret = TextMobject("Secret") secret.move_to(private, RIGHT) - secret.highlight(self.private_color) + secret.set_color(self.private_color) names = self.get_names()[:-1] public_key_strings = [ @@ -1087,8 +1087,8 @@ class DescribeDigitalSignatures(LedgerScene): for key_pair, pi in zip(key_pairs, self.pi_creatures): key_pair.next_to(pi, UP, MED_LARGE_BUFF) for key in key_pair: - key.highlight_by_tex("sk", self.private_color) - key.highlight_by_tex("pk", self.public_color) + key.set_color_by_tex("sk", self.private_color) + key.set_color_by_tex("pk", self.public_color) self.play(Write(title, run_time = 2)) self.play(ReplacementTransform( @@ -1114,7 +1114,7 @@ class DescribeDigitalSignatures(LedgerScene): def keep_secret_key_secret(self): keys = self.private_keys rects = VGroup(*map(SurroundingRectangle, keys)) - rects.highlight(self.private_color) + rects.set_color(self.private_color) lock = SVGMobject( file_name = "lock", height = rects.get_height(), @@ -1164,7 +1164,7 @@ class DescribeDigitalSignatures(LedgerScene): signatures = VGroup() for document in documents: signature = get_cursive_name("Alice") - signature.highlight(self.signature_color) + signature.set_color(self.signature_color) line = document[1][-1] signature.next_to(line, UP, SMALL_BUFF) signatures.add(signature) @@ -1190,7 +1190,7 @@ class DescribeDigitalSignatures(LedgerScene): bits = bin(hash(str(i)))[-8:] digital_signature = TexMobject(bits + "\\dots") digital_signature.scale(0.7) - digital_signature.highlight(signature.get_color()) + digital_signature.set_color(signature.get_color()) digital_signature.move_to(signature, DOWN) digital_signatures.add(digital_signature) @@ -1234,9 +1234,9 @@ class DescribeDigitalSignatures(LedgerScene): arg_separator = "" ) for mob in sign, verify: - mob.highlight_by_tex("sk", self.private_color) - mob.highlight_by_tex("pk", self.public_color) - mob.highlight_by_tex( + mob.set_color_by_tex("sk", self.private_color) + mob.set_color_by_tex("pk", self.public_color) + mob.set_color_by_tex( "Signature", self.signature_color, ) for name in "Message", "sk", "Signature", "pk": @@ -1308,8 +1308,8 @@ class TryGuessingDigitalSignature(Scene): verify.scale(1.5) verify.shift(DOWN) signature = verify.get_part_by_tex("Signature") - verify.highlight_by_tex("Signature", BLUE) - verify.highlight_by_tex("pk", GREEN) + verify.set_color_by_tex("Signature", BLUE) + verify.set_color_by_tex("pk", GREEN) brace = Brace(signature, UP) zeros_row = TexMobject("0"*32) @@ -1345,7 +1345,7 @@ class WriteTwoTo256PossibleSignatures(Scene): "$2^{256}$", "possible\\\\", "signatures" ) words.scale(2) - words.highlight_by_tex("256", BLUE) + words.set_color_by_tex("256", BLUE) self.play(Write(words)) self.wait() @@ -1372,26 +1372,26 @@ class FeelConfidentWithVerification(PiCreatureScene): arg_separator = "" ) signature_word = verify.get_part_by_tex("Signature") - verify.highlight_by_tex("Signature", BLUE) - verify.highlight_by_tex("pk", GREEN) + verify.set_color_by_tex("Signature", BLUE) + verify.set_color_by_tex("pk", GREEN) brace = Brace(signature_word, UP) signature = sha256_tex_mob("Signature") signature.next_to(brace, UP) - signature.highlight(BLUE_C) + signature.set_color(BLUE_C) rhs = TextMobject("=", "True") - rhs.highlight_by_tex("True", YELLOW) + rhs.set_color_by_tex("True", YELLOW) rhs.next_to(verify, RIGHT) pk = verify.get_part_by_tex("pk") sk = TextMobject("sk") - sk.highlight(RED) + sk.set_color(RED) arrow = TexMobject("\\Updownarrow") arrow.next_to(pk, DOWN) sk.next_to(arrow, DOWN) sk_group = VGroup(arrow, sk) lock_box = SurroundingRectangle(sk_group, buff = SMALL_BUFF) - lock_box.highlight(RED) + lock_box.set_color(RED) lock = SVGMobject( file_name = "lock", fill_color = LIGHT_GREY, @@ -1507,14 +1507,14 @@ class IncludeTransactionNumber(LedgerScene): for i, line in enumerate(lines): number = TexMobject(str(i)) number.scale(0.7) - number.highlight(YELLOW) + number.set_color(YELLOW) number.next_to(line, LEFT) numbers.add(number) line.add_to_back(number) old_signature = line[-1] new_signature = self.get_signature() new_signature.replace(old_signature) - new_signature.highlight(colors[i]) + new_signature.set_color(colors[i]) old_signatures.add(old_signature) new_signatures.add(VGroup(new_signature)) line.remove(old_signature) @@ -1539,12 +1539,12 @@ class ProtocolWithDigitalSignatures(InitialProtocol): self.revert_to_original_skipping_status() rect = SurroundingRectangle(self.items[-1]) - rect.highlight(RED) + rect.set_color(RED) new_item = self.get_new_item( "Only signed transactions are valid" ) - new_item.highlight(YELLOW) + new_item.set_color(YELLOW) self.play(Write(new_item)) self.wait() @@ -1629,7 +1629,7 @@ class DontAllowOverdrawing(InitialProtocol): "Only signed transactions are valid \\,", "No overspending" ]) - lines[2].highlight(YELLOW) + lines[2].set_color(YELLOW) self.add(*lines[:2]) self.wait() @@ -1651,7 +1651,7 @@ class LedgerWithInitialBuyIn(SignedLedgerScene): TexMobject("\\$100") for pi in self.pi_creatures ]) - moneys.highlight(GREEN) + moneys.set_color(GREEN) for pi, money in zip(reversed(self.pi_creatures), moneys): vect = pi.get_center() - center money.next_to(center, vect, SMALL_BUFF) @@ -1679,11 +1679,11 @@ class LedgerWithInitialBuyIn(SignedLedgerScene): "get" if name == "you" else "gets", "\\$100" ) - new_line.highlight_by_tex( + new_line.set_color_by_tex( name.capitalize(), self.get_color_from_name(name) ) - new_line.highlight_by_tex("100", GREEN) + new_line.set_color_by_tex("100", GREEN) self.add_line_to_ledger(new_line) lines.add(new_line) line = Line(LEFT, RIGHT) @@ -1726,13 +1726,13 @@ class LedgerWithInitialBuyIn(SignedLedgerScene): SurroundingRectangle(line) for line in charlie_lines ]) - rects.highlight(YELLOW) + rects.set_color(YELLOW) rects.set_stroke(width = 2) last_rect = rects[-1] last_rect.set_stroke(RED, 4) rects.remove(last_rect) invalid = TextMobject("Invalid") - invalid.highlight(RED) + invalid.set_color(RED) invalid.next_to(last_rect, DOWN) self.play(ShowCreation(rects)) @@ -1769,8 +1769,8 @@ class LedgerWithInitialBuyIn(SignedLedgerScene): lines = VGroup(*map(TextMobject, [ "\\$100", "\\$50", "\\$0", "Overdrawn" ])) - lines.highlight(GREEN) - lines[-1].highlight(RED) + lines.set_color(GREEN) + lines[-1].set_color(RED) arrows = VGroup() for line, c_line in zip(lines, charlie_lines): line.next_to(rect.get_left(), RIGHT, LARGE_BUFF) @@ -1804,7 +1804,7 @@ class RemovedConnectionBetweenLedgerAndCash(TeacherStudentsScene): arrow = TexMobject("\\leftrightarrow") cash = TexMobject("\\$\\$\\$") - cash.highlight(GREEN) + cash.set_color(GREEN) arrow.next_to(ledger, RIGHT) cash.next_to(arrow, RIGHT) group = VGroup(ledger, arrow, cash) @@ -1900,13 +1900,13 @@ class RenameToLedgerDollars(LedgerScene): amount.add(dollar_sign) tex_string = amount.get_tex_string() ld = TextMobject(tex_string[2:] + " LD") - ld.highlight(YELLOW) + ld.set_color(YELLOW) ld.scale(0.8) ld.move_to(amount, LEFT) amounts.target.add(ld) ledger_dollars = TextMobject("Ledger Dollars \\\\ ``LD'' ") - ledger_dollars.highlight(YELLOW) + ledger_dollars.set_color(YELLOW) ledger_dollars.next_to(self.ledger, RIGHT) self.play( @@ -1946,8 +1946,8 @@ class ExchangeCashForLedgerDollars(LedgerScene): title = TextMobject( "Exchange", "LD", "for", "\\$\\$\\$" ) - title.highlight_by_tex("LD", YELLOW) - title.highlight_by_tex("\\$", GREEN) + title.set_color_by_tex("LD", YELLOW) + title.set_color_by_tex("\\$", GREEN) title.scale(1.3) title.to_edge(UP).shift(LEFT) @@ -2018,7 +2018,7 @@ class BitcoinIsALedger(Scene): equation = TextMobject( "Currency", "=", "Transaction history" ) - equation.highlight_by_tex("Currency", BITCOIN_COLOR) + equation.set_color_by_tex("Currency", BITCOIN_COLOR) equation.shift( self.btc_to_ledger[1].get_center() - \ equation[1].get_center() + 2*UP @@ -2045,7 +2045,7 @@ class BitcoinIsALedger(Scene): class BigDifferenceBetweenLDAndCryptocurrencies(Scene): def construct(self): - ld = TextMobject("LD").scale(1.5).highlight(YELLOW) + ld = TextMobject("LD").scale(1.5).set_color(YELLOW) btc = BitcoinLogo() eth = EthereumLogo() ltc = LitecoinLogo() @@ -2099,7 +2099,7 @@ class DistributedLedgerScene(LedgerScene): for pi in self.pi_creatures: pi.ledger = ledger.copy() pi.ledger.scale_to_fit_height(pi.get_height()) - pi.ledger[0].highlight(pi.get_color()) + pi.ledger[0].set_color(pi.get_color()) vect = pi.get_center()-self.pi_creatures.get_center() x_vect = vect[0]*RIGHT pi.ledger.next_to(pi, x_vect, SMALL_BUFF) @@ -2134,7 +2134,7 @@ class TransitionToDistributedLedger(DistributedLedgerScene): def ask_where_is_ledger(self): question = TextMobject("Where", "is", "this?!") - question.highlight(RED) + question.set_color(RED) question.scale(1.5) question.next_to(self.ledger, UP) @@ -2162,7 +2162,7 @@ class TransitionToDistributedLedger(DistributedLedgerScene): new_question = TextMobject("Who", "controls", "this?!") new_question.scale(1.3) new_question.move_to(self.question) - new_question.highlight(RED) + new_question.set_color(RED) self.play(Transform(self.question, new_question)) self.play(*[ @@ -2196,9 +2196,9 @@ class TransitionToDistributedLedger(DistributedLedgerScene): payment = TextMobject( "Alice", "pays", "Bob", "100 LD" ) - payment.highlight_by_tex("Alice", self.alice.get_color()) - payment.highlight_by_tex("Bob", self.bob.get_color()) - payment.highlight_by_tex("LD", YELLOW) + payment.set_color_by_tex("Alice", self.alice.get_color()) + payment.set_color_by_tex("Bob", self.bob.get_color()) + payment.set_color_by_tex("LD", YELLOW) payment.scale(0.75) payment.add_background_rectangle() payment_copies = VGroup(*[ @@ -2293,9 +2293,9 @@ class BobDoubtsBroadcastTransaction(DistributedLedgerScene): payment = TextMobject( "Alice", "pays", "Bob", "10 LD" ) - payment.highlight_by_tex("Alice", self.alice.get_color()) - payment.highlight_by_tex("Bob", self.bob.get_color()) - payment.highlight_by_tex("LD", YELLOW) + payment.set_color_by_tex("Alice", self.alice.get_color()) + payment.set_color_by_tex("Bob", self.bob.get_color()) + payment.set_color_by_tex("LD", YELLOW) payment.next_to(corner, UP+LEFT) self.play( @@ -2376,9 +2376,9 @@ class AskWhatToAddToProtocol(InitialProtocol): ] + [""]*6)) brace = Brace(VGroup(*items[3:]), LEFT) question = TextMobject("What to \\\\ add here?") - question.highlight(RED) + question.set_color(RED) question.scale(1.5) - brace.highlight(RED) + brace.set_color(RED) question.next_to(brace, LEFT) self.add(*items[:3]) @@ -2418,7 +2418,7 @@ class TrustComputationalWork(DistributedLedgerScene): new_bit = TexMobject(bit_str) new_bit.replace(curr_bit, dim_to_match = 1) if bit_str == "1": - new_bit.highlight(YELLOW) + new_bit.set_color(YELLOW) zeros.submobjects[-i-1] = new_bit self.remove(curr_bit) self.add(zeros) @@ -2429,7 +2429,7 @@ class TrustComputationalWorkSupplement(Scene): words = TextMobject( "Main tool: ", "Cryptographic hash functions" ) - words[1].highlight(YELLOW) + words[1].set_color(YELLOW) self.add(words[0]) self.play(Write(words[1])) self.wait() @@ -2440,7 +2440,7 @@ class FraudIsInfeasible(Scene): "Fraud", "$\\Leftrightarrow$", "Computationally infeasible" ) - words.highlight_by_tex("Fraud", RED) + words.set_color_by_tex("Fraud", RED) words.to_edge(UP) self.play(FadeIn(words[0])) self.play(FadeIn(words[2])) @@ -2482,7 +2482,7 @@ class ThisIsWellIntoTheWeeds(TeacherStudentsScene): ) self.play(LaggedStart( ApplyMethod, lightbulb, - lambda b : (b.highlight, YELLOW_A), + lambda b : (b.set_color, YELLOW_A), rate_func = there_and_back )) self.wait(2) @@ -2511,7 +2511,7 @@ class IntroduceSHA256(Scene): "SHA256", "(``", message, "'') =", arg_separator = "" ) - lhs.highlight_by_tex(message, BLUE) + lhs.set_color_by_tex(message, BLUE) digest = sha256_tex_mob(message) digest.next_to(lhs, RIGHT) group = VGroup(lhs, digest) @@ -2526,9 +2526,9 @@ class IntroduceSHA256(Scene): message_brace = Brace(message, DOWN) digest_brace = Brace(digest, DOWN) sha_text = sha_brace.get_text("", "Hash function") - sha_text.highlight(YELLOW) + sha_text.set_color(YELLOW) message_text = message_brace.get_text("Message/file") - message_text.highlight(BLUE) + message_text.set_color(BLUE) digest_text = digest_brace.get_text("``Hash'' or ``Digest''") brace_text_pairs = [ (sha_brace, sha_text), @@ -2537,7 +2537,7 @@ class IntroduceSHA256(Scene): ] looks_random = TextMobject("Looks random") - looks_random.highlight(MAROON_B) + looks_random.set_color(MAROON_B) looks_random.next_to(digest_text, DOWN) self.add(group) @@ -2560,7 +2560,7 @@ class IntroduceSHA256(Scene): for mob in digest, message: self.play(LaggedStart( ApplyMethod, mob, - lambda m : (m.highlight, YELLOW), + lambda m : (m.set_color, YELLOW), rate_func = there_and_back, run_time = 1 )) @@ -2571,7 +2571,7 @@ class IntroduceSHA256(Scene): char = new_lhs[2][-5] arrow = Arrow(UP, ORIGIN, buff = 0) arrow.next_to(char, UP) - arrow.highlight(RED) + arrow.set_color(RED) self.play(ShowCreation(arrow)) for new_group in groups[1:]: new_lhs, new_digest = new_group @@ -2600,8 +2600,8 @@ class IntroduceSHA256(Scene): ) new_sha_text.next_to(sha_brace, UP) new_sha_text.shift_onto_screen() - new_sha_text.highlight(YELLOW) - new_sha_text[0].highlight(GREEN) + new_sha_text.set_color(YELLOW) + new_sha_text[0].set_color(GREEN) self.play(Transform(sha_text, new_sha_text)) self.wait() @@ -2614,11 +2614,11 @@ class IntroduceSHA256(Scene): def inverse_function_question(self): arrow = Arrow(3*RIGHT, 3*LEFT, buff = 0) arrow.set_stroke(width = 8) - arrow.highlight(RED) + arrow.set_color(RED) everything = VGroup(*self.get_mobjects()) arrow.next_to(everything, DOWN) words = TextMobject("Inverse is infeasible") - words.highlight(RED) + words.set_color(RED) words.next_to(arrow, DOWN) self.play(ShowCreation(arrow)) @@ -2628,12 +2628,12 @@ class IntroduceSHA256(Scene): def issue_challenge(self): desired_output_text = TextMobject("Desired output") desired_output_text.move_to(self.digest_text) - desired_output_text.highlight(YELLOW) + desired_output_text.set_color(YELLOW) new_digest = sha256_tex_mob("Challenge") new_digest.replace(self.digest) q_marks = TextMobject("???") q_marks.move_to(self.message_text) - q_marks.highlight(BLUE) + q_marks.set_color(BLUE) self.play( Transform( @@ -2665,7 +2665,7 @@ class IntroduceSHA256(Scene): "SHA256(``", message, "'') = ", arg_separator = "" ) - lhs.highlight_by_tex("Guess", BLUE) + lhs.set_color_by_tex("Guess", BLUE) digest = sha256_tex_mob(message) digest.next_to(lhs, RIGHT) group = VGroup(lhs, digest) @@ -2745,7 +2745,7 @@ class IntroduceNonceOnTrasactions(LedgerScene): nonce = TexMobject(str(2**30 + hash("Hey there")%(2**15))) nonce.next_to(ledger, RIGHT, LARGE_BUFF) - nonce.highlight(GREEN_C) + nonce.set_color(GREEN_C) nonce_brace = Brace(nonce, DOWN) special_word = nonce_brace.get_text("Special number") arrow = Arrow(LEFT, RIGHT, buff = 0) @@ -2785,7 +2785,7 @@ class IntroduceNonceOnTrasactions(LedgerScene): ) self.play(LaggedStart( ApplyMethod, decomposed_ledger, - lambda m : (m.highlight, YELLOW), + lambda m : (m.set_color, YELLOW), rate_func = there_and_back )) point = VectorizedPoint(sha.get_center()) @@ -2809,7 +2809,7 @@ class IntroduceNonceOnTrasactions(LedgerScene): ) self.play(LaggedStart( ApplyMethod, zeros, - lambda m : (m.highlight, YELLOW) + lambda m : (m.set_color, YELLOW) )) self.wait(2) @@ -2832,7 +2832,7 @@ class IntroduceNonceOnTrasactions(LedgerScene): def guess_and_check(self): q_mark = TexMobject("?") - q_mark.highlight(RED) + q_mark.set_color(RED) q_mark.next_to(self.zeros_words, RIGHT, SMALL_BUFF) self.digest.save_state() @@ -2842,7 +2842,7 @@ class IntroduceNonceOnTrasactions(LedgerScene): for x in range(1, 13): nonce = TexMobject(str(x)) nonce.move_to(self.nonce) - nonce.highlight(GREEN_C) + nonce.set_color(GREEN_C) digest = sha256_tex_mob(str(x)) digest.replace(self.digest) @@ -2869,7 +2869,7 @@ class IntroduceNonceOnTrasactions(LedgerScene): words = TextMobject("``Proof of work''") words.next_to(self.nonce, DOWN, LARGE_BUFF) words.shift(MED_LARGE_BUFF*RIGHT) - words.highlight(GREEN) + words.set_color(GREEN) arrow = Arrow( words.get_top(), self.nonce.get_bottom(), color = WHITE, @@ -2883,7 +2883,7 @@ class IntroduceNonceOnTrasactions(LedgerScene): amount = self.ledger.content[2][-1] new_amount = TextMobject("300 LD") new_amount.scale_to_fit_height(amount.get_height()) - new_amount.highlight(amount.get_color()) + new_amount.set_color(amount.get_color()) new_amount.move_to(amount, LEFT) new_digest = sha256_tex_mob("Ah shucks") @@ -2924,7 +2924,7 @@ class ShowSomeBroadcasting(DistributedLedgerScene): dots = VGroup() for line in outgoing_lines: dot = Dot(line.get_start()) - dot.highlight(YELLOW) + dot.set_color(YELLOW) dot.generate_target() dot.target.move_to(line.get_end()) for alt_pi in self.pi_creatures: @@ -3041,14 +3041,14 @@ class IntroduceBlockChain(Scene): proofs_of_work.add(block.proof_of_work) num_str = str(random.randint(0, 10**12)) number = TexMobject(num_str) - number.highlight(self.proof_of_work_color) + number.set_color(self.proof_of_work_color) number.replace(block.proof_of_work, dim_to_match = 1) new_proofs_of_work.add(number) digest = sha256_tex_mob(num_str, 60) digest.scale(0.7) digest.move_to(block).to_edge(DOWN) - VGroup(*digest[:60]).highlight(YELLOW) + VGroup(*digest[:60]).set_color(YELLOW) arrow = Arrow(block, digest) sha = TextMobject("SHA256") sha.scale(0.7) @@ -3134,7 +3134,7 @@ class IntroduceBlockChain(Scene): amount = blocks[0].payments[1][3] new_amount = TextMobject("400 LD") new_amount.scale_to_fit_height(amount.get_height()) - new_amount.highlight(RED) + new_amount.set_color(RED) new_amount.move_to(amount, LEFT) self.play(FocusOn(amount)) @@ -3156,7 +3156,7 @@ class IntroduceBlockChain(Scene): self.play(ShowCreation(rect)) self.play( MoveToTarget(rect), - prev_hash.highlight, RED + prev_hash.set_color, RED ) def redo_proof_of_work(self): @@ -3171,16 +3171,16 @@ class IntroduceBlockChain(Scene): Integer(random.randint(10**9, 10**10)) for x in range(50) ]) - num_pow_group.highlight(proof_of_work.get_color()) + num_pow_group.set_color(proof_of_work.get_color()) num_pow_group.scale_to_fit_width(proof_of_work.get_width()) num_pow_group.move_to(proof_of_work) for num_pow in num_pow_group: self.add(num_pow) self.wait(1./20) - prev_hash.highlight(random_bright_color()) + prev_hash.set_color(random_bright_color()) self.remove(num_pow) self.add(num_pow) - prev_hash.highlight(BLUE) + prev_hash.set_color(BLUE) def write_block_chain(self): ledger = TextMobject("Ledger") @@ -3227,11 +3227,11 @@ class IntroduceBlockChain(Scene): self.names[hashes[1]%4], "%d0 LD"%(hashes[2]%9 + 1), ) - payment.highlight_by_tex("LD", YELLOW) + payment.set_color_by_tex("LD", YELLOW) for name, color in zip(self.names, self.name_colors): - payment.highlight_by_tex(name, color) + payment.set_color_by_tex(name, color) signature = TextMobject("$\\langle$ Signature $\\rangle$") - signature.highlight(payment[0].get_color()) + signature.set_color(payment[0].get_color()) signature.next_to(payment, DOWN, SMALL_BUFF) payment.add(signature) @@ -3244,7 +3244,7 @@ class IntroduceBlockChain(Scene): payments.next_to(h_line1, DOWN) proof_of_work = TextMobject("Proof of work") - proof_of_work.highlight(self.proof_of_work_color) + proof_of_work.set_color(self.proof_of_work_color) proof_of_work.scale(0.8) proof_of_work.move_to( VGroup(h_line2, VectorizedPoint(rect.get_bottom())) @@ -3252,7 +3252,7 @@ class IntroduceBlockChain(Scene): prev_hash = TextMobject("Prev hash") prev_hash.scale(0.8) - prev_hash.highlight(self.prev_hash_color) + prev_hash.set_color(self.prev_hash_color) prev_hash.move_to( VGroup(h_line1, VectorizedPoint(rect.get_top())) ) @@ -3401,8 +3401,8 @@ class FromBankToDecentralizedSystem(DistributedBlockChainScene): "Digital signatures \\\\", "Cryptographic hash functions", ) - terms.highlight_by_tex("signature", BLUE) - terms.highlight_by_tex("hash", YELLOW) + terms.set_color_by_tex("signature", BLUE) + terms.set_color_by_tex("hash", YELLOW) for term in terms: self.play(Write(term, run_time = 1)) self.wait() @@ -3495,9 +3495,9 @@ class IntroduceBlockCreator(DistributedBlockChainScene): payment = TextMobject( from_name, verb, to_name, "%d LD"%amount ) - payment.highlight_by_tex("LD", YELLOW) + payment.set_color_by_tex("LD", YELLOW) for name in self.get_names(): - payment.highlight_by_tex( + payment.set_color_by_tex( name.capitalize(), self.get_color_from_name(name) ) @@ -3545,7 +3545,7 @@ class IntroduceBlockCreator(DistributedBlockChainScene): payments.target.move_to(block) prev_hash = TextMobject("Prev hash") - prev_hash.highlight(BLUE) + prev_hash.set_color(BLUE) prev_hash.scale_to_fit_height(0.3) prev_hash.next_to(block.get_top(), DOWN, MED_SMALL_BUFF) block.add(prev_hash) @@ -3573,13 +3573,13 @@ class IntroduceBlockCreator(DistributedBlockChainScene): self.add(arrow) for x in range(self.n_pow_guesses): guess = Integer(random.randint(10**11, 10**12)) - guess.highlight(GREEN) + guess.set_color(GREEN) guess.scale_to_fit_height(0.3) guess.next_to(block.get_bottom(), UP, MED_SMALL_BUFF) if x == self.n_pow_guesses - 1: digest = sha256_tex_mob(str(x), 60) - VGroup(*digest[:60]).highlight(YELLOW) + VGroup(*digest[:60]).set_color(YELLOW) else: digest = sha256_tex_mob(str(x)) digest.scale_to_fit_width(block.get_width()) @@ -3601,8 +3601,8 @@ class IntroduceBlockCreator(DistributedBlockChainScene): self.block_creator_labels[0].get_tex_string(), "gets", "10 LD" ) - new_transaction[0].highlight(LIGHT_GREY) - new_transaction.highlight_by_tex("LD", YELLOW) + new_transaction[0].set_color(LIGHT_GREY) + new_transaction.set_color_by_tex("LD", YELLOW) new_transaction.scale_to_fit_height(payments[0].get_height()) new_transaction.move_to(payments.get_top()) payments.generate_target() @@ -3647,13 +3647,13 @@ class IntroduceBlockCreator(DistributedBlockChainScene): for label in self.block_creator_labels: tex = label.get_tex_string() new_label = TextMobject("Miner " + tex[-1]) - new_label.highlight(label.get_color()) + new_label.set_color(label.get_color()) new_label.replace(label, dim_to_match = 1) self.play(Transform(label, new_label)) top_payment = self.payments[0] new_top_payment = TextMobject("Miner 1", "gets", "10 LD") - new_top_payment[0].highlight(LIGHT_GREY) - new_top_payment[-1].highlight(YELLOW) + new_top_payment[0].set_color(LIGHT_GREY) + new_top_payment[-1].set_color(YELLOW) new_top_payment.scale_to_fit_height(top_payment.get_height()) new_top_payment.move_to(top_payment, LEFT) self.play(Transform(top_payment, new_top_payment)) @@ -3747,7 +3747,7 @@ class MiningIsALottery(IntroduceBlockCreator): block.add(payments) prev_hash = TextMobject("Prev hash") - prev_hash.highlight(BLUE) + prev_hash.set_color(BLUE) prev_hash.scale_to_fit_height(0.2) prev_hash.next_to(block.get_top(), DOWN, SMALL_BUFF) block.add(prev_hash) @@ -3797,9 +3797,9 @@ class MiningIsALottery(IntroduceBlockCreator): self.miners )) - nonces[winner_index].highlight(GREEN) + nonces[winner_index].set_color(GREEN) new_digest = sha256_tex_mob("Winner", 60) - VGroup(*new_digest[:60]).highlight(YELLOW) + VGroup(*new_digest[:60]).set_color(YELLOW) old_digest = digests[winner_index] new_digest.replace(old_digest) Transform(old_digest, new_digest).update(1) @@ -3832,8 +3832,8 @@ class MiningIsALottery(IntroduceBlockCreator): miner_name = miner.label.get_tex_string() top_line = TextMobject(miner_name, "gets", "10 LD") - top_line.highlight_by_tex(miner_name, LIGHT_GREY) - top_line.highlight_by_tex("LD", YELLOW) + top_line.set_color_by_tex(miner_name, LIGHT_GREY) + top_line.set_color_by_tex("LD", YELLOW) lines.add(top_line) payments = [ ("Alice", "Bob", 20), @@ -3906,7 +3906,7 @@ class TwoBlockChains(DistributedBlockChainScene): conflicting = TextMobject("Conflicting") conflicting.to_edge(UP) - conflicting.highlight(RED) + conflicting.set_color(RED) arrows = VGroup(*[ Arrow( conflicting.get_bottom(), block_chain.get_top(), @@ -3919,7 +3919,7 @@ class TwoBlockChains(DistributedBlockChainScene): longer_chain_rect = SurroundingRectangle(block_chains[0]) longer_chain_rect.set_stroke(GREEN, 8) checkmark = TexMobject("\\checkmark") - checkmark.highlight(GREEN) + checkmark.set_color(GREEN) checkmark.next_to(longer_chain_rect, UP) checkmark.shift(RIGHT) @@ -3996,7 +3996,7 @@ class TwoBlockChains(DistributedBlockChainScene): rect.set_stroke(GREEN, 8) checkmark = TexMobject("\\checkmark") checkmark.next_to(rect, UP) - checkmark.highlight(GREEN) + checkmark.set_color(GREEN) self.play( ShowCreation(rect), @@ -4022,7 +4022,7 @@ class ReplaceCentralAuthorityWithWork(Scene): work = TextMobject("computational work") work.scale(1.5) work.move_to(central, LEFT) - work.highlight(YELLOW) + work.set_color(YELLOW) self.play(Write(words)) self.play(ShowCreation(cross)) @@ -4103,7 +4103,7 @@ class DoubleSpendingAttack(DistributedBlockChainScene): bubble = ThoughtBubble() words = TextMobject("Alice", "never \\\\ paid", "Bob") for name in "Alice", "Bob": - words.highlight_by_tex(name, self.get_color_from_name(name)) + words.set_color_by_tex(name, self.get_color_from_name(name)) bubble.add_content(words) bubble.resize_to_content() bubble.add(*bubble.content) @@ -4130,7 +4130,7 @@ class DoubleSpendingAttack(DistributedBlockChainScene): ] for word, vect, color in tuples: mob = TextMobject(word) - mob.highlight(color) + mob.set_color(color) mob.scale_to_fit_height(0.07*block.get_height()) mob.next_to( block.get_edge_center(vect), -vect, @@ -4142,8 +4142,8 @@ class DoubleSpendingAttack(DistributedBlockChainScene): payment = TextMobject("Alice", "pays", "Bob", "100 LD") for name in "Alice", "Bob": - payment.highlight_by_tex(name, self.get_color_from_name(name)) - payment.highlight_by_tex("LD", YELLOW) + payment.set_color_by_tex(name, self.get_color_from_name(name)) + payment.set_color_by_tex("LD", YELLOW) payments = VGroup( TexMobject("\\vdots"), payment, @@ -4223,7 +4223,7 @@ class AliceRacesOtherMiners(DoubleSpendingAttack): block.add(transactions) proof_of_work = self.get_rand_int_mob() - prev_hash = TextMobject("Prev hash").highlight(BLUE) + prev_hash = TextMobject("Prev hash").set_color(BLUE) for mob, vect in (proof_of_work, DOWN), (prev_hash, UP): mob.scale_to_fit_height(0.1*block.get_height()) mob.next_to( @@ -4246,7 +4246,7 @@ class AliceRacesOtherMiners(DoubleSpendingAttack): self.proofs_of_work.add(self.fraud_block.proof_of_work) self.wait(3) self.proofs_of_work.remove(self.fraud_block.proof_of_work) - fraud_block.proof_of_work.highlight(GREEN) + fraud_block.proof_of_work.set_color(GREEN) self.play( Indicate(fraud_block.proof_of_work), self.alice.change, "hooray" @@ -4274,13 +4274,13 @@ class AliceRacesOtherMiners(DoubleSpendingAttack): winner = self.miners[-1] proof_of_work = winner.block.proof_of_work self.proofs_of_work.remove(proof_of_work) - proof_of_work.highlight(GREEN) + proof_of_work.set_color(GREEN) self.play( Indicate(proof_of_work), winner.change, "hooray" ) block = winner.block.copy() - proof_of_work.highlight(WHITE) + proof_of_work.set_color(WHITE) self.remove(winner.block) ff_head = self.fraud_fork_head @@ -4345,7 +4345,7 @@ class AliceRacesOtherMiners(DoubleSpendingAttack): block = random.choice(self.miners).block prev_block = last_valid_block block_copy = block.deepcopy() - block_copy.proof_of_work.highlight(GREEN) + block_copy.proof_of_work.set_color(GREEN) block_copy.generate_target() block_copy.target.replace(chain.blocks[1], stretch = True) arrow = chain.arrows[0].copy() @@ -4429,7 +4429,7 @@ class WhenToTrustANewBlock(DistributedBlockChainScene): arrow = Arrow(UP, DOWN, color = RED) arrow.next_to(chain.blocks[-1], UP) for word, color in zip(words, colors): - word.highlight(color) + word.set_color(color) word.next_to(arrow, UP) word = words[0] self.play( @@ -4444,7 +4444,7 @@ class WhenToTrustANewBlock(DistributedBlockChainScene): self.add_new_block( Transform(word, new_word, **kwargs), ApplyMethod( - arrow.highlight, new_word.get_color(), + arrow.set_color, new_word.get_color(), **kwargs ) ) @@ -4458,7 +4458,7 @@ class WhenToTrustANewBlock(DistributedBlockChainScene): ] for word, vect, color in tuples: mob = TextMobject(word) - mob.highlight(color) + mob.set_color(color) mob.scale_to_fit_height(0.07*block.get_height()) mob.next_to( block.get_edge_center(vect), -vect, @@ -4521,7 +4521,7 @@ class MainIdeas(Scene): ]) colors = BLUE, WHITE, RED, GREEN, YELLOW for idea, color in zip(ideas, colors): - idea.highlight(color) + idea.set_color(color) ideas.arrange_submobjects( DOWN, buff = MED_LARGE_BUFF, @@ -4566,7 +4566,7 @@ class VariableProofOfWork(WhenToTrustANewBlock): sha_tex = TextMobject("SHA256") sha_tex.scale(0.7) sha_tex.next_to(arrow, UP, SMALL_BUFF) - sha_tex.highlight(YELLOW) + sha_tex.set_color(YELLOW) arrow.add(sha_tex) digest = sha256_tex_mob("Random") @@ -4587,8 +4587,8 @@ class VariableProofOfWork(WhenToTrustANewBlock): new_digest.replace(digest) Transform(digest, new_digest).update(1) self.wait(1./20) - proof_of_work.highlight(GREEN) - VGroup(*digest[:60]).highlight(YELLOW) + proof_of_work.set_color(GREEN) + VGroup(*digest[:60]).set_color(YELLOW) self.miner = miner self.block = block @@ -4603,7 +4603,7 @@ class VariableProofOfWork(WhenToTrustANewBlock): ) requirement.next_to(digest, UP, MED_LARGE_BUFF) self.n_zeros_mob = requirement.get_part_by_tex("60") - self.n_zeros_mob.highlight(YELLOW) + self.n_zeros_mob.set_color(YELLOW) self.play(Write(requirement, run_time = 2)) self.wait(2) @@ -4641,13 +4641,13 @@ class VariableProofOfWork(WhenToTrustANewBlock): new_digest = sha256_tex_mob(str(n_zeros), n_zeros) new_digest.move_to(digest) - VGroup(*new_digest[:n_zeros]).highlight(YELLOW) + VGroup(*new_digest[:n_zeros]).set_color(YELLOW) new_n_zeros_mob = TexMobject(str(n_zeros)) new_n_zeros_mob.move_to(n_zeros_mob) - new_n_zeros_mob.highlight(n_zeros_mob.get_color()) + new_n_zeros_mob.set_color(n_zeros_mob.get_color()) new_pow = self.get_rand_int_mob() new_pow.replace(proof_of_work, dim_to_match = 1) - new_pow.highlight(proof_of_work.get_color()) + new_pow.set_color(proof_of_work.get_color()) self.play( Transform(n_zeros_mob, new_n_zeros_mob), @@ -4693,7 +4693,7 @@ class CompareBlockTimes(Scene): for logo, example, color in zip(logos, examples, colors): logo.scale_to_fit_height(0.5) logo.next_to(example, LEFT) - example[0].highlight(color) + example[0].set_color(color) self.add(title, h_line) self.play( @@ -4747,7 +4747,7 @@ class BlockRewards(Scene): ) rewards.next_to(h_line, DOWN) for reward in rewards: - reward[1].highlight(YELLOW) + reward[1].set_color(YELLOW) footnote = TextMobject( "$^*$ Extrapolating from the 25 BTC reward period" @@ -4776,8 +4776,8 @@ class ShowGeometricSum(Scene): numbers = ["50", "25", "12.5", "6.25"] colors = color_gradient([BLUE_D, BLUE_B], 4) for tex, color in zip(numbers, colors): - equation.highlight_by_tex(tex, color) - equation[-1].highlight(YELLOW) + equation.set_color_by_tex(tex, color) + equation[-1].set_color(YELLOW) self.add(*equation[:2] + equation[-3:-1]) for i in range(2, 9, 2): @@ -4792,19 +4792,19 @@ class TransactionFeeExample(PiCreatureScene): payment = TextMobject( "Alice", "pays", "Bob", "0.42 BTC", ) - payment.highlight_by_tex("Alice", BLUE_C) - payment.highlight_by_tex("Bob", MAROON) - payment.highlight_by_tex("BTC", YELLOW) + payment.set_color_by_tex("Alice", BLUE_C) + payment.set_color_by_tex("Bob", MAROON) + payment.set_color_by_tex("BTC", YELLOW) payment.move_to(2.5*UP) fee = TextMobject("And leaves", "0.001 BTC", "to the miner") - fee.highlight_by_tex("BTC", YELLOW) + fee.set_color_by_tex("BTC", YELLOW) fee.next_to(payment, DOWN) signature = TextMobject( "$\\langle$Alice's digital signature$\\rangle$" ) - signature.highlight(BLUE_C) + signature.set_color(BLUE_C) signature.next_to(fee, DOWN) group = VGroup(payment, fee, signature) @@ -4883,7 +4883,7 @@ class ShowBitcoinBlockSize(LedgerScene): ] for word, vect, color in tuples: mob = TextMobject(word) - mob.highlight(color) + mob.set_color(color) rect = SurroundingRectangle( mob, color = WHITE, buff = MED_SMALL_BUFF ) @@ -4903,7 +4903,7 @@ class ShowBitcoinBlockSize(LedgerScene): "Limited to\\\\", "$\\sim 2{,}400$", "transactions" ) - limit.highlight_by_tex("2{,}400", RED) + limit.set_color_by_tex("2{,}400", RED) self.add(title, block) self.remove(payments) @@ -4923,7 +4923,7 @@ class ShowBitcoinBlockSize(LedgerScene): fill_color = BLUE_D, fill_opacity = 1, ) - visa_logo[-1].highlight("#faa61a") + visa_logo[-1].set_color("#faa61a") visa_logo.sort_submobjects() avg_rate = TextMobject("Avg: $1{,}700$/second") max_rate = TextMobject("Max: $>24{,}000$/second") @@ -4947,8 +4947,8 @@ class CurrentAverageFees(Scene): "$\\sim 0.0013$ BTC", "$\\approx$", "\\$3.39" ) - fees.highlight_by_tex("BTC", YELLOW) - fees.highlight_by_tex("\\$", GREEN) + fees.set_color_by_tex("BTC", YELLOW) + fees.set_color_by_tex("\\$", GREEN) fees.to_edge(UP) self.play(Write(fees)) @@ -4961,7 +4961,7 @@ class TopicsNotCovered(TeacherStudentsScene): def construct(self): title = TextMobject("Topics not covered:") title.to_corner(UP+LEFT) - title.highlight(YELLOW) + title.set_color(YELLOW) title.save_state() title.shift(DOWN) title.set_fill(opacity = 0) @@ -5047,7 +5047,7 @@ class ShowManyExchanges(Scene): buff = MED_LARGE_BUFF ) for p1, p2 in (LEFT, RIGHT), (RIGHT, LEFT) - ]).highlight(WHITE) + ]).set_color(WHITE) exchanges = VGroup(*[ VGroup(*[ exchange.copy() @@ -5101,9 +5101,9 @@ class ShowManyExchanges(Scene): def get_currencies(self): return [ - TexMobject("\\$").highlight(GREEN), - TexMobject("\\$").highlight(GREEN), - TexMobject("\\$").highlight(GREEN), + TexMobject("\\$").set_color(GREEN), + TexMobject("\\$").set_color(GREEN), + TexMobject("\\$").set_color(GREEN), SVGMobject( file_name = "euro_symbol", stroke_width = 0, @@ -5130,8 +5130,8 @@ class ShowLDAndOtherCurrencyExchanges(ShowManyExchanges): fill_color = BLUE, ) return [ - TextMobject("LD").highlight(YELLOW), - TextMobject("LD").highlight(YELLOW), + TextMobject("LD").set_color(YELLOW), + TextMobject("LD").set_color(YELLOW), euro, euro.copy(), SVGMobject( file_name = "yen_symbol", @@ -5143,7 +5143,7 @@ class ShowLDAndOtherCurrencyExchanges(ShowManyExchanges): ] def get_currencies(self): - return [TexMobject("\\$").highlight(GREEN)] + return [TexMobject("\\$").set_color(GREEN)] class CryptoPatreonThanks(PatreonThanks): CONFIG = { @@ -5252,7 +5252,7 @@ class Thumbnail(DistributedBlockChainScene): title = TextMobject("Crypto", "currencies", arg_separator = "") title.scale(2.5) title.to_edge(UP) - title[0].highlight(YELLOW) + title[0].set_color(YELLOW) title[0].set_stroke(RED, 2) self.add(title) @@ -5267,7 +5267,7 @@ class Thumbnail(DistributedBlockChainScene): # self.add(logos) block_chain = self.get_block_chain() - block_chain.arrows.highlight(RED) + block_chain.arrows.set_color(RED) block_chain.blocks.gradient_highlight(BLUE, GREEN) block_chain.scale_to_fit_width(FRAME_WIDTH-1) block_chain.set_stroke(width = 12) diff --git a/old_projects/domino_play.py b/old_projects/domino_play.py index 89f08394..935ba8c2 100644 --- a/old_projects/domino_play.py +++ b/old_projects/domino_play.py @@ -164,7 +164,7 @@ class SimpleVelocityGraph(GraphScene): self.add(dot) dots.add(dot) if note == "twist": - dot.highlight(RED) + dot.set_color(RED) self.dots = dots def add_label_to_last_dot(self, label, color = WHITE): @@ -172,7 +172,7 @@ class SimpleVelocityGraph(GraphScene): label = TextMobject(label) label.scale(0.75) label.next_to(dot, UP, buff = MED_SMALL_BUFF) - label.highlight(color) + label.set_color(color) label.shift_onto_screen() self.label = label self.add(label) @@ -601,7 +601,7 @@ class ContrastTwoGraphs(SimpleVelocityGraph): felt = TextMobject("Felt") hardwood = TextMobject("Hardwood") - hardwood.highlight(RED) + hardwood.set_color(RED) words = VGroup(felt, hardwood) self.force_skipping() @@ -681,7 +681,7 @@ class ContrastTwoGraphs(SimpleVelocityGraph): self.play(GrowArrow(arrow)) self.play( dot2.shift, MED_SMALL_BUFF*UP, - dot2.highlight, PINK, + dot2.set_color, PINK, rate_func = wiggle ) self.wait() @@ -758,8 +758,8 @@ class ContrastTwoGraphs(SimpleVelocityGraph): ### def color_graph(self, graph, color1 = BLUE, color2 = WHITE, n_starts = 20): - graph.highlight(color2) - VGroup(*graph.dots[:11] + graph.lines[:10]).highlight(color1) + graph.set_color(color2) + VGroup(*graph.dots[:11] + graph.lines[:10]).set_color(color1) def get_smoothed_velocity_graph(self, velocities): n = self.moving_average_n @@ -820,7 +820,7 @@ class ShowAllSteadyStateVelocities(SimpleVelocityGraph): color = color ) label.scale(0.5) - label.highlight(color) + label.set_color(color) dot = Dot(color = color) dot.scale(0.5) @@ -869,7 +869,7 @@ class Test(Scene): angle = -np.arcsin(2*spacing/domino1.get_height()) ) arc2.shift(domino1.get_right()) - arc2.highlight(BLUE) + arc2.set_color(BLUE) arcs = VGroup(arc1, arc2) for arc, vect in zip(arcs, [DOWN+RIGHT, RIGHT]): arc_copy = arc.copy() diff --git a/old_projects/efvgt.py b/old_projects/efvgt.py index d7c22e85..dd9a5ba3 100644 --- a/old_projects/efvgt.py +++ b/old_projects/efvgt.py @@ -284,8 +284,8 @@ class QuickExplanation(ComplexTransformationScene): "=", "i", "e^{it}" ) - equation[0].highlight(self.velocity_color) - equation[-1].highlight(self.position_color) + equation[0].set_color(self.velocity_color) + equation[-1].set_color(self.position_color) equation.add_background_rectangle() brace = Brace(equation, UP) equation.add(brace) @@ -294,8 +294,8 @@ class QuickExplanation(ComplexTransformationScene): "$90^\\circ$ \\\\ rotation", "of", "position vector" ) - brace_text[0].highlight(self.velocity_color) - brace_text[-1].highlight(self.position_color) + brace_text[0].set_color(self.velocity_color) + brace_text[-1].set_color(self.position_color) brace_text.add_background_rectangle() brace_text.scale(0.8) brace_text.to_corner(UP+LEFT, buff = MED_SMALL_BUFF) @@ -328,7 +328,7 @@ class QuickExplanation(ComplexTransformationScene): ) v_vector = s_vector.copy().rotate(np.pi/2) - v_vector.highlight(self.velocity_color) + v_vector.set_color(self.velocity_color) circle = Circle( radius = self.z_to_point(1)[0], color = self.position_color @@ -470,7 +470,7 @@ class SymmetriesOfSquare(ThreeDScene): self.play(ReplacementTransform(self.title, new_title)) self.title = new_title self.play(*[ - ApplyMethod(mob.highlight, GREY) + ApplyMethod(mob.set_color, GREY) for mob in self.title[1:] ]) @@ -693,9 +693,9 @@ class CircleSymmetries(Scene): def associate_rotations_with_points(self): zero_dot = Dot(self.circle.point_from_proportion(0)) - zero_dot.highlight(RED) + zero_dot.set_color(RED) zero_arrow = Arrow(UP+RIGHT, ORIGIN) - zero_arrow.highlight(zero_dot.get_color()) + zero_arrow.set_color(zero_dot.get_color()) zero_arrow.next_to(zero_dot, UP+RIGHT, buff = SMALL_BUFF) self.play( @@ -711,7 +711,7 @@ class CircleSymmetries(Scene): vect = np.sign(point) arrow = Arrow(vect, ORIGIN) arrow.next_to(dot, vect, buff = SMALL_BUFF) - arrow.highlight(dot.get_color()) + arrow.set_color(dot.get_color()) angle = alpha*2*np.pi self.play( @@ -747,7 +747,7 @@ class CircleSymmetries(Scene): self.circle.get_center(), self.circle.point_from_proportion(0) ) - static_radius = radius.copy().highlight(GREY) + static_radius = radius.copy().set_color(GREY) self.play(ShowCreation(radius)) self.add(static_radius, radius) @@ -906,13 +906,13 @@ class AddCircleSymmetries(CircleSymmetries): colors = [BLUE, YELLOW, GREEN] for color, arc, term in zip(colors, arcs, equation[::2]): - arc.highlight(color) - term.highlight(color) + arc.set_color(color) + term.set_color(color) self.play(FadeIn(circle)) self.add_radial_line() alt_radius = circle.radius.copy() - alt_radius.highlight(GREY) + alt_radius.set_color(GREY) alt_circle = circle.copy() equals = TexMobject("=") equals.move_to(circle) @@ -1009,7 +1009,7 @@ class AddCubeSymmetries(GroupOfCubeSymmetries): times = TexMobject("\\times") times.scale(1.5) times.move_to(plus) - times.highlight(RED) + times.set_color(RED) self.wait() self.play(ReplacementTransform(plus, times)) self.play(Indicate(times)) @@ -1183,7 +1183,7 @@ class ThisIsAVeryGeneralIdea(Scene): def construct(self): groups = TextMobject("Groups") groups.to_edge(UP) - groups.highlight(BLUE) + groups.set_color(BLUE) examples = VGroup(*map(TextMobject, [ "Square matrices \\\\ \\small (Where $\\det(M) \\ne 0$)", @@ -1200,7 +1200,7 @@ class ThisIsAVeryGeneralIdea(Scene): Line(groups.get_bottom(), ex.get_top(), buff = MED_SMALL_BUFF) for ex in examples ]) - lines.highlight(groups.get_color()) + lines.set_color(groups.get_color()) self.add(groups) @@ -1227,14 +1227,14 @@ class ThisIsAVeryGeneralIdea(Scene): sub_categories.arrange_submobjects(RIGHT, buff = MED_LARGE_BUFF) sub_categories.next_to(numbers, DOWN, 1.5*LARGE_BUFF) sub_categories.to_edge(RIGHT) - sub_categories[0].highlight(ADDER_COLOR) - sub_categories[1].highlight(MULTIPLIER_COLOR) + sub_categories[0].set_color(ADDER_COLOR) + sub_categories[1].set_color(MULTIPLIER_COLOR) sub_lines = VGroup(*[ Line(numbers.get_bottom(), sc.get_top(), buff = MED_SMALL_BUFF) for sc in sub_categories ]) - sub_lines.highlight(numbers.get_color()) + sub_lines.set_color(numbers.get_color()) self.play(*it.chain( map(ShowCreation, sub_lines), @@ -1286,7 +1286,7 @@ class AdditiveGroupOfReals(Scene): line.add_numbers() shadow_line.numbers.fade(0.25) shadow_line.save_state() - shadow_line.highlight(BLACK) + shadow_line.set_color(BLACK) shadow_line.move_to(number_line) @@ -1302,7 +1302,7 @@ class AdditiveGroupOfReals(Scene): zero_point = self.number_line.number_to_point(0) num_point = self.number_line.number_to_point(num) arrow = Arrow(zero_point, num_point, buff = 0) - arrow.highlight(ADDER_COLOR) + arrow.set_color(ADDER_COLOR) arrow.shift(MED_LARGE_BUFF*UP) self.play(ShowCreation(arrow)) @@ -1327,7 +1327,7 @@ class AdditiveGroupOfReals(Scene): arrow = Arrow(dot, color = self.zero_color) words = TextMobject("Follow zero") words.next_to(arrow.get_start(), UP) - words.highlight(self.zero_color) + words.set_color(self.zero_color) self.play( ShowCreation(arrow), @@ -1376,8 +1376,8 @@ class AdditiveGroupOfReals(Scene): def get_write_name_of_group_anim(self): new_title = TextMobject("Additive group of real numbers") - VGroup(*new_title[-len("realnumbers"):]).highlight(BLUE) - VGroup(*new_title[:len("Additive")]).highlight(ADDER_COLOR) + VGroup(*new_title[-len("realnumbers"):]).set_color(BLUE) + VGroup(*new_title[:len("Additive")]).set_color(ADDER_COLOR) new_title.to_edge(UP) return Transform(self.title, new_title) @@ -1440,18 +1440,18 @@ class AdditiveGroupOfReals(Scene): zero_point = self.number_line.number_to_point(0) num_point = self.number_line.number_to_point(num) arrow = Arrow(zero_point, num_point, buff = 0) - arrow.highlight(ADDER_COLOR) + arrow.set_color(ADDER_COLOR) arrow.shift(MED_SMALL_BUFF*UP) if num == 0: arrow = DashedLine(UP, ORIGIN) arrow.move_to(zero_point) elif num < 0: - arrow.highlight(RED) + arrow.set_color(RED) arrow.shift(SMALL_BUFF*UP) sign = "+" if num >= 0 else "" num_mob = TexMobject(sign + str(num)) num_mob.next_to(arrow, UP) - num_mob.highlight(arrow.get_color()) + num_mob.set_color(arrow.get_color()) return zero_point, num_point, arrow, num_mob class AdditiveGroupOfComplexNumbers(ComplexTransformationScene): @@ -1496,11 +1496,11 @@ class AdditiveGroupOfComplexNumbers(ComplexTransformationScene): Dot(self.z_to_point(complex(0, i))) for i in range(1, 4) ]) - dots.highlight(YELLOW) + dots.set_color(YELLOW) labels = VGroup(*self.imag_labels[-3:]) arrow = Arrow(ORIGIN, dots[-1].get_center(), buff = 0) - arrow.highlight(ADDER_COLOR) + arrow.set_color(ADDER_COLOR) self.plane.save_state() for dot, label in zip(dots, labels): @@ -1533,15 +1533,15 @@ class AdditiveGroupOfComplexNumbers(ComplexTransformationScene): point = self.z_to_point(z) dot = Dot(point, color = YELLOW) arrow = Vector(point, buff = dot.radius) - arrow.highlight(dot.get_color()) + arrow.set_color(dot.get_color()) label = TexMobject("%d + %di"%(z.real, z.imag)) label.next_to(point, UP) - label.highlight(dot.get_color()) + label.set_color(dot.get_color()) label.add_background_rectangle() real_arrow = Vector(self.z_to_point(z.real)) imag_arrow = Vector(self.z_to_point(z - z.real)) - VGroup(real_arrow, imag_arrow).highlight(ADDER_COLOR) + VGroup(real_arrow, imag_arrow).set_color(ADDER_COLOR) self.play( Write(label), @@ -1598,7 +1598,7 @@ class AdditiveGroupOfComplexNumbers(ComplexTransformationScene): "%d %di"%(z2.real, z2.imag) ) label2.next_to(point2, UP+RIGHT) - label2.highlight(dot2.get_color()) + label2.set_color(dot2.get_color()) label2.add_background_rectangle() self.play(ShowCreation(arrow2)) @@ -1694,8 +1694,8 @@ class AdditiveGroupOfComplexNumbers(ComplexTransformationScene): title = TextMobject( "Additive", "group of", "complex numbers" ) - title[0].highlight(ADDER_COLOR) - title[2].highlight(BLUE) + title[0].set_color(ADDER_COLOR) + title[2].set_color(BLUE) title.add_background_rectangle() title.to_edge(UP, buff = MED_SMALL_BUFF) @@ -1748,7 +1748,7 @@ class SchizophrenicNumbers(Scene): TexMobject("2-i").shift(DOWN+RIGHT), ) for number in numbers: - number.highlight(ADDER_COLOR) + number.set_color(ADDER_COLOR) number.scale(1.5) if isinstance(number, PiCreature): continue @@ -1765,7 +1765,7 @@ class SchizophrenicNumbers(Scene): number.generate_target() number.target.shift(FRAME_X_RADIUS*RIGHT) number.target.eyes.save_state() - number.target.highlight(MULTIPLIER_COLOR) + number.target.set_color(MULTIPLIER_COLOR) number.target.eyes.restore() self.play(*[ MoveToTarget( @@ -1841,9 +1841,9 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals): def show_zero_fixed_in_place(self): arrow = Arrow(self.zero_point + UP, self.zero_point, buff = 0) - arrow.highlight(ADDER_COLOR) + arrow.set_color(ADDER_COLOR) words = TextMobject("Fix zero") - words.highlight(ADDER_COLOR) + words.set_color(ADDER_COLOR) words.next_to(arrow, UP) self.play( @@ -1866,7 +1866,7 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals): words = TextMobject("Follow one") words.next_to(arrow.get_start(), UP) for mob in dot, arrow, words: - mob.highlight(MULTIPLIER_COLOR) + mob.set_color(MULTIPLIER_COLOR) three_line, half_line = [ DashedLine( @@ -1886,7 +1886,7 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals): ) half_label = TexMobject("1/2") half_label.scale(0.7) - half_label.highlight(MULTIPLIER_COLOR) + half_label.set_color(MULTIPLIER_COLOR) half_label.next_to(half_arrow.get_start(), LEFT, buff = SMALL_BUFF) self.play( @@ -1948,7 +1948,7 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals): color = self.positive_reals_color ) positive_reals_words = TextMobject("All positive reals") - positive_reals_words.highlight(self.positive_reals_color) + positive_reals_words.set_color(self.positive_reals_color) positive_reals_words.next_to(positive_reals_line, UP) positive_reals_words.add_background_rectangle() @@ -2001,7 +2001,7 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals): words.submobjects.insert(2, TexMobject("=")) words.arrange_submobjects(RIGHT) top_words = VGroup(*words[:2]) - top_words.highlight(MULTIPLIER_COLOR) + top_words.set_color(MULTIPLIER_COLOR) bottom_words = VGroup(*words[2:]) bottom_words.next_to(top_words, DOWN) words.scale(0.8) @@ -2030,10 +2030,10 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals): new_title.to_edge(UP) VGroup( *new_title[:len("Multiplicative")] - ).highlight(MULTIPLIER_COLOR) + ).set_color(MULTIPLIER_COLOR) VGroup( *new_title[-len("positiverealnumbers"):] - ).highlight(self.positive_reals_color) + ).set_color(self.positive_reals_color) self.play(Transform(self.title, new_title)) self.wait() @@ -2094,8 +2094,8 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): "complex numbers" ) title.to_edge(UP) - title[0].highlight(MULTIPLIER_COLOR) - title[2].highlight(BLUE) + title[0].set_color(MULTIPLIER_COLOR) + title[2].set_color(BLUE) title.add_background_rectangle() self.play(Write(title, run_time = 2)) @@ -2107,9 +2107,9 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): UP+1.25*LEFT, ORIGIN, buff = 2*self.dot_radius ) - zero_arrow.highlight(ADDER_COLOR) + zero_arrow.set_color(ADDER_COLOR) zero_words = TextMobject("Fix zero") - zero_words.highlight(ADDER_COLOR) + zero_words.set_color(ADDER_COLOR) zero_words.add_background_rectangle() zero_words.next_to(zero_arrow.get_start(), UP) @@ -2120,7 +2120,7 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): color = MULTIPLIER_COLOR, ) one_words = TextMobject("Drag one") - one_words.highlight(MULTIPLIER_COLOR) + one_words.set_color(MULTIPLIER_COLOR) one_words.add_background_rectangle() one_words.next_to(one_arrow.get_start(), UP) @@ -2156,9 +2156,9 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): def show_action_at_i(self): i_point = self.z_to_point(complex(0, 1)) i_dot = Dot(i_point) - i_dot.highlight(RED) + i_dot.set_color(RED) i_arrow = Arrow(i_point+UP+LEFT, i_point) - i_arrow.highlight(i_dot.get_color()) + i_arrow.set_color(i_dot.get_color()) arc = Arc( start_angle = np.pi/24, @@ -2167,7 +2167,7 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): num_anchors = 20, ) arc.add_tip(tip_length = 0.15) - arc.highlight(YELLOW) + arc.set_color(YELLOW) self.play( ShowCreation(i_arrow), @@ -2216,7 +2216,7 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): equation.add_background_rectangle() equation.next_to(ORIGIN, RIGHT) equation.shift(1.5*UP) - equation.highlight(MULTIPLIER_COLOR) + equation.set_color(MULTIPLIER_COLOR) self.play(Write(equation, run_time = 2)) self.wait() @@ -2251,7 +2251,7 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): brace_text.scale(0.7, about_point = brace.get_top()) brace.rotate(angle) brace_text.rotate(angle).rotate_in_place(-angle) - VGroup(brace, brace_text).highlight(MAROON_B) + VGroup(brace, brace_text).set_color(MAROON_B) arc = Arc(angle, color = WHITE, radius = 0.5) angle_label = TexMobject("30^\\circ") angle_label.scale(0.7) @@ -2259,7 +2259,7 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): arc, RIGHT, buff = SMALL_BUFF, aligned_edge = DOWN ) - angle_label.highlight(MULTIPLIER_COLOR) + angle_label.set_color(MULTIPLIER_COLOR) self.play( Write(label), @@ -2298,7 +2298,7 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): def show_break_down(self): positive_reals = Line(ORIGIN, FRAME_X_RADIUS*RIGHT) - positive_reals.highlight(MAROON_B) + positive_reals.set_color(MAROON_B) circle = Circle( radius = self.z_to_point(1)[0], color = MULTIPLIER_COLOR @@ -2328,7 +2328,7 @@ class MultiplicativeGroupOfComplexNumbers(AdditiveGroupOfComplexNumbers): ] for z in z_list: dot = Dot(self.z_to_point(z)) - dot.highlight(WHITE) + dot.set_color(WHITE) dot.save_state() dot.move_to(self.plane.one_dot) dot.set_fill(opacity = 1) @@ -2433,8 +2433,8 @@ class ExponentsAsRepeatedMultiplication(TeacherStudentsScene): general_equation = TexMobject("2^{x+y}=", "2^x", "2^y") general_equation.to_edge(UP, buff = MED_LARGE_BUFF) - general_equation[0].highlight(GREEN_B) - VGroup(*general_equation[1:]).highlight(MULTIPLIER_COLOR) + general_equation[0].set_color(GREEN_B) + VGroup(*general_equation[1:]).set_color(MULTIPLIER_COLOR) self.play(*[ ReplacementTransform( mob.copy(), term, run_time = 2 @@ -2523,7 +2523,7 @@ class ExponentsAsRepeatedMultiplication(TeacherStudentsScene): self.play( imag_power.move_to, UP, imag_power.scale_in_place, 1.5, - imag_power.highlight, BLUE, + imag_power.set_color, BLUE, self.exponential_rule.to_edge, RIGHT, self.get_teacher().change_mode, "speaking" ) @@ -2579,10 +2579,10 @@ class ExponentsAsHomomorphism(Scene): rhs = VGroup(*equation[5:]) lhs_brace = Brace(lhs, UP) lhs_text = lhs_brace.get_text("Add inputs") - lhs_text.highlight(GREEN_B) + lhs_text.set_color(GREEN_B) rhs_brace = Brace(rhs, DOWN) rhs_text = rhs_brace.get_text("Multiply outputs") - rhs_text.highlight(MULTIPLIER_COLOR) + rhs_text.set_color(MULTIPLIER_COLOR) self.add(equation) for brace, text in (lhs_brace, lhs_text), (rhs_brace, rhs_text): @@ -2609,7 +2609,7 @@ class ExponentsAsHomomorphism(Scene): adders.center, adders.space_out_submobjects, 2, adders.to_edge, UP, - adders.highlight, GREEN_B, + adders.set_color, GREEN_B, FadeOut(self.lhs_brace_group), Write(top_line) ) @@ -2633,7 +2633,7 @@ class ExponentsAsHomomorphism(Scene): multipliers.space_out_submobjects, 4, multipliers.next_to, self.bottom_line_center, UP, MED_LARGE_BUFF, - multipliers.highlight, YELLOW, + multipliers.set_color, YELLOW, FadeOut(self.rhs_brace_group), Write(bottom_line), ) @@ -2691,7 +2691,7 @@ class ExponentsAsHomomorphism(Scene): target_texs += ["2^{%d}"%x for x in inputs] for mob, target_tex in zip(terms, target_texs): target = TexMobject(target_tex) - target.highlight(mob[0].get_color()) + target.set_color(mob[0].get_color()) target.move_to(mob, DOWN) if mob in self.adders: target.to_edge(UP) @@ -2831,9 +2831,9 @@ class DihedralCubeHomomorphism(GroupOfCubeSymmetries, SymmetriesOfSquare): if i == 2: for group, color in (homo_group, YELLOW), (morph_group, BLUE): part, remainder = group[0], VGroup(*group[1:]) - remainder.highlight(color) + remainder.set_color(color) self.play( - part.highlight, color, + part.set_color, color, FadeIn(remainder) ) @@ -2856,8 +2856,8 @@ class ComplexExponentiationAbstract(): self.draw_real_line() self.show_real_actions(*example_inputs) self.show_pure_imaginary_actions(*example_inputs) - self.highlight_vertical_line() - self.highlight_unit_circle() + self.set_color_vertical_line() + self.set_color_unit_circle() self.show_pure_imaginary_actions(*example_inputs) self.walk_input_up_vertical() self.change_base(self.new_base, str(self.new_base)) @@ -2884,7 +2884,7 @@ class ComplexExponentiationAbstract(): def add_title(self): title = TextMobject(self.group_type, "group") title.scale(0.8) - title[0].highlight(self.color) + title[0].set_color(self.color) title.add_background_rectangle() title.to_edge(UP, buff = MED_SMALL_BUFF) self.add_foreground_mobjects(title) @@ -2912,7 +2912,7 @@ class ComplexExponentiationAbstract(): line = VGroup(Line(ORIGIN, FRAME_X_RADIUS*RIGHT)) if self.vect[0] < 0: line.add(Line(ORIGIN, FRAME_X_RADIUS*LEFT)) - line.highlight(RED) + line.set_color(RED) self.play(*map(ShowCreation, line), run_time = 3) self.add_foreground_mobjects(line) @@ -2941,8 +2941,8 @@ class ComplexExponentiationAbstract(): def write_eulers_formula(self): formula = TexMobject("e^", "{\\pi", "i}", "=", "-1") - VGroup(*formula[1:3]).highlight(ADDER_COLOR) - formula[-1].highlight(MULTIPLIER_COLOR) + VGroup(*formula[1:3]).set_color(ADDER_COLOR) + formula[-1].set_color(MULTIPLIER_COLOR) formula.scale(1.5) formula.next_to(ORIGIN, UP) formula.shift(-FRAME_X_RADIUS*self.vect/2) @@ -2975,12 +2975,12 @@ class ComplexExponentiationAdderHalf( *kwargs.get("added_anims", []) ) - def highlight_vertical_line(self): + def set_color_vertical_line(self): line = VGroup( Line(ORIGIN, FRAME_Y_RADIUS*UP), Line(ORIGIN, FRAME_Y_RADIUS*DOWN), ) - line.highlight(YELLOW) + line.set_color(YELLOW) self.play( FadeOut(self.real_line), @@ -2996,12 +2996,12 @@ class ComplexExponentiationAdderHalf( self.foreground_mobjects = [line] + self.foreground_mobjects self.vertical_line = line - def highlight_unit_circle(self): + def set_color_unit_circle(self): line = VGroup( Line(ORIGIN, FRAME_Y_RADIUS*UP), Line(ORIGIN, FRAME_Y_RADIUS*DOWN), ) - line.highlight(YELLOW) + line.set_color(YELLOW) for submob in line: submob.insert_n_anchor_points(10) submob.make_smooth() @@ -3009,7 +3009,7 @@ class ComplexExponentiationAdderHalf( Circle(), Circle().flip(RIGHT), ) - circle.highlight(YELLOW) + circle.set_color(YELLOW) circle.shift(FRAME_X_RADIUS*RIGHT) self.play(ReplacementTransform( @@ -3020,7 +3020,7 @@ class ComplexExponentiationAdderHalf( def walk_input_up_vertical(self): arrow = Arrow(ORIGIN, UP, buff = 0, tip_length = 0.15) - arrow.highlight(GREEN) + arrow.set_color(GREEN) brace = Brace(arrow, RIGHT, buff = SMALL_BUFF) brace_text = brace.get_text("1 unit") brace_text.add_background_rectangle() @@ -3095,17 +3095,17 @@ class ComplexExponentiationMultiplierHalf( kwargs["run_time"] = run_time self.multiply_by_z(self.base**z, **kwargs) - def highlight_vertical_line(self): + def set_color_vertical_line(self): self.play(FadeOut(self.real_line)) self.foreground_mobjects.remove(self.real_line) self.wait(2) - def highlight_unit_circle(self): + def set_color_unit_circle(self): line = VGroup( Line(ORIGIN, FRAME_Y_RADIUS*UP), Line(ORIGIN, FRAME_Y_RADIUS*DOWN), ) - line.highlight(YELLOW) + line.set_color(YELLOW) line.shift(FRAME_X_RADIUS*LEFT) for submob in line: submob.insert_n_anchor_points(10) @@ -3114,7 +3114,7 @@ class ComplexExponentiationMultiplierHalf( Circle(), Circle().flip(RIGHT), ) - circle.highlight(YELLOW) + circle.set_color(YELLOW) self.play(ReplacementTransform( line, circle, run_time = 3 @@ -3241,8 +3241,8 @@ class WhyE(TeacherStudentsScene): class ReadFormula(Scene): def construct(self): formula = TexMobject("e^", "{\\pi i}", "=", "-1") - formula[1].highlight(GREEN_B) - formula[3].highlight(MULTIPLIER_COLOR) + formula[1].set_color(GREEN_B) + formula[3].set_color(MULTIPLIER_COLOR) formula.scale(2) randy = Randolph() @@ -3304,7 +3304,7 @@ class EmeraldLogo(SVGMobject): SVGMobject.__init__(self, **kwargs) self.scale_to_fit_height(1) for submob in self.split()[18:]: - submob.highlight(self.helix_color) + submob.set_color(self.helix_color) class ECLPromo(PiCreatureScene): CONFIG = { @@ -3389,8 +3389,8 @@ class ExpTransformation(ComplexTransformationScene): class Thumbnail(Scene): def construct(self): formula = TexMobject("e^", "{\\pi i}", "=", "-1") - formula[1].highlight(GREEN_B) - formula[3].highlight(YELLOW) + formula[1].set_color(GREEN_B) + formula[3].set_color(YELLOW) formula.scale(4) formula.to_edge(UP, buff = LARGE_BUFF) self.add(formula) diff --git a/old_projects/eoc/chapter1.py b/old_projects/eoc/chapter1.py index af33c6f6..74a67f6c 100644 --- a/old_projects/eoc/chapter1.py +++ b/old_projects/eoc/chapter1.py @@ -115,7 +115,7 @@ class CircleScene(PiCreatureScene): nudge_label = TexMobject("%.01f"%self.dR) else: nudge_label = TexMobject("dr") - nudge_label.highlight(self.dR_color) + nudge_label.set_color(self.dR_color) nudge_label.scale(0.75) nudge_label.next_to(nudge_arrow.get_start(), DOWN) @@ -246,7 +246,7 @@ class Introduction(TeacherStudentsScene): series = VideoSeries() series.to_edge(UP) this_video = series[0] - this_video.highlight(YELLOW) + this_video.set_color(YELLOW) this_video.save_state() this_video.set_fill(opacity = 0) this_video.center() @@ -258,7 +258,7 @@ class Introduction(TeacherStudentsScene): "Welcome to \\\\", "Essence of calculus" ) - words.highlight_by_tex("Essence of calculus", YELLOW) + words.set_color_by_tex("Essence of calculus", YELLOW) self.teacher.change_mode("happy") self.play( @@ -335,7 +335,7 @@ class Introduction(TeacherStudentsScene): for rule in rules: for tex, color in tex_to_color: - rule.highlight_by_tex(tex, color, substring = False) + rule.set_color_by_tex(tex, color, substring = False) rule.next_to(self.teacher.get_corner(UP+LEFT), UP) rule.shift_onto_screen() @@ -414,7 +414,7 @@ class PreviewFrame(Scene): colors = iter(color_gradient([BLUE, YELLOW], 3)) titles = [ - TextMobject("Chapter %d:"%d, s).to_edge(UP).highlight(colors.next()) + TextMobject("Chapter %d:"%d, s).to_edge(UP).set_color(colors.next()) for d, s in [ (3, "Derivative formulas through geometry"), (4, "Chain rule, product rule, etc."), @@ -474,7 +474,7 @@ class ProductRuleDiagram(Scene): for corner in corner_pair ]) d_rect.line = d_rect.copy().replace(line, stretch = True) - d_rect.line.highlight(d_rect.get_color()) + d_rect.line.set_color(d_rect.get_color()) f_brace = Brace(rect, UP) g_brace = Brace(rect, LEFT) @@ -486,8 +486,8 @@ class ProductRuleDiagram(Scene): df_label = df_brace.get_text("$df$") dg_label = dg_brace.get_text("$dg$") - VGroup(f_label, df_label).highlight(GREEN) - VGroup(g_label, dg_label).highlight(RED) + VGroup(f_label, df_label).set_color(GREEN) + VGroup(g_label, dg_label).set_color(RED) f_label.generate_target() g_label.generate_target() @@ -776,7 +776,7 @@ class ApproximateOneRing(CircleScene, ReconfigurableScene): r_label = TexMobject("r") r_label.next_to(radius.get_center(), UP+LEFT, SMALL_BUFF) area_q = TextMobject("Area", "?", arg_separator = "") - area_q.highlight(YELLOW) + area_q.set_color(YELLOW) self.play( @@ -962,7 +962,7 @@ class MoveForwardWithApproximation(TeacherStudentsScene): "\\\\ for smaller ", "$dr$" ) - words.highlight_by_tex("dr", BLUE) + words.set_color_by_tex("dr", BLUE) self.teacher_says(words, target_mode = "shruggie") self.wait(3) @@ -1016,7 +1016,7 @@ class GraphRectangles(CircleScene, GraphScene): "\\text{Area}", "\\approx", "2\\pi", "r", "\\,dr" ) - area_label.highlight_by_tex("r", YELLOW, substring = False) + area_label.set_color_by_tex("r", YELLOW, substring = False) area_label.next_to(ring_sum, RIGHT, aligned_edge = UP) area = area_label.get_part_by_tex("Area") arrow_start = area.get_corner(DOWN+LEFT) @@ -1047,7 +1047,7 @@ class GraphRectangles(CircleScene, GraphScene): def draw_r_values(self): values_of_r = TextMobject("Values of ", "$r$") - values_of_r.highlight_by_tex("r", YELLOW) + values_of_r.set_color_by_tex("r", YELLOW) values_of_r.next_to( self.x_axis, UP, buff = 2*LARGE_BUFF, @@ -1196,7 +1196,7 @@ class GraphRectangles(CircleScene, GraphScene): side_brace = Brace(highlighted_ring, RIGHT) height_label = side_brace.get_text("2\\pi", "r") - height_label.highlight_by_tex("r", YELLOW) + height_label.set_color_by_tex("r", YELLOW) self.play( transformed_rings.set_fill, None, 0.2, @@ -1477,11 +1477,11 @@ class GraphRectangles(CircleScene, GraphScene): "\\\\ &=", "\\pi ", "%s"%R, "^2" ) - formula.highlight_by_tex("b", GREEN, substring = False) - formula.highlight_by_tex("h", RED, substring = False) - formula.highlight_by_tex("%s"%R, GREEN) - formula.highlight_by_tex("(2\\pi ", RED) - formula.highlight_by_tex("(2\\pi ", RED) + formula.set_color_by_tex("b", GREEN, substring = False) + formula.set_color_by_tex("h", RED, substring = False) + formula.set_color_by_tex("%s"%R, GREEN) + formula.set_color_by_tex("(2\\pi ", RED) + formula.set_color_by_tex("(2\\pi ", RED) formula.scale(0.8) formula.top_line = VGroup(*formula[:4]) @@ -1492,7 +1492,7 @@ class GraphRectangles(CircleScene, GraphScene): class ThinkLikeAMathematician(TeacherStudentsScene): def construct(self): pi_R_squraed = TexMobject("\\pi", "R", "^2") - pi_R_squraed.highlight_by_tex("R", YELLOW) + pi_R_squraed.set_color_by_tex("R", YELLOW) pi_R_squraed.move_to(self.get_students(), UP) pi_R_squraed.set_fill(opacity = 0) @@ -1519,7 +1519,7 @@ class TwoThingsToNotice(TeacherStudentsScene): "Two things to \\\\ note about", "$dr$", ) - words.highlight_by_tex("dr", GREEN) + words.set_color_by_tex("dr", GREEN) self.teacher_says(words, run_time = 1) self.wait(3) @@ -1583,15 +1583,15 @@ class RecapCircleSolution(GraphRectangles, ReconfigurableScene): "\\approx", "2\\pi", "(%s)"%str(radius), "(%s)"%str(self.dR) ) - label[2].highlight(YELLOW) - label[3].highlight(GREEN) + label[2].set_color(YELLOW) + label[3].set_color(GREEN) label.scale(0.75) label.next_to(ring, RIGHT) approximations.add(label) approximations[-1].shift(UP+0.5*LEFT) area_label = TexMobject("2\\pi", "r", "\\, dr") - area_label.highlight_by_tex("r", YELLOW) - area_label.highlight_by_tex("dr", GREEN) + area_label.set_color_by_tex("r", YELLOW) + area_label.set_color_by_tex("dr", GREEN) area_label.next_to(approximations, RIGHT, buff = 2*LARGE_BUFF) arrows = VGroup(*[ Arrow( @@ -1739,7 +1739,7 @@ class RecapCircleSolution(GraphRectangles, ReconfigurableScene): words = TextMobject("Area under \\\\ a graph") group = VGroup(TexMobject("\\Downarrow"), words) group.arrange_submobjects(DOWN) - group.highlight(YELLOW) + group.set_color(YELLOW) group.scale(0.8) group.next_to(self.integral_condition, DOWN) @@ -1817,7 +1817,7 @@ class ExampleIntegralProblems(PiCreatureScene, GraphScene): brace = Brace(brace_ticks, UP) v_dt = TexMobject("v(t)", "dt") v_dt.next_to(brace, UP, SMALL_BUFF) - v_dt.highlight(YELLOW) + v_dt.set_color(YELLOW) v_dt_brace_group = VGroup(brace, v_dt) self.play( @@ -2132,7 +2132,7 @@ class AreaUnderParabola(GraphScene): def name_integral(self): f_tex = "$%s$"%self.graph_label_tex words = TextMobject("``Integral'' of ", f_tex) - words.highlight_by_tex(f_tex, self.graph_label.get_color()) + words.set_color_by_tex(f_tex, self.graph_label.get_color()) brace = Brace(self.A_func, UP) words.next_to(brace, UP) @@ -2210,7 +2210,7 @@ class PlayWithThisIdea(TeacherStudentsScene): self.change_student_modes(*["happy"]*3) self.wait() equation = TexMobject("A(x)", "\\leftrightarrow", "x^2") - equation.highlight_by_tex("x^2", BLUE) + equation.set_color_by_tex("x^2", BLUE) self.teacher_says(equation, target_mode = "sassy") self.change_student_modes(*["thinking"]*3) self.wait(2) @@ -2275,7 +2275,7 @@ class PlayingTowardsDADX(AreaUnderParabola, ReconfigurableScene): ).move_to(self.right_v_lines, DOWN) dA_label = TexMobject("d", "A") dA_label.next_to(dA_rect, RIGHT, MED_LARGE_BUFF, UP) - dA_label.highlight(GREEN) + dA_label.set_color(GREEN) dA_arrow = Arrow( dA_label.get_bottom()+MED_SMALL_BUFF*DOWN, dA_rect.get_center(), @@ -2287,8 +2287,8 @@ class PlayingTowardsDADX(AreaUnderParabola, ReconfigurableScene): "d", "ifference in ", "A", "rea", arg_separator = "" ) - difference_in_area.highlight_by_tex("d", GREEN) - difference_in_area.highlight_by_tex("A", GREEN) + difference_in_area.set_color_by_tex("d", GREEN) + difference_in_area.set_color_by_tex("A", GREEN) difference_in_area.scale(0.7) difference_in_area.next_to(dA_label, UP, MED_SMALL_BUFF, LEFT) @@ -2314,7 +2314,7 @@ class PlayingTowardsDADX(AreaUnderParabola, ReconfigurableScene): self.play(FadeIn(dA_rect), Animation(dA_arrow)) self.play(GrowFromCenter(side_brace)) self.play( - graph_label_copy.highlight, WHITE, + graph_label_copy.set_color, WHITE, graph_label_copy.next_to, side_brace, LEFT, SMALL_BUFF ) self.wait() @@ -2344,7 +2344,7 @@ class PlayingTowardsDADX(AreaUnderParabola, ReconfigurableScene): deriv_equation.move_to(equation, UP+LEFT) for tex_mob in equation, deriv_equation: - tex_mob.highlight_by_tex( + tex_mob.set_color_by_tex( "dA", self.dA_label.get_color() ) @@ -2439,7 +2439,7 @@ class PlayingTowardsDADX(AreaUnderParabola, ReconfigurableScene): tip_length = 0.15 ) line_copy = line.copy() - line_copy.highlight(YELLOW) + line_copy.set_color(YELLOW) self.play( FadeIn(label), @@ -2550,12 +2550,12 @@ class AlternateAreaUnderCurve(PlayingTowardsDADX): "Gets better \\\\ as", "$dx \\to 0$" ) - dx_to_zero_words.highlight_by_tex("dx", color) + dx_to_zero_words.set_color_by_tex("dx", color) dx_to_zero_words.next_to(approx, DOWN, 1.5*LARGE_BUFF) arrow = Arrow(dx_to_zero_words, approx, color = color) self.play( - approx.highlight, color, + approx.set_color, color, ShowCreation(arrow), FadeIn(dx_to_zero_words), ) @@ -2652,7 +2652,7 @@ class FundamentalTheorem(Scene): deriv = TexMobject( "{dA", "\\over \\,", "dx}", "=", "x^2" ) - deriv.highlight_by_tex("dA", GREEN) + deriv.set_color_by_tex("dA", GREEN) deriv.next_to(arrow, RIGHT) self.play(ShowCreation(arrow)) @@ -2667,7 +2667,7 @@ class NextVideos(TeacherStudentsScene): series = VideoSeries() series.to_edge(UP) this_video = series[0] - this_video.highlight(YELLOW) + this_video.set_color(YELLOW) self.add(series) self.teacher_says( diff --git a/old_projects/eoc/chapter10.py b/old_projects/eoc/chapter10.py index 38e764af..4c742060 100644 --- a/old_projects/eoc/chapter10.py +++ b/old_projects/eoc/chapter10.py @@ -119,7 +119,7 @@ class ExampleApproximation(GraphScene): equation.next_to(near_text, DOWN, MED_LARGE_BUFF) equation.to_edge(RIGHT) near_text.next_to(equation, UP, MED_LARGE_BUFF) - equation.highlight_by_tex( + equation.set_color_by_tex( self.function_tex, self.function_color, substring = False ) @@ -416,7 +416,7 @@ class Pendulum(ReconfigurableScene): for angle in angles ]) - dots.highlight(color) + dots.set_color(color) dots.scale(self.radius) dots.rotate(-np.pi/2 + arc_angle) dots.shift(self.anchor_point) @@ -456,7 +456,7 @@ class Pendulum(ReconfigurableScene): tex_mob = TexMobject( "R", "\\big(1-", "\\cos(", "\\theta", ")", "\\big)" ) - tex_mob.highlight_by_tex("theta", YELLOW) + tex_mob.set_color_by_tex("theta", YELLOW) tex_mob.next_to(brace, RIGHT) return tex_mob @@ -467,7 +467,7 @@ class Pendulum(ReconfigurableScene): color = YELLOW ) theta = TexMobject("\\theta") - theta.highlight(YELLOW) + theta.set_color(YELLOW) theta.next_to( arc.point_from_proportion(0.5), DOWN, SMALL_BUFF @@ -478,7 +478,7 @@ class Pendulum(ReconfigurableScene): def get_cosine_approx(self): approx = TexMobject(*self.approx_tex) - approx.highlight_by_tex("theta", YELLOW) + approx.set_color_by_tex("theta", YELLOW) approx.theta_squared_over_two = VGroup(*approx[1:5]) return approx @@ -598,7 +598,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): dot = Dot(color = WHITE) dot.move_to(cosine_label) for mob in cosine_label, cosine_graph: - mob.highlight(self.colors[0]) + mob.set_color(self.colors[0]) def update_dot(dot): dot.move_to(cosine_graph.points[-1]) @@ -710,7 +710,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): ) poly_at_zero.next_to(self.quadratic_tex, DOWN) equals_c0 = TexMobject("=", "c_0", "+0") - equals_c0.highlight_by_tex("c_0", self.colors[0]) + equals_c0.set_color_by_tex("c_0", self.colors[0]) equals_c0.next_to( poly_at_zero.get_part_by_tex("="), DOWN, buff = MED_LARGE_BUFF, @@ -722,7 +722,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): self.quadratic_tex, ) poly_group_target = VGroup( - TexMobject("=", "1", "+0").highlight_by_tex("1", self.colors[0]), + TexMobject("=", "1", "+0").set_color_by_tex("1", self.colors[0]), self.get_quadratic_tex("1", "c_1", "c_2", arg = "0"), self.get_quadratic_tex("1", "c_1", "c_2"), ) @@ -818,14 +818,14 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): buff = MED_LARGE_BUFF, aligned_edge = LEFT, ) - equals_c1.highlight_by_tex("c_1", self.colors[1]) + equals_c1.set_color_by_tex("c_1", self.colors[1]) poly_group = VGroup( equals_c1, derivative, self.quadratic_tex ) poly_group_target = VGroup( - TexMobject("=", "0", "+0").highlight_by_tex( + TexMobject("=", "0", "+0").set_color_by_tex( "0", self.colors[1], substring = False ), self.get_quadratic_derivative("0", "c_2", arg = "0"), @@ -951,7 +951,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): second_deriv[0].scale( 0.7, about_point = second_deriv[0].get_right() ) - second_deriv[-1].highlight(self.colors[-1]) + second_deriv[-1].set_color(self.colors[-1]) second_deriv.next_to( deriv, DOWN, buff = MED_LARGE_BUFF, @@ -1018,7 +1018,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): c0, "+", c1, arg, "+", c2, arg, "^2" ) for tex, color in zip([c0, c1, c2], self.colors): - tex_mob.highlight_by_tex(tex, color) + tex_mob.set_color_by_tex(tex, color) tex_mob.to_corner(UP+RIGHT) return tex_mob @@ -1029,7 +1029,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): ) result[0].scale(0.7, about_point = result[0].get_right()) for index, color in zip([5, 8], self.colors[1:]): - result[index].highlight(color) + result[index].set_color(color) if hasattr(self, "quadratic_tex"): result.next_to( self.quadratic_tex, DOWN, @@ -1073,7 +1073,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): derivative = TexMobject( "{d(", "\\cos", ")", "\\over", "dx}", "(0)", ) - derivative.highlight_by_tex("\\cos", self.colors[0]) + derivative.set_color_by_tex("\\cos", self.colors[0]) derivative.scale(0.7) derivative.next_to( self.cosine_label, DOWN, @@ -1081,7 +1081,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): aligned_edge = LEFT ) rhs = TexMobject("=", "-\\sin(0)", "=", "0") - rhs.highlight_by_tex("\\sin", self.colors[1]) + rhs.set_color_by_tex("\\sin", self.colors[1]) rhs.scale(0.75) rhs.next_to( derivative, RIGHT, @@ -1098,8 +1098,8 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): "{d^2(", "\\cos", ")", "\\over", "dx^2}", "(", "0", ")", ) - second_deriv.highlight_by_tex("cos", self.colors[0]) - second_deriv.highlight_by_tex("-\\cos", self.colors[2]) + second_deriv.set_color_by_tex("cos", self.colors[0]) + second_deriv.set_color_by_tex("-\\cos", self.colors[2]) second_deriv.scale(0.75) second_deriv.add_background_rectangle() second_deriv.next_to( @@ -1108,7 +1108,7 @@ class ConstructQuadraticApproximation(ExampleApproximationWithCos): aligned_edge = LEFT ) rhs = TexMobject("=", "-\\cos(0)", "=", "-1") - rhs.highlight_by_tex("cos", self.colors[2]) + rhs.set_color_by_tex("cos", self.colors[2]) rhs.scale(0.8) rhs.next_to( second_deriv, RIGHT, @@ -1146,7 +1146,7 @@ class ReflectOnQuadraticApproximation(TeacherStudentsScene): real_result.get_part_by_tex("=").get_center() ) for mob in approx_at_point, real_result: - mob.highlight_by_tex("0.1", YELLOW) + mob.set_color_by_tex("0.1", YELLOW) real_result.set_fill(opacity = 0) self.play( @@ -1253,7 +1253,7 @@ class ReflectOnQuadraticApproximation(TeacherStudentsScene): ) colors = ConstructQuadraticApproximation.CONFIG["colors"] for tex, color in zip([c0, c1, c2], colors): - polynomial.highlight_by_tex(tex, color, substring = False) + polynomial.set_color_by_tex(tex, color, substring = False) polynomial.next_to(self.teacher, UP, LARGE_BUFF) polynomial.to_edge(RIGHT) @@ -1377,7 +1377,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): ) self.cosine_label = TexMobject("\\cos", "(0)", "=1") - self.cosine_label.highlight_by_tex("cos", self.colors[0]) + self.cosine_label.set_color_by_tex("cos", self.colors[0]) self.cosine_label.scale(0.75) self.cosine_label.to_corner(UP+LEFT) self.add(self.cosine_label) @@ -1387,8 +1387,8 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): self.polynomial = TexMobject( "P(x)=", "1", "-\\frac{1}{2}", "x^2" ) - self.polynomial.highlight_by_tex("1", self.colors[0]) - self.polynomial.highlight_by_tex("-\\frac{1}{2}", self.colors[2]) + self.polynomial.set_color_by_tex("1", self.colors[0]) + self.polynomial.set_color_by_tex("-\\frac{1}{2}", self.colors[2]) self.polynomial.to_corner(UP+RIGHT) self.polynomial.quadratic_part = VGroup( *self.polynomial[1:] @@ -1400,7 +1400,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): plus_cubic_term = TexMobject("+\\,", "c_3", "x^3") plus_cubic_term.next_to(polynomial, RIGHT) plus_cubic_term.to_edge(RIGHT, buff = LARGE_BUFF) - plus_cubic_term.highlight_by_tex("c_3", self.colors[3]) + plus_cubic_term.set_color_by_tex("c_3", self.colors[3]) plus_cubic_copy = plus_cubic_term.copy() polynomial.generate_target() @@ -1469,7 +1469,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): TexMobject("0").move_to(c3) for c3 in c3s ]) - zeros.highlight(self.colors[3]) + zeros.set_color(self.colors[3]) zeros.shift(SMALL_BUFF*UP) zeros[0].shift(0.25*SMALL_BUFF*(UP+LEFT)) @@ -1506,7 +1506,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): polynomial = self.polynomial plus_quartic_term = TexMobject("+\\,", "c_4", "x^4") plus_quartic_term.next_to(polynomial, RIGHT) - plus_quartic_term.highlight_by_tex("c_4", self.colors[4]) + plus_quartic_term.set_color_by_tex("c_4", self.colors[4]) self.play(*map(FadeOut, [ self.plus_cubic_term, @@ -1542,7 +1542,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): buff = LARGE_BUFF, aligned_edge = LEFT ) - alt_rhs.highlight_by_tex("c_4", self.colors[4]) + alt_rhs.set_color_by_tex("c_4", self.colors[4]) self.play(Write(fourth_deriv_lhs)) self.play( @@ -1565,7 +1565,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): self.plus_quartic_term.get_part_by_tex("c_4") ) fraction = TexMobject("\\text{\\small $\\frac{1}{24}$}") - fraction.highlight(self.colors[4]) + fraction.set_color(self.colors[4]) fractions = VGroup(*[ fraction.copy().move_to(c4, LEFT) for c4 in c4s @@ -1676,8 +1676,8 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): "{d^3(", "\\cos", ")", "\\over", "dx^3}", "(", "0", ")", ) - third_deriv.highlight_by_tex("cos", self.colors[0]) - third_deriv.highlight_by_tex("-\\cos", self.colors[3]) + third_deriv.set_color_by_tex("cos", self.colors[0]) + third_deriv.set_color_by_tex("-\\cos", self.colors[3]) third_deriv.scale(0.75) third_deriv.add_background_rectangle() third_deriv.next_to( @@ -1686,7 +1686,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): aligned_edge = LEFT ) rhs = TexMobject("=", "\\sin(0)", "=", "0") - rhs.highlight_by_tex("sin", self.colors[3]) + rhs.set_color_by_tex("sin", self.colors[3]) rhs.scale(0.8) rhs.next_to( third_deriv, RIGHT, @@ -1705,7 +1705,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): "{d^4(", "\\cos", ")", "\\over", "dx^4}", "(", "0", ")", ) - fourth_deriv.highlight_by_tex("cos", self.colors[0]) + fourth_deriv.set_color_by_tex("cos", self.colors[0]) fourth_deriv.scale(0.75) fourth_deriv.add_background_rectangle() fourth_deriv.next_to( @@ -1714,7 +1714,7 @@ class CubicAndQuarticApproximations(ConstructQuadraticApproximation): aligned_edge = LEFT ) rhs = TexMobject("=", "\\cos(0)", "=", "1") - rhs.highlight_by_tex("cos", self.colors[4]) + rhs.set_color_by_tex("cos", self.colors[4]) rhs.scale(0.8) rhs.next_to( fourth_deriv, RIGHT, @@ -1744,7 +1744,7 @@ class FactorialTerms(CubicAndQuarticApproximations): for s in ["^%d"%i if i > 1 else ""] ] for lhs in lhs_list: - lhs.highlight_by_tex("c_8", YELLOW) + lhs.set_color_by_tex("c_8", YELLOW) lhs.next_to(ORIGIN, LEFT) lhs_list[0].set_fill(opacity = 0) added_anims = [ @@ -1757,7 +1757,7 @@ class FactorialTerms(CubicAndQuarticApproximations): term = TexMobject("c_8", "x^8") term.next_to(lhs[-1], RIGHT) - term.highlight_by_tex("c_8", YELLOW) + term.set_color_by_tex("c_8", YELLOW) self.add(term) self.wait() @@ -1772,7 +1772,7 @@ class FactorialTerms(CubicAndQuarticApproximations): "Set", "$c_8$", "$ = \\frac{\\text{Desired derivative value}}{8!}" ) - words.highlight_by_tex("c_8", YELLOW) + words.set_color_by_tex("c_8", YELLOW) words.shift(2*UP) self.play( @@ -1814,7 +1814,7 @@ class HigherTermsDontMessUpLowerTerms(Scene): for tex in c0_tex, c2_tex, c4_tex ] for term, color in zip([c0, c2, c4], self.colors): - term.highlight(color) + term.set_color(color) arrows = VGroup(*[ Arrow( c4.get_top(), c.get_top(), @@ -1850,9 +1850,9 @@ class HigherTermsDontMessUpLowerTerms(Scene): "2", self.c2_tex, "+", "3 \\cdot 4", self.c4_tex, "(", "0", ")", "^2" ) - second_deriv.highlight_by_tex(self.c2_tex, self.colors[1]) - second_deriv.highlight_by_tex(self.c4_tex, self.colors[2]) - second_deriv.highlight_by_tex("0", YELLOW) + second_deriv.set_color_by_tex(self.c2_tex, self.colors[1]) + second_deriv.set_color_by_tex(self.c4_tex, self.colors[2]) + second_deriv.set_color_by_tex("0", YELLOW) second_deriv.next_to( self.polynomial, DOWN, buff = MED_LARGE_BUFF, @@ -1903,7 +1903,7 @@ class EachTermControlsOneDerivative(Scene): for const, deriv, color in zip(consts, deriv_words, colors): for mob in const, deriv: - mob.highlight(color) + mob.set_color(color) arrow = Arrow( const.get_top(), deriv.get_bottom(), @@ -2014,7 +2014,7 @@ class ApproximateNearNewPoint(CubicAndQuarticApproximations): ]) ) for d, color in enumerate(self.colors): - result.highlight_by_tex("c_%d"%d, color) + result.set_color_by_tex("c_%d"%d, color) result.scale(0.85) result.add_background_rectangle() return result @@ -2080,7 +2080,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations): center_v_line.copy().shift(vect) for vect in LEFT, RIGHT ]) - outer_v_lines.highlight(GREEN) + outer_v_lines.set_color(GREEN) dot = Dot(color = YELLOW) dot.move_to(center_v_line.get_top()) dot.save_state() @@ -2154,7 +2154,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations): group.to_edge(LEFT) for dx, d0, color in zip(derivs_at_x, derivs_at_zero, self.colors): for d in dx, d0: - d.highlight(color) + d.set_color(color) d0.replace(dx) rhs_group = VGroup(*[ TexMobject("=", "%d"%d).scale(0.7).next_to(deriv, RIGHT) @@ -2164,7 +2164,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations): rhs[1] for rhs in rhs_group ]) for value, color in zip(derivative_values, self.colors): - value.highlight(color) + value.set_color(color) zeros = VGroup(*[ deriv.get_part_by_tex("0") for deriv in derivs_at_zero @@ -2254,7 +2254,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations): x_min = -3.2, x_max = 3.2, ) - quartic_graph.highlight(self.colors[4]) + quartic_graph.set_color(self.colors[4]) self.play(GrowFromCenter(brace)) self.play(Write(name)) @@ -2316,7 +2316,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations): for color, dx, d0, da in zip(self.colors, *deriv_lists): for d in dx, d0, da: - d.highlight(color) + d.set_color(color) d.add_background_rectangle() d0.replace(dx) da.replace(dx) @@ -2376,7 +2376,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations): for n in range(7) ] for graph, color in zip(approx_graphs, self.colors): - graph.highlight(color) + graph.set_color(color) left_mob = self.polynomial.coefficients[0] right_mobs = list(self.polynomial.factorials) @@ -2489,7 +2489,7 @@ class TranslationOfInformation(CubicAndQuarticApproximations): result.scale(0.8) coefs = VGroup(result[1], *result[3:-1:6]) for coef, color in zip(coefs, self.colors): - coef.highlight(color) + coef.set_color(color) result.coefficients = coefs result.factorials = VGroup(*result[7::6]) @@ -2542,7 +2542,7 @@ class ExpPolynomial(TranslationOfInformation, ExampleApproximationWithExp): self.e_to_x.generate_target() derivs_at_x, derivs_at_zero = [ VGroup(*[ - TexMobject("e^%s"%s).highlight(c) + TexMobject("e^%s"%s).set_color(c) for c in self.colors ]) for s in "x", "0" @@ -2577,7 +2577,7 @@ class ExpPolynomial(TranslationOfInformation, ExampleApproximationWithExp): rhs[1] for rhs in rhs_group ]) for value, color in zip(derivative_values, self.colors): - value.highlight(color) + value.set_color(color) for arrow in arrows: d_dx = TexMobject("d/dx") @@ -2646,7 +2646,7 @@ class ShowSecondTerm(TeacherStudentsScene): "\\frac{d^2 f}{dx^2}(a)", "(x - a)^2" ) for tex, color in zip(["f(a)", "df", "d^2 f"], colors): - polynomial.highlight_by_tex(tex, color) + polynomial.set_color_by_tex(tex, color) polynomial.next_to(self.teacher, UP+LEFT) polynomial.shift(MED_LARGE_BUFF*UP) second_term = VGroup(*polynomial[-2:]) @@ -2860,7 +2860,7 @@ class SecondTermIntuition(AreaIsDerivative): triangle.get_corner(DOWN+vect) for vect in LEFT, RIGHT ]) - base_line.highlight(RED) + base_line.set_color(RED) base_label = TextMobject("Base = ", "$(x-a)$") base_label.scale(tex_scale_factor) base_label.next_to(base_line, DOWN+RIGHT, MED_LARGE_BUFF) @@ -2959,9 +2959,9 @@ class SecondTermIntuition(AreaIsDerivative): "\\frac{df}{dx}(a)(x-a)", "+", "\\frac{1}{2}\\frac{d^2 f}{dx^2}(a)(x-a)^2" ) - analytic_taylor.highlight_by_tex("f(a)", BLUE) - analytic_taylor.highlight_by_tex("df", YELLOW) - analytic_taylor.highlight_by_tex("d^2 f", MAROON_B) + analytic_taylor.set_color_by_tex("f(a)", BLUE) + analytic_taylor.set_color_by_tex("df", YELLOW) + analytic_taylor.set_color_by_tex("d^2 f", MAROON_B) analytic_taylor.scale(0.7) analytic_taylor.next_to( geometric_taylor, DOWN, @@ -3128,10 +3128,10 @@ class ConvergenceExample(Scene): convergence_words = TextMobject("``Converges'' to $\\frac{1}{2}$") convergence_words.next_to(series, UP, LARGE_BUFF) - convergence_words.highlight(YELLOW) + convergence_words.set_color(YELLOW) rhs = TexMobject("= \\frac{1}{2}") rhs.next_to(series, RIGHT) - rhs.highlight(BLUE) + rhs.set_color(BLUE) brace = braces[0] self.add(series, brace) @@ -3161,7 +3161,7 @@ class ConvergenceExample(Scene): ] for brace, partial_sum in zip(braces, partial_sums): number = brace.get_text("%.7f"%partial_sum) - number.highlight(YELLOW) + number.set_color(YELLOW) brace.add(number) return braces @@ -3200,7 +3200,7 @@ class ExpConvergenceExample(ConvergenceExample): colors = list(CubicAndQuarticApproximations.CONFIG["colors"]) colors += [BLUE_C] for term, color in zip(series[::2], colors): - term.highlight(color) + term.set_color(color) lhs = TexMobject("e^%s"%arg, "\\rightarrow") lhs.arrange_submobjects(RIGHT, buff = SMALL_BUFF) @@ -3294,7 +3294,7 @@ class ExpGraphConvergence(ExpPolynomial, ExpConvergenceExample): colors = it.chain(self.colors, it.repeat(WHITE)) for approx_graph, color in zip(approx_graphs, colors): - approx_graph.highlight(color) + approx_graph.set_color(color) dot = Dot(color = WHITE) dot.move_to(self.input_to_graph_point( self.example_input, approx_graph @@ -3410,7 +3410,7 @@ class RadiusOfConvergenceForLnX(ExpGraphConvergence): series.scale(0.8) series.to_corner(UP+LEFT) for n in range(4): - lhs[2*n].highlight(self.colors[n+1]) + lhs[2*n].set_color(self.colors[n+1]) self.braces = self.get_partial_sum_braces( lhs, np.zeros(self.n_iterations) ) @@ -3471,7 +3471,7 @@ class RadiusOfConvergenceForLnX(ExpGraphConvergence): it.repeat(PINK) ) for graph, color in zip(approx_graphs, colors): - graph.highlight(color) + graph.set_color(color) for graph in approx_graphs: dot = Dot(color = WHITE) dot.move_to(self.input_to_graph_point( @@ -3569,7 +3569,7 @@ class RadiusOfConvergenceForLnX(ExpGraphConvergence): self.coords_to_point(x, 0) for x in 1, 2 ]) - line.highlight(YELLOW) + line.set_color(YELLOW) brace = Brace(line, DOWN) words = brace.get_text("``Radius of convergence''") words.add_background_rectangle() @@ -3592,8 +3592,8 @@ class MoreToBeSaid(TeacherStudentsScene): "convergence tests, ", "$\\dots$" ) - words[0].highlight(BLUE) - words[1].highlight(GREEN) + words[0].set_color(BLUE) + words[1].set_color(GREEN) words.to_edge(UP) fade_rect = FullScreenFadeRectangle() rect = Rectangle(height = 9, width = 16) diff --git a/old_projects/eoc/chapter2.py b/old_projects/eoc/chapter2.py index 67381b64..db713b4d 100644 --- a/old_projects/eoc/chapter2.py +++ b/old_projects/eoc/chapter2.py @@ -104,9 +104,9 @@ class Introduction(TeacherStudentsScene): ", 2) Avoid paradoxes.", arg_separator = "" ) - goals[1].highlight(MAROON_B) - goals[2].highlight(RED) - goals[2][0].highlight(WHITE) + goals[1].set_color(MAROON_B) + goals[2].set_color(RED) + goals[2][0].set_color(WHITE) goals.to_edge(UP) self.add(*goals[:2]) @@ -180,7 +180,7 @@ class Introduction(TeacherStudentsScene): stopped_clock = clock.copy() stopped_clock.next_to(instantaneous_description, DOWN) self.play( - instantaneous.highlight, BLUE, + instantaneous.set_color, BLUE, GrowFromCenter(instantaneous_brace), Transform(change_description.copy(), instantaneous_description), clock.copy().next_to, instantaneous_description, DOWN, @@ -218,11 +218,11 @@ class FathersOfCalculus(Scene): discover_brace = Brace(Mobject(*men[:3]), UP) discover = discover_brace.get_text("Discovered it") - VGroup(discover_brace, discover).highlight(BLUE) + VGroup(discover_brace, discover).set_color(BLUE) rigor_brace = Brace(Mobject(*men[3:]), UP) rigor = rigor_brace.get_text("Made it rigorous") rigor.shift(0.1*DOWN) - VGroup(rigor_brace, rigor).highlight(YELLOW) + VGroup(rigor_brace, rigor).set_color(YELLOW) for man in men: @@ -249,7 +249,7 @@ class IntroduceCar(Scene): A = Dot(point_A) B = Dot(point_B) line = Line(point_A, point_B) - VGroup(A, B, line).highlight(WHITE) + VGroup(A, B, line).set_color(WHITE) for dot, tex in (A, "A"), (B, "B"): label = TexMobject(tex).next_to(dot, DOWN) dot.add(label) @@ -400,7 +400,7 @@ class GraphCarTrajectory(GraphScene): t_dot.move_to(self.x_axis_label_mob) t_dot.set_fill(opacity = 0) dashed_h = DashedLine(*h_line.get_start_and_end()) - dashed_h.highlight(h_line.get_color()) + dashed_h.set_color(h_line.get_color()) brace = Brace(dashed_h, RIGHT) brace_text = brace.get_text("Distance traveled") self.play(t_dot.restore) @@ -423,7 +423,7 @@ class GraphCarTrajectory(GraphScene): s = s_of_t[0] d = TexMobject("d") d.move_to(s, DOWN) - d.highlight(DISTANCE_COLOR) + d.set_color(DISTANCE_COLOR) self.play(Write(s_of_t)) self.wait() @@ -690,7 +690,7 @@ class SnapshotOfACar(Scene): run_time = 2, rate_func = rush_into )) - car.get_tires().highlight(GREY) + car.get_tires().set_color(GREY) speed_lines.next_to(car, LEFT) self.add(speed_lines) self.play( @@ -726,7 +726,7 @@ class CompareTwoTimes(Scene): Line(FRAME_X_RADIUS*LEFT, RIGHT), Line(RIGHT+FRAME_Y_RADIUS*UP, RIGHT+FRAME_Y_RADIUS*DOWN), ) - dividers.highlight(GREY) + dividers.set_color(GREY) self.add(dividers, state1) self.wait() @@ -755,11 +755,11 @@ class CompareTwoTimes(Scene): VGroup( VGroup(*formula[1:1+ed_len]), VGroup(*formula[2+ed_len:2+ed_len+sd_len]) - ).highlight(DISTANCE_COLOR) + ).set_color(DISTANCE_COLOR) VGroup( VGroup(*formula[-2-seconds_len-et_len-st_len:-2-seconds_len-st_len]), VGroup(*formula[-1-seconds_len-st_len:-1-seconds_len]), - ).highlight(TIME_COLOR) + ).set_color(TIME_COLOR) down_arrow1 = TexMobject("\\Downarrow") down_arrow2 = TexMobject("\\Downarrow") @@ -800,12 +800,12 @@ class CompareTwoTimes(Scene): distance_label = brace.get_text( str(distance), " meters" ) - distance_label.highlight_by_tex(str(distance), DISTANCE_COLOR) + distance_label.set_color_by_tex(str(distance), DISTANCE_COLOR) brace.add(distance_label) time_label = TextMobject( "Time:", str(time), "seconds" ) - time_label.highlight_by_tex(str(time), TIME_COLOR) + time_label.set_color_by_tex(str(time), TIME_COLOR) time_label.next_to( VGroup(line, car), UP, aligned_edge = LEFT @@ -881,8 +881,8 @@ class VelocityAtIndividualPointsVsPairs(GraphCarTrajectory): self.play(ShowCreation(VGroup(line1, line2))) for line, brace, text in (dt_line, dt_brace, dt_text), (ds_line, ds_brace, ds_text): - brace.highlight(line.get_color()) - text.highlight(line.get_color()) + brace.set_color(line.get_color()) + text.set_color(line.get_color()) text.add_background_rectangle() self.play( ShowCreation(line), @@ -931,7 +931,7 @@ class SidestepParadox(Scene): new_words = TextMobject("over a small time") new_words.next_to(title[1], DOWN) - new_words.highlight(TIME_COLOR) + new_words.set_color(TIME_COLOR) self.add(title, car) self.play(Write(speedometer)) @@ -963,10 +963,10 @@ class CompareTwoVerySimilarTimes(CompareTwoTimes): ] ds_brace = Brace(ds_symbols, UP) ds_text = ds_brace.get_text("$ds$", buff = SMALL_BUFF) - ds_text.highlight(DISTANCE_COLOR) + ds_text.set_color(DISTANCE_COLOR) dt_brace = Brace(dt_symbols, DOWN) dt_text = dt_brace.get_text("$dt$", buff = SMALL_BUFF) - dt_text.highlight(TIME_COLOR) + dt_text.set_color(TIME_COLOR) self.play( GrowFromCenter(dt_brace), @@ -1026,7 +1026,7 @@ class DsOverDtGraphically(GraphCarTrajectory, ZoomedScene): brace = Brace(line, vect) text = brace.get_text("$d%s$"%char) text.next_to(brace, vect) - text.highlight(line.get_color()) + text.set_color(line.get_color()) subgroup = VGroup(line, brace, text) subgroup.scale(self.dt) result.add(subgroup) @@ -1067,8 +1067,8 @@ class DsOverDtGraphically(GraphCarTrajectory, ZoomedScene): #Show as function frac = TexMobject("\\frac{ds}{dt}") - VGroup(*frac[:2]).highlight(DISTANCE_COLOR) - VGroup(*frac[-2:]).highlight(TIME_COLOR) + VGroup(*frac[:2]).set_color(DISTANCE_COLOR) + VGroup(*frac[-2:]).set_color(TIME_COLOR) frac.next_to(self.input_to_graph_point(5.25), DOWN+RIGHT) rise_over_run = TexMobject( "=\\frac{\\text{rise}}{\\text{run}}" @@ -1078,7 +1078,7 @@ class DsOverDtGraphically(GraphCarTrajectory, ZoomedScene): of_t.next_to(frac, RIGHT, buff = SMALL_BUFF) dt_choice = TexMobject("dt = 0.01") - dt_choice.highlight(TIME_COLOR) + dt_choice.set_color(TIME_COLOR) dt_choice.next_to(of_t, UP, aligned_edge = LEFT, buff = LARGE_BUFF) @@ -1093,10 +1093,10 @@ class DsOverDtGraphically(GraphCarTrajectory, ZoomedScene): upper_dt = VGroup(*full_formula[5:7]) equals = full_formula[0] frac_line = full_formula[-3] - s_t_plus_dt.highlight(DISTANCE_COLOR) - s_t.highlight(DISTANCE_COLOR) - lower_dt.highlight(TIME_COLOR) - upper_dt.highlight(TIME_COLOR) + s_t_plus_dt.set_color(DISTANCE_COLOR) + s_t.set_color(DISTANCE_COLOR) + lower_dt.set_color(TIME_COLOR) + upper_dt.set_color(TIME_COLOR) velocity_graph = self.get_derivative_graph() t_tick_marks = VGroup(*[ @@ -1236,8 +1236,8 @@ class DefineTrueDerivative(Scene): title.to_edge(UP) lhs = TexMobject("\\frac{ds}{dt}(t) = ") - VGroup(*lhs[:2]).highlight(DISTANCE_COLOR) - VGroup(*lhs[3:5]).highlight(TIME_COLOR) + VGroup(*lhs[:2]).set_color(DISTANCE_COLOR) + VGroup(*lhs[3:5]).set_color(TIME_COLOR) lhs.shift(3*LEFT+UP) dt_rhs = self.get_fraction("dt") @@ -1282,13 +1282,13 @@ class DefineTrueDerivative(Scene): VGroup(*tex_mob[i1:i2]) for i1, i2 in zip(pl_cumsum, pl_cumsum[1:]) ]) - VGroup(*result[1:3]+result[4:6]).highlight(TIME_COLOR) + VGroup(*result[1:3]+result[4:6]).set_color(TIME_COLOR) return result def get_brace_and_text(self, deriv_frac): brace = Brace(VGroup(deriv_frac), DOWN) dt_to_zero = brace.get_text("$dt \\to 0$") - VGroup(*dt_to_zero[:2]).highlight(TIME_COLOR) + VGroup(*dt_to_zero[:2]).set_color(TIME_COLOR) return brace, dt_to_zero class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative): @@ -1319,7 +1319,7 @@ class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative): for dot in dots: dot.scale_in_place(0.5) secant_line = Line(*points) - secant_line.highlight(VELOCITY_COLOR) + secant_line.set_color(VELOCITY_COLOR) secant_line.scale_in_place( self.secant_line_length/secant_line.get_length() ) @@ -1328,7 +1328,7 @@ class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative): dt_line = Line(points[0], interim_point, color = TIME_COLOR) ds_line = Line(interim_point, points[1], color = DISTANCE_COLOR) dt = TexMobject("dt") - dt.highlight(TIME_COLOR) + dt.set_color(TIME_COLOR) if dt.get_width() > dt_line.get_width(): dt.scale( dt_line.get_width()/dt.get_width(), @@ -1336,7 +1336,7 @@ class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative): ) dt.next_to(dt_line, DOWN, buff = SMALL_BUFF) ds = TexMobject("ds") - ds.highlight(DISTANCE_COLOR) + ds.set_color(DISTANCE_COLOR) if ds.get_height() > ds_line.get_height(): ds.scale( ds_line.get_height()/ds.get_height(), @@ -1384,8 +1384,8 @@ class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative): def add_derivative_definition(self, target_upper_left): deriv_frac = self.get_fraction("dt") lhs = TexMobject("\\frac{ds}{dt}(t)=") - VGroup(*lhs[:2]).highlight(DISTANCE_COLOR) - VGroup(*lhs[3:5]).highlight(TIME_COLOR) + VGroup(*lhs[:2]).set_color(DISTANCE_COLOR) + VGroup(*lhs[3:5]).set_color(TIME_COLOR) lhs.next_to(deriv_frac, LEFT) brace, text = self.get_brace_and_text(deriv_frac) deriv_def = VGroup(lhs, deriv_frac, brace, text) @@ -1484,8 +1484,8 @@ class SecantLineToTangentLine(GraphCarTrajectory, DefineTrueDerivative): for s in "``infinitely small''", "0" ] for phrase in phrases: - phrase[0].highlight(TIME_COLOR) - phrase[2].highlight(RED) + phrase[0].set_color(TIME_COLOR) + phrase[2].set_color(RED) phrases[0].shift(DOWN+2*RIGHT) phrases[1].next_to(phrases[0], DOWN, aligned_edge = LEFT) @@ -1516,7 +1516,7 @@ class UseOfDImpliesApproaching(TeacherStudentsScene): announces that $dt \\to 0$ """) - VGroup(*statement[-4:-2]).highlight(TIME_COLOR) + VGroup(*statement[-4:-2]).set_color(TIME_COLOR) self.teacher_says(statement) self.change_student_modes(*["pondering"]*3) self.wait(4) @@ -1641,15 +1641,15 @@ class TCubedExample(SecantLineToTangentLine): lhs.next_to(ds_dt_group, UP+RIGHT, buff = MED_LARGE_BUFF) ds = VGroup(*lhs[:2]) dt = VGroup(*lhs[3:5]) - ds.highlight(DISTANCE_COLOR) - dt.highlight(TIME_COLOR) + ds.set_color(DISTANCE_COLOR) + dt.set_color(TIME_COLOR) ds.target, dt.target = ds_dt_group[3:5] for mob in ds, dt: mob.save_state() mob.move_to(mob.target) nonzero_size = TextMobject("Nonzero size...for now") - nonzero_size.highlight(TIME_COLOR) + nonzero_size.set_color(TIME_COLOR) nonzero_size.next_to(dt, DOWN+2*RIGHT, buff = LARGE_BUFF) arrow = Arrow(nonzero_size, dt) @@ -1657,8 +1657,8 @@ class TCubedExample(SecantLineToTangentLine): "\\frac{s(2+dt) - s(2)}{dt}" ) rhs.next_to(lhs[-1]) - VGroup(*rhs[4:6]).highlight(TIME_COLOR) - VGroup(*rhs[-2:]).highlight(TIME_COLOR) + VGroup(*rhs[4:6]).set_color(TIME_COLOR) + VGroup(*rhs[-2:]).set_color(TIME_COLOR) numerator = VGroup(*rhs[:-3]) non_numerator = VGroup(*rhs[-3:]) numerator_non_minus = VGroup(*numerator) @@ -1688,7 +1688,7 @@ class TCubedExample(SecantLineToTangentLine): self.play(ShowCreation(v_lines[1])) self.wait() self.play( - v_lines[0].highlight, YELLOW, + v_lines[0].set_color, YELLOW, rate_func = there_and_back ) self.wait() @@ -1782,7 +1782,7 @@ class TCubedExample(SecantLineToTangentLine): VGroup(*terms[3][1:3]), terms[-1] ] - VGroup(*dts).highlight(TIME_COLOR) + VGroup(*dts).set_color(TIME_COLOR) two_cubed_terms = terms[0], terms[4] @@ -1794,7 +1794,7 @@ class TCubedExample(SecantLineToTangentLine): self.play(*it.chain(*[ [ tc.scale, 1.3, tc.get_corner(vect), - tc.highlight, RED + tc.set_color, RED ] for tc, vect in zip( two_cubed_terms, @@ -1819,7 +1819,7 @@ class TCubedExample(SecantLineToTangentLine): ) new_exp = TexMobject("2").replace(faders[-1], dim_to_match = 1) self.play( - faders.highlight, BLACK, + faders.set_color, BLACK, FadeIn(new_exp), run_time = 2, ) @@ -1841,7 +1841,7 @@ class TCubedExample(SecantLineToTangentLine): ) brace = Brace(VGroup(terms[2][0], terms[3][-1]), DOWN) brace_text = brace.get_text("Contains $dt$") - VGroup(*brace_text[-2:]).highlight(TIME_COLOR) + VGroup(*brace_text[-2:]).set_color(TIME_COLOR) self.play(ShowCreation(arrow)) self.wait() @@ -1894,7 +1894,7 @@ class TCubedExample(SecantLineToTangentLine): ) approach_text = TextMobject("As $dt \\to 0$") approach_text.next_to(arrow.get_center(), RIGHT) - VGroup(*approach_text[2:4]).highlight(TIME_COLOR) + VGroup(*approach_text[2:4]).set_color(TIME_COLOR) self.play( ShowCreation(arrow), Write(approach_text) @@ -1905,7 +1905,7 @@ class TCubedExample(SecantLineToTangentLine): #Ephasize slope v_line = self.vertical_lines[0] slope_text = TextMobject("Slope = $12$") - slope_text.highlight(VELOCITY_COLOR) + slope_text.set_color(VELOCITY_COLOR) slope_text.next_to(v_line.get_end(), LEFT) self.play(Write(slope_text)) self.play( @@ -1963,7 +1963,7 @@ class TCubedExample(SecantLineToTangentLine): for mob in numerator, denominator, self.approach_text, self.deriv_term: mob.generate_target() mob.target.scale_in_place(1.2) - mob.target.highlight(MAROON_B) + mob.target.set_color(MAROON_B) self.play( MoveToTarget( mob, rate_func = there_and_back, @@ -1997,11 +1997,11 @@ class YouWouldntDoThisEveryTime(TeacherStudentsScene): this_video = series[1] next_video = series[2] this_video.save_state() - this_video.highlight(YELLOW) + this_video.set_color(YELLOW) self.play(FadeIn(series, submobject_mode = "lagged_start")) self.play( this_video.restore, - next_video.highlight, YELLOW, + next_video.set_color, YELLOW, next_video.shift, 0.5*DOWN ) self.wait(2) @@ -2015,9 +2015,9 @@ class ContrastConcreteDtWithLimit(Scene): If $dt$ has a specific size. """) - VGroup(*l_title[2:4]).highlight(TIME_COLOR) + VGroup(*l_title[2:4]).set_color(TIME_COLOR) r_title = TexMobject("dt \\to 0") - VGroup(*r_title[:2]).highlight(TIME_COLOR) + VGroup(*r_title[:2]).set_color(TIME_COLOR) for title, vect in (l_title, LEFT), (r_title, RIGHT): title.to_edge(UP) title.shift(FRAME_X_RADIUS*vect/2) @@ -2039,22 +2039,22 @@ class ContrastConcreteDtWithLimit(Scene): l_formula[21:23], l_formula[27:29], l_formula[35:37], - )).highlight(TIME_COLOR) + )).set_color(TIME_COLOR) l_formula.scale_to_fit_width(FRAME_X_RADIUS-MED_LARGE_BUFF) l_formula.to_edge(LEFT) l_brace = Brace(l_formula, DOWN) l_text = l_brace.get_text("Messy") - l_text.highlight(RED) + l_text.set_color(RED) r_formula = TexMobject( "\\frac{d(t^3)}{dt} = 3t^2" ) - VGroup(*r_formula[6:8]).highlight(TIME_COLOR) + VGroup(*r_formula[6:8]).set_color(TIME_COLOR) r_formula.shift(FRAME_X_RADIUS*RIGHT/2) r_brace = Brace(r_formula, DOWN) r_text = r_brace.get_text("Simple") - r_text.highlight(GREEN) + r_text.set_color(GREEN) triplets = [ (l_formula, l_brace, l_text), @@ -2165,7 +2165,7 @@ class ParadoxAtTEquals0(TCubedExample): "At time $t=0$,", "is \\\\ the car moving?" ) - VGroup(*question[0][-4:-1]).highlight(RED) + VGroup(*question[0][-4:-1]).set_color(RED) question.next_to( self.coords_to_point(0, 10), RIGHT @@ -2189,9 +2189,9 @@ class ParadoxAtTEquals0(TCubedExample): "= 0", "\\frac{\\text{m}}{\\text{s}}", ) - VGroup(*derivative[0][:2]).highlight(DISTANCE_COLOR) - VGroup(*derivative[0][3:5]).highlight(TIME_COLOR) - derivative[1][3].highlight(RED) + VGroup(*derivative[0][:2]).set_color(DISTANCE_COLOR) + VGroup(*derivative[0][3:5]).set_color(TIME_COLOR) + derivative[1][3].set_color(RED) derivative[-1].scale_in_place(0.7) derivative.to_edge(RIGHT, buff = LARGE_BUFF) derivative.shift(2*UP) @@ -2298,7 +2298,7 @@ class ParadoxAtTEquals0(TCubedExample): for word in change_word, moment_word: self.play( word.scale_in_place, 1.2, - word.highlight, YELLOW, + word.set_color, YELLOW, rate_func = there_and_back, run_time = 1.5 ) @@ -2348,7 +2348,7 @@ class TinyMovement(ZoomedScene): brace = Brace(Line(ORIGIN, RIGHT)) distance_label = TexMobject(self.distance_label) distance_label.next_to(brace, DOWN) - distance_label.highlight(DISTANCE_COLOR) + distance_label.set_color(DISTANCE_COLOR) brace.add(distance_label) brace.scale(self.distance) brace.next_to(dots, DOWN, buff = self.distance/5) @@ -2362,7 +2362,7 @@ class TinyMovement(ZoomedScene): start_time = TexMobject("0") end_time = TexMobject(self.time_label) for time in start_time, end_time: - time.highlight(TIME_COLOR) + time.set_color(TIME_COLOR) time.next_to(time_label, RIGHT) self.add(car, time_label, start_time) @@ -2418,9 +2418,9 @@ class TinyMovement(ZoomedScene): np.cumsum(lengths)[1:], ) ]) - result[1].highlight(DISTANCE_COLOR) - result[3].highlight(TIME_COLOR) - result[5].highlight(VELOCITY_COLOR) + result[1].set_color(DISTANCE_COLOR) + result[3].set_color(TIME_COLOR) + result[5].set_color(VELOCITY_COLOR) return result @@ -2429,7 +2429,7 @@ class NextVideos(TeacherStudentsScene): series = VideoSeries() series.scale_to_fit_width(FRAME_WIDTH - 1) series.to_edge(UP) - series[1].highlight(YELLOW) + series[1].set_color(YELLOW) self.add(series) brace = Brace(VGroup(*series[2:6])) @@ -2576,7 +2576,7 @@ class Promotion(PiCreatureScene): self.play(ShowCreation(url_rect)) self.play( FadeOut(url_rect), - url.get_part_by_tex("3blue1brown").highlight, BLUE, + url.get_part_by_tex("3blue1brown").set_color, BLUE, ) self.wait(3) @@ -2603,8 +2603,8 @@ class Thumbnail(SecantLineToTangentLine): randy.shift(RIGHT) deriv = TexMobject("\\frac{ds}{dt}(t)") - VGroup(*deriv[:2]).highlight(DISTANCE_COLOR) - VGroup(*deriv[3:5]).highlight(TIME_COLOR) + VGroup(*deriv[:2]).set_color(DISTANCE_COLOR) + VGroup(*deriv[3:5]).set_color(TIME_COLOR) deriv.scale(3) # deriv.next_to(randy, RIGHT, buff = 2) deriv.to_edge(RIGHT, buff = LARGE_BUFF) diff --git a/old_projects/eoc/chapter3.py b/old_projects/eoc/chapter3.py index 8c784864..234697e4 100644 --- a/old_projects/eoc/chapter3.py +++ b/old_projects/eoc/chapter3.py @@ -133,7 +133,7 @@ class ContrastAbstractAndConcrete(Scene): for spring in compact_spring, extended_spring: spring.scale(0.5) spring.rotate(np.pi/6, UP) - spring.highlight(GREY) + spring.set_color(GREY) spring.next_to(ORIGIN, RIGHT) spring.shift( alignement_mob.get_center()[1]*UP + SMALL_BUFF*RIGHT \ @@ -286,8 +286,8 @@ class DerivativeOfXSquaredAsGraph(GraphScene, ZoomedScene, PiCreatureScene): ] df_dx = TexMobject("\\frac{df}{dx} ?") - VGroup(*df_dx[:2]).highlight(ss_group.df_line.get_color()) - VGroup(*df_dx[3:5]).highlight(ss_group.dx_line.get_color()) + VGroup(*df_dx[:2]).set_color(ss_group.df_line.get_color()) + VGroup(*df_dx[3:5]).set_color(ss_group.dx_line.get_color()) df_dx.next_to( self.input_to_graph_point(self.start_x, self.graph), DOWN+RIGHT, @@ -408,7 +408,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): self.introduce_square() self.increase_area() self.write_df_equation() - self.highlight_shapes() + self.set_color_shapes() self.examine_thin_rectangles() self.examine_tiny_square() self.show_smaller_dx() @@ -493,7 +493,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): buff = SMALL_BUFF, ) text = brace.get_text("$dx$", buff = SMALL_BUFF) - text.highlight(self.dx_color) + text.set_color(self.dx_color) brace.add(text) little_braces.add(brace) @@ -533,7 +533,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): corner_square = self.corner_square df_equation = VGroup( - TexMobject("df").highlight(right_rect.get_color()), + TexMobject("df").set_color(right_rect.get_color()), TexMobject("="), right_rect.copy(), TextMobject("+"), @@ -575,7 +575,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): self.df_equation = df_equation - def highlight_shapes(self): + def set_color_shapes(self): df, equals, r1, plus1, r2, plus2, s = self.df_equation tups = [ @@ -585,7 +585,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): for tup in tups: self.play( *it.chain(*[ - [m.scale_in_place, 1.2, m.highlight, RED] + [m.scale_in_place, 1.2, m.set_color, RED] for m in tup ]), rate_func = there_and_back @@ -598,11 +598,11 @@ class NudgeSideLengthOfSquare(PiCreatureScene): rects = VGroup(r1, r2) thin_rect_brace = Brace(rects, DOWN) text = thin_rect_brace.get_text("$2x \\, dx$") - VGroup(*text[-2:]).highlight(self.dx_color) + VGroup(*text[-2:]).set_color(self.dx_color) text.save_state() alt_text = thin_rect_brace.get_text("$2(3)(0.01)$") - alt_text[2].highlight(self.three_color) - VGroup(*alt_text[-5:-1]).highlight(self.dx_color) + alt_text[2].set_color(self.three_color) + VGroup(*alt_text[-5:-1]).set_color(self.dx_color) example_value = TexMobject("=0.06") example_value.next_to(alt_text, DOWN) @@ -627,7 +627,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): group.generate_target() for submob in group.target: number = TexMobject(tex) - number.highlight(color) + number.set_color(color) number.move_to(submob, LEFT) Transform(submob, number).update(1) self.play(MoveToTarget(xs)) @@ -655,7 +655,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): def examine_tiny_square(self): text = TexMobject("dx^2") - VGroup(*text[:2]).highlight(self.dx_color) + VGroup(*text[:2]).set_color(self.dx_color) text.next_to(self.df_equation[-1], UP) text.save_state() alt_text = TextMobject("0.0001") @@ -670,7 +670,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): ) for submob in self.dxs.target: number = TexMobject("0.01") - number.highlight(self.dx_color) + number.set_color(self.dx_color) number.move_to(submob, LEFT) Transform(submob, number).update(1) self.play(MoveToTarget(self.dxs)) @@ -724,7 +724,7 @@ class NudgeSideLengthOfSquare(PiCreatureScene): circle.scale_in_place(1.5) safe_to_ignore = TextMobject("Safe to ignore") safe_to_ignore.next_to(circle, DOWN, aligned_edge = LEFT) - safe_to_ignore.highlight(circle.get_color()) + safe_to_ignore.set_color(circle.get_color()) self.play(ShowCreation(circle)) self.play( @@ -809,8 +809,8 @@ class ChangeInAreaOverChangeInX(Scene): fractions = [] for pair in ("Change in area", "Change in $x$"), ("$d(x^2)$", "$dx$"): top, bottom = map(TextMobject, pair) - top.highlight(YELLOW) - bottom.highlight(BLUE_B) + top.set_color(YELLOW) + bottom.set_color(BLUE_B) frac_line = TexMobject("-") frac_line.stretch_to_fit_width(top.get_width()) top.next_to(frac_line, UP, SMALL_BUFF) @@ -932,7 +932,7 @@ class NudgeSideLengthOfCube(Scene): self.corner_cube.copy() ) df, equals, faces, plus1, bars, plus2, corner_cube = df_equation - df.highlight(self.df_color) + df.set_color(self.df_color) for three_d_mob in faces, bars, corner_cube: three_d_mob.scale(self.small_piece_scaling_factor) # self.pose_3d_mobject(three_d_mob) @@ -963,8 +963,8 @@ class NudgeSideLengthOfCube(Scene): self.wait() for submob, sides in zip(x_squared_dx, [face[0], VGroup(*face[1:])]): self.play( - submob.highlight, RED, - sides.highlight, RED, + submob.set_color, RED, + sides.set_color, RED, rate_func = there_and_back ) self.wait() @@ -1045,7 +1045,7 @@ class NudgeSideLengthOfCube(Scene): self.play( FadeOut(frac_line2), FadeOut(dx_below_dx_squared), - dx_squared[-1].highlight, BLACK, + dx_squared[-1].set_color, BLACK, inner_dx.next_to, extra_stuff[0], RIGHT, SMALL_BUFF ) self.wait() @@ -1072,7 +1072,7 @@ class NudgeSideLengthOfCube(Scene): piece.target.rotate_in_place( np.pi/12, piece.get_center()-self.cube.get_center() ) - piece.target.highlight(RED) + piece.target.set_color(RED) self.play(*map(MoveToTarget, start_pieces), rate_func = wiggle) self.wait() added_anims = [] @@ -1325,7 +1325,7 @@ class PatternForPowerRule(PiCreatureScene): "\\frac{d(x^%d)}{dx} = "%exponent, "%d x^{%d}"%(exponent, exponent-1) ) - VGroup(*derivative[0][2:4]).highlight(color) + VGroup(*derivative[0][2:4]).set_color(color) derivatives.add(derivative) derivatives.arrange_submobjects( DOWN, aligned_edge = LEFT, @@ -1408,7 +1408,7 @@ class PatternForPowerRule(PiCreatureScene): "x^", str(exp-1) ) - form.highlight(color) + form.set_color(color) form.to_corner(UP+RIGHT, buff = LARGE_BUFF) lhs = VGroup(*form[:2]) lhs_copy = lhs.copy() @@ -1455,10 +1455,10 @@ class PowerRuleAlgebra(Scene): *paren_strings*3+["\\cdots"]+paren_strings ) - x_to_n.highlight(self.x_color) + x_to_n.set_color(self.x_color) for mob in x_dx_to_n, full_product: - mob.highlight_by_tex("dx", self.dx_color) - mob.highlight_by_tex("x", self.x_color) + mob.set_color_by_tex("dx", self.dx_color) + mob.set_color_by_tex("x", self.x_color) nudge_group = VGroup(x_to_n, down_arrow, x_dx_to_n) nudge_group.arrange_submobjects(DOWN) @@ -1506,15 +1506,15 @@ class PowerRuleAlgebra(Scene): x_to_n = TexMobject("x^n") extra_stuff = TexMobject("+(\\text{Multiple of }\\, dx^2)") # extra_stuff.scale(0.8) - VGroup(*extra_stuff[-4:-2]).highlight(self.dx_color) + VGroup(*extra_stuff[-4:-2]).set_color(self.dx_color) x_to_n.next_to(equals, RIGHT, align_using_submobjects = True) - x_to_n.highlight(self.x_color) + x_to_n.set_color(self.x_color) xs_copy = xs.copy() full_product.save_state() - self.play(full_product.highlight, WHITE) - self.play(xs_copy.highlight, self.x_color) + self.play(full_product.set_color, WHITE) + self.play(xs_copy.set_color, self.x_color) self.play( Write(equals), Transform(xs_copy, x_to_n) @@ -1565,8 +1565,8 @@ class PowerRuleAlgebra(Scene): xs_copy = xs.copy() xs_copy.remove(xs_copy[dx_index]) self.play( - dx_copy.highlight, self.dx_color, - xs_copy.highlight, self.x_color, + dx_copy.set_color, self.dx_color, + xs_copy.set_color, self.x_color, rate_func = squish_rate_func(smooth, 0, 0.5) ) @@ -1598,8 +1598,8 @@ class PowerRuleAlgebra(Scene): all_linear_terms.target.scale(0.7) brace = Brace(all_linear_terms.target, UP) compact = TexMobject("+\\,", "n", "x^{n-1}", "\\,dx") - compact.highlight_by_tex("x^{n-1}", self.x_color) - compact.highlight_by_tex("\\,dx", self.dx_color) + compact.set_color_by_tex("x^{n-1}", self.x_color) + compact.set_color_by_tex("\\,dx", self.dx_color) compact.next_to(brace, UP) brace.add(compact) derivative_term = VGroup(*compact[1:3]) @@ -1810,7 +1810,7 @@ class OneOverX(PiCreatureScene, GraphScene): df_brace.add(df_label) negative = TextMobject("Negative") - negative.highlight(RED) + negative.set_color(RED) negative.next_to(df_label, UP+RIGHT) negative.shift(RIGHT) negative_arrow = Arrow( @@ -2127,11 +2127,11 @@ class SquareRootOfX(Scene): brace.add(tex) area_increase = TextMobject("$dx$ = New area") - area_increase.highlight(bigger_square.get_color()) + area_increase.set_color(bigger_square.get_color()) area_increase.next_to(square, RIGHT, 4) question = TexMobject("\\frac{d\\sqrt{x}}{dx} = ???") - VGroup(*question[5:7]).highlight(bigger_square.get_color()) + VGroup(*question[5:7]).set_color(bigger_square.get_color()) question.next_to( area_increase, DOWN, aligned_edge = LEFT, @@ -2165,7 +2165,7 @@ class NameUnitCircle(Scene): def construct(self): words = TextMobject("Unit circle") words.scale(2) - words.highlight(BLUE) + words.set_color(BLUE) self.play(Write(words)) self.wait() @@ -2177,8 +2177,8 @@ class DerivativeOfSineIsSlope(Scene): ) tex.scale_to_fit_width(FRAME_WIDTH-1) tex.to_edge(DOWN) - VGroup(*tex[0][2:8]).highlight(BLUE) - VGroup(*tex[1][-9:]).highlight(BLUE) + VGroup(*tex[0][2:8]).set_color(BLUE) + VGroup(*tex[1][-9:]).set_color(BLUE) self.play(Write(tex, run_time = 2)) self.wait() @@ -2222,7 +2222,7 @@ class IntroduceUnitCircleWithSine(GraphScene): def introduce_unit_circle(self): circle = self.get_unit_circle() radial_line = Line(ORIGIN, self.unit_length*RIGHT) - radial_line.highlight(RED) + radial_line.set_color(RED) if self.include_radial_line_dot: dot = Dot() dot.move_to(radial_line.get_end()) @@ -2255,11 +2255,11 @@ class IntroduceUnitCircleWithSine(GraphScene): self.example_radians, radius = self.unit_length, color = line.get_color(), ) - arc_copy = arc.copy().highlight(WHITE) + arc_copy = arc.copy().set_color(WHITE) brace = Brace(line, RIGHT) brace_text = brace.get_text("$\\theta%s$"%self.theta_label) - brace_text.highlight(line.get_color()) + brace_text.set_color(line.get_color()) theta_copy = brace_text[0].copy() self.play( @@ -2301,7 +2301,7 @@ class IntroduceUnitCircleWithSine(GraphScene): v_line = self.line_class(radial_line.get_end(), drop_point) brace = Brace(v_line, RIGHT) brace_text = brace.get_text("$\\sin(\\theta)$") - brace_text[-2].highlight(YELLOW) + brace_text[-2].set_color(YELLOW) self.play(ShowCreation(v_line)) self.play( @@ -2327,7 +2327,7 @@ class IntroduceUnitCircleWithSine(GraphScene): ) return v_line filler_arc = self.circle.copy() - filler_arc.highlight(YELLOW) + filler_arc.set_color(YELLOW) curr_arc_portion = self.example_radians/(2*np.pi) filler_portion = 1 - curr_arc_portion filler_arc.pointwise_become_partial(filler_arc, curr_arc_portion, 1) @@ -2444,7 +2444,7 @@ class DerivativeIntuitionFromSineGraph(GraphScene): words.get_bottom(), deriv_graph.point_from_proportion(0.45) ) - VGroup(words, arrow).highlight(deriv_graph.get_color()) + VGroup(words, arrow).set_color(deriv_graph.get_color()) self.play( Write(words), ShowCreation(arrow) @@ -2490,7 +2490,7 @@ class DerivativeIntuitionFromSineGraph(GraphScene): label = TexMobject("%d\\pi"%x) label.next_to(self.coords_to_point(x*np.pi, 0), DOWN, MED_LARGE_BUFF) self.add(label) - self.x_axis_label_mob.highlight(YELLOW) + self.x_axis_label_mob.set_color(YELLOW) class LookToFunctionsMeaning(TeacherStudentsScene): def construct(self): @@ -2557,7 +2557,7 @@ class DerivativeFromZoomingInOnSine(IntroduceUnitCircleWithSine, ZoomedScene): d_theta_brace.get_center(), d_theta_brace.direction, MED_LARGE_BUFF ) - d_theta_label.highlight(d_theta_arc.get_color()) + d_theta_label.set_color(d_theta_arc.get_color()) group = VGroup(d_theta_arc, d_theta_brace, d_theta_label) group.scale(1./self.zoom_factor) @@ -2574,7 +2574,7 @@ class DerivativeFromZoomingInOnSine(IntroduceUnitCircleWithSine, ZoomedScene): d_sine_brace.scale_to_fit_height(d_sine_line.get_height()) d_sine_brace.next_to(d_sine_line, LEFT, buff = SMALL_BUFF/self.zoom_factor) d_sine = TexMobject("d(\\sin(\\theta))") - d_sine.highlight(d_sine_line.get_color()) + d_sine.set_color(d_sine_line.get_color()) d_sine.scale_to_fit_width(1.5*self.d_theta*self.unit_length) d_sine.next_to(d_sine_brace, LEFT, SMALL_BUFF/self.zoom_factor) @@ -2608,7 +2608,7 @@ class DerivativeFromZoomingInOnSine(IntroduceUnitCircleWithSine, ZoomedScene): self.radial_line.get_end()[0]*RIGHT, ) for triangle in little_triangle, big_triangle: - triangle.highlight(GREEN) + triangle.set_color(GREEN) triangle.set_fill(GREEN, opacity = 0.5) big_triangle_copy = big_triangle.copy() big_triangle_copy.next_to(ORIGIN, UP+LEFT) @@ -2628,12 +2628,12 @@ class DerivativeFromZoomingInOnSine(IntroduceUnitCircleWithSine, ZoomedScene): (UP+LEFT, DOWN+LEFT) ] ]) - little_triangle_lines.highlight(little_triangle.get_color()) + little_triangle_lines.set_color(little_triangle.get_color()) self.play(DrawBorderThenFill(little_triangle)) self.play( little_triangle.scale, 2, little_triangle.get_corner(DOWN+RIGHT), - little_triangle.highlight, YELLOW, + little_triangle.set_color, YELLOW, rate_func = there_and_back ) self.wait() @@ -2646,7 +2646,7 @@ class DerivativeFromZoomingInOnSine(IntroduceUnitCircleWithSine, ZoomedScene): )) self.play( group.scale, 1.2, group.get_corner(DOWN+RIGHT), - group.highlight, YELLOW, + group.set_color, YELLOW, rate_func = there_and_back, ) self.wait() @@ -2685,18 +2685,18 @@ class DerivativeFromZoomingInOnSine(IntroduceUnitCircleWithSine, ZoomedScene): ) self.play( new_angle_label.scale_in_place, 2, - new_angle_label.highlight, RED, + new_angle_label.set_color, RED, rate_func = there_and_back ) self.wait() def analyze_ratios(self): d_ratio = TexMobject("\\frac{d(\\sin(\\theta))}{d\\theta} = ") - VGroup(*d_ratio[:9]).highlight(GREEN) - VGroup(*d_ratio[10:12]).highlight(MAROON_B) + VGroup(*d_ratio[:9]).set_color(GREEN) + VGroup(*d_ratio[10:12]).set_color(MAROON_B) trig_ratio = TexMobject("\\frac{\\text{Adj.}}{\\text{Hyp.}}") - VGroup(*trig_ratio[:4]).highlight(GREEN) - VGroup(*trig_ratio[5:9]).highlight(MAROON_B) + VGroup(*trig_ratio[:4]).set_color(GREEN) + VGroup(*trig_ratio[5:9]).set_color(MAROON_B) cos = TexMobject("= \\cos(\\theta)") cos.add_background_rectangle() @@ -2715,7 +2715,7 @@ class DerivativeFromZoomingInOnSine(IntroduceUnitCircleWithSine, ZoomedScene): class TryWithCos(Scene): def construct(self): words = TextMobject("What about $\\cos(\\theta)$?") - words.highlight(YELLOW) + words.set_color(YELLOW) self.play(Write(words)) self.wait() @@ -2745,7 +2745,7 @@ class NextVideo(TeacherStudentsScene): ] ) self.play( - next_video.highlight, YELLOW, + next_video.set_color, YELLOW, next_video.shift, MED_LARGE_BUFF*DOWN ) self.wait() @@ -2825,8 +2825,8 @@ class Thumbnail(NudgeSideLengthOfCube): formula = TexMobject( "\\frac{d(x^3)}{dx} = 3x^2" ) - VGroup(*formula[:5]).highlight(YELLOW) - VGroup(*formula[-3:]).highlight(GREEN_B) + VGroup(*formula[:5]).set_color(YELLOW) + VGroup(*formula[-3:]).set_color(GREEN_B) formula.scale_to_fit_width(FRAME_X_RADIUS-1) formula.to_edge(RIGHT) self.add(formula) diff --git a/old_projects/eoc/chapter4.py b/old_projects/eoc/chapter4.py index 9d92c2d1..94e171d3 100644 --- a/old_projects/eoc/chapter4.py +++ b/old_projects/eoc/chapter4.py @@ -77,7 +77,7 @@ class TransitionFromLastVideo(TeacherStudentsScene): self.add(series) self.play( FadeIn(brace), - last_video.highlight, YELLOW + last_video.set_color, YELLOW ) for rule in simple_rules: self.play( @@ -95,7 +95,7 @@ class TransitionFromLastVideo(TeacherStudentsScene): last_video.restore, Animation(simple_rules), brace.next_to, this_video, DOWN, - this_video.highlight, YELLOW + this_video.set_color, YELLOW ) #Combination rules @@ -115,10 +115,10 @@ class TransitionFromLastVideo(TeacherStudentsScene): self.play(inner_func.shift, 0.5*UP) added_anims = [ inner_func.shift, 0.5*DOWN, - inner_func.highlight, YELLOW + inner_func.set_color, YELLOW ] self.play( - interior.highlight, YELLOW, + interior.set_color, YELLOW, *added_anims, submobject_mode = "lagged_start" ) @@ -164,7 +164,7 @@ class TransitionFromLastVideo(TeacherStudentsScene): self.get_teacher().change_mode, "plain", ) self.wait() - answer[1].highlight(GREEN) + answer[1].set_color(GREEN) self.play( Transform(question, answer), self.get_teacher().change_mode, "hooray", @@ -211,12 +211,12 @@ class TransitionFromLastVideo(TeacherStudentsScene): ]) for word, part in zip(words, reversed(parts)): - word.highlight(YELLOW) + word.set_color(YELLOW) word.next_to(monster, UP) self.play( FadeIn(word), part.scale_in_place, 1.2, - part.highlight, YELLOW + part.set_color, YELLOW ) self.wait() self.play(*map(FadeOut, [word, part])) @@ -246,7 +246,7 @@ class DampenedSpring(Scene): for spring in compact_spring, extended_spring: spring.scale(0.5) spring.rotate(np.pi/6, UP) - spring.highlight(GREY) + spring.set_color(GREY) spring.shift(-spring.points[0] + 3*LEFT) moving_spring = compact_spring.copy() @@ -299,10 +299,10 @@ class PreSumRuleDiscussion(Scene): "=", "\\frac{dg}{dx}", "+", "\\frac{dh}{dx}" ) for formula in specific, general: - formula[1].highlight(SINE_COLOR) - formula[6].highlight(SINE_COLOR) - formula[3].highlight(X_SQUARED_COLOR) - formula[8].highlight(X_SQUARED_COLOR) + formula[1].set_color(SINE_COLOR) + formula[6].set_color(SINE_COLOR) + formula[3].set_color(X_SQUARED_COLOR) + formula[8].set_color(X_SQUARED_COLOR) VGroup(specific, general).arrange_submobjects(DOWN, buff = LARGE_BUFF) #Add on rules @@ -326,7 +326,7 @@ class PreSumRuleDiscussion(Scene): else: part = specific[i] self.play( - part.highlight, YELLOW, + part.set_color, YELLOW, part.scale_in_place, 1.2, rate_func = there_and_back ) @@ -361,9 +361,9 @@ class SumRule(GraphScene): def write_function(self): func_mob = TexMobject("f(x)", "=", "\\sin(x)", "+", "x^2") func_mob.scale(self.tex_scale_factor) - func_mob.highlight_by_tex("f(x)", SUM_COLOR) - func_mob.highlight_by_tex("\\sin(x)", SINE_COLOR) - func_mob.highlight_by_tex("x^2", X_SQUARED_COLOR) + func_mob.set_color_by_tex("f(x)", SUM_COLOR) + func_mob.set_color_by_tex("\\sin(x)", SINE_COLOR) + func_mob.set_color_by_tex("x^2", X_SQUARED_COLOR) func_mob.to_corner(UP+LEFT) self.add(func_mob) @@ -504,7 +504,7 @@ class SumRule(GraphScene): buff = SMALL_BUFF, min_num_quads = 2, ) - line.brace.highlight(line.get_color()) + line.brace.set_color(line.get_color()) line.brace.add_background_rectangle() line.brace_text = line.brace.get_text("$%s$"%tex) line.brace_text.scale( @@ -574,9 +574,9 @@ class SumRule(GraphScene): df, equals, d_sine, plus, d_x_squared = deriv_mob = TexMobject( "df", "=", "d(\\sin(x))", "+", "d(x^2)" ) - df.highlight(SUM_COLOR) - d_sine.highlight(SINE_COLOR) - d_x_squared.highlight(X_SQUARED_COLOR) + df.set_color(SUM_COLOR) + d_sine.set_color(SINE_COLOR) + d_x_squared.set_color(X_SQUARED_COLOR) deriv_mob.scale(self.tex_scale_factor) deriv_mob.next_to( self.func_mob, DOWN, @@ -628,9 +628,9 @@ class SumRule(GraphScene): expanded_deriv = TexMobject( "df", "=", "\\cos(x)", "\\,dx", "+", "2x", "\\,dx" ) - expanded_deriv.highlight_by_tex("df", SUM_COLOR) - VGroup(*expanded_deriv[2:4]).highlight(SINE_COLOR) - VGroup(*expanded_deriv[5:7]).highlight(X_SQUARED_COLOR) + expanded_deriv.set_color_by_tex("df", SUM_COLOR) + VGroup(*expanded_deriv[2:4]).set_color(SINE_COLOR) + VGroup(*expanded_deriv[5:7]).set_color(X_SQUARED_COLOR) expanded_deriv.scale(self.tex_scale_factor) expanded_deriv.next_to( self.deriv_mob, DOWN, @@ -642,9 +642,9 @@ class SumRule(GraphScene): rearranged_deriv = TexMobject( "{df \\over", "dx}", "=", "\\cos(x)", "+", "2x" ) - rearranged_deriv[0].highlight(SUM_COLOR) - rearranged_deriv[3].highlight(SINE_COLOR) - rearranged_deriv[5].highlight(X_SQUARED_COLOR) + rearranged_deriv[0].set_color(SUM_COLOR) + rearranged_deriv[3].set_color(SINE_COLOR) + rearranged_deriv[5].set_color(X_SQUARED_COLOR) rearranged_deriv.scale(self.tex_scale_factor) rearranged_deriv.move_to(expanded_deriv, UP+LEFT) deriv_target_indices = [0, 2, 3, 1, 4, 5, 1] @@ -664,7 +664,7 @@ class SumRule(GraphScene): ] def indicate(mob): self.play( - mob.highlight, YELLOW, + mob.set_color, YELLOW, mob.scale_in_place, 1.2, rate_func = there_and_back ) @@ -676,7 +676,7 @@ class SumRule(GraphScene): new_label.add_background_rectangle() new_label.scale(self.tex_scale_factor) new_label.move_to(old_label, RIGHT) - new_label.highlight(old_label.get_color()) + new_label.set_color(old_label.get_color()) self.play(FocusOn(old_label)) indicate(old_label) @@ -707,8 +707,8 @@ class DiscussProducts(TeacherStudentsScene): "\\left(\\frac{d(x^2)}{dx}\\right)", ) not_equals = wrong_product_rule[1] - wrong_product_rule[2].highlight(SINE_COLOR) - wrong_product_rule[3].highlight(X_SQUARED_COLOR) + wrong_product_rule[2].set_color(SINE_COLOR) + wrong_product_rule[3].set_color(X_SQUARED_COLOR) wrong_product_rule.next_to( self.get_teacher().get_corner(UP+LEFT), UP, @@ -729,7 +729,7 @@ class DiscussProducts(TeacherStudentsScene): "pondering", "confused", "erm", added_anims = [ not_equals.scale_in_place, 1.3, - not_equals.highlight, RED + not_equals.set_color, RED ] ) self.wait() @@ -791,7 +791,7 @@ class NotGraphsForProducts(GraphScene): words.scale(1.5) words.shift(FRAME_Y_RADIUS*UP/2) words.add_background_rectangle() - words.highlight(RED) + words.set_color(RED) self.play( everything.fade, Write(words) @@ -876,7 +876,7 @@ class IntroduceProductAsArea(ReconfigurableScene): graph.move_to(x_axis.number_to_point(0), DOWN+LEFT) label = TexMobject("\\sin(x)") - label.highlight(SINE_COLOR) + label.set_color(SINE_COLOR) label.next_to(graph, UP) y_axis = x_axis.copy() @@ -924,7 +924,7 @@ class IntroduceProductAsArea(ReconfigurableScene): "\\text{Area}" ) f_def.to_corner(UP+RIGHT) - f_def[-1].highlight(self.box_kwargs["fill_color"]) + f_def[-1].set_color(self.box_kwargs["fill_color"]) box, labels = self.box_label_group @@ -987,7 +987,7 @@ class IntroduceProductAsArea(ReconfigurableScene): dx = TexMobject("dx") dx.scale(0.7) dx.next_to(brace, UP, buff = SMALL_BUFF) - dx.highlight(dx_line.get_color()) + dx.set_color(dx_line.get_color()) return VGroup(dx_line, brace, dx) @@ -1024,7 +1024,7 @@ class IntroduceProductAsArea(ReconfigurableScene): aligned_edge = aligned_edge, buff = SMALL_BUFF ) - label.highlight(df_boxes[0].get_color()) + label.set_color(df_boxes[0].get_color()) result.add(VGroup(brace, label)) return result @@ -1042,7 +1042,7 @@ class IntroduceProductAsArea(ReconfigurableScene): deriv.to_edge(RIGHT) for submob, tex in zip(deriv, deriv.expression_parts): if tex.startswith("d"): - submob.highlight(self.df_box_kwargs["fill_color"]) + submob.set_color(self.df_box_kwargs["fill_color"]) bottom_box_area = VGroup(*deriv[2:4]) right_box_area = VGroup(*deriv[5:7]) @@ -1072,22 +1072,22 @@ class IntroduceProductAsArea(ReconfigurableScene): deriv.submobjects[4] = df_boxes_copy[1] self.wait() - self.highlight_right_boxes() - self.highlight_bottom_boxes() + self.set_color_right_boxes() + self.set_color_bottom_boxes() self.describe_bottom_box(bottom_box_area) self.describe_right_box(right_box_area) self.ignore_corner() # self.add(deriv) - def highlight_boxes_and_label(self, boxes, label): + def set_color_boxes_and_label(self, boxes, label): boxes.save_state() label.save_state() self.play(GrowFromCenter(label)) self.play( - boxes.highlight, RED, - label.highlight, RED, + boxes.set_color, RED, + label.set_color, RED, ) self.play( label[1].scale_in_place, 1.1, @@ -1096,14 +1096,14 @@ class IntroduceProductAsArea(ReconfigurableScene): self.play(boxes.restore, label.restore) self.wait() - def highlight_right_boxes(self): - self.highlight_boxes_and_label( + def set_color_right_boxes(self): + self.set_color_boxes_and_label( VGroup(*self.df_boxes[1:]), self.df_box_labels[0] ) - def highlight_bottom_boxes(self): - self.highlight_boxes_and_label( + def set_color_bottom_boxes(self): + self.set_color_boxes_and_label( VGroup(*self.df_boxes[:-1]), self.df_box_labels[1] ) @@ -1162,21 +1162,21 @@ class IntroduceProductAsArea(ReconfigurableScene): corner.save_state() corner_copy = VGroup(*self.df_boxes_copy[-2:]) words = TextMobject("Ignore") - words.highlight(RED) + words.set_color(RED) words.next_to(corner_copy, LEFT, buff = LARGE_BUFF) words.shift(MED_SMALL_BUFF*DOWN) arrow = Arrow(words, corner_copy, buff = SMALL_BUFF, color = RED) self.play( - corner.highlight, RED, - corner_copy.highlight, RED, + corner.set_color, RED, + corner_copy.set_color, RED, ) self.wait() self.play(Write(words), ShowCreation(arrow)) self.wait() self.play(*map(FadeOut, [words, arrow, corner_copy])) self.wait() - corner_copy.highlight(BLACK) + corner_copy.set_color(BLACK) def show_thinner_dx(self): self.transition_to_alt_config(dx = self.tiny_dx) @@ -1211,7 +1211,7 @@ class IntroduceProductAsArea(ReconfigurableScene): for submob, tex in zip(new_deriv, new_deriv.expression_parts): for substr in "df", "dx", self.top_func_derivative, self.side_func_derivative: if substr in tex: - submob.highlight(color) + submob.set_color(color) new_deriv.scale(0.9) new_deriv.next_to(self.deriv, DOWN, buff = MED_LARGE_BUFF) new_deriv.shift_onto_screen() @@ -1219,7 +1219,7 @@ class IntroduceProductAsArea(ReconfigurableScene): def indicate(mob): self.play( mob.scale_in_place, 1.2, - mob.highlight, YELLOW, + mob.set_color, YELLOW, rate_func = there_and_back ) @@ -1295,7 +1295,7 @@ class IntroduceProductAsArea(ReconfigurableScene): "``Left ", "d(Right) ", "+", " Right ", "d(Left)", "''", arg_separator = "" ) - VGroup(words[1], words[4]).highlight(self.df_boxes[0].get_color()) + VGroup(words[1], words[4]).set_color(self.df_boxes[0].get_color()) words.scale(0.7) words.next_to(morty.get_corner(UP+LEFT), UP) words.shift_onto_screen() @@ -1403,7 +1403,7 @@ class IntroduceProductAsArea(ReconfigurableScene): class WriteDXSquared(Scene): def construct(self): term = TexMobject("(...)(dx)^2") - term.highlight(RED) + term.set_color(RED) self.play(Write(term)) self.wait() @@ -1420,7 +1420,7 @@ class MneumonicExample(TeacherStudentsScene): ) deriv = TexMobject("\\sin(x)", "2x", "+", "x^2", "\\cos(x)") for mob in words, deriv: - VGroup(mob[1], mob[4]).highlight(GREEN) + VGroup(mob[1], mob[4]).set_color(GREEN) mob.next_to(deriv_q, DOWN, buff = MED_LARGE_BUFF) deriv.shift(words[2].get_center()-deriv[2].get_center()) @@ -1505,9 +1505,9 @@ class ShoveXSquaredInSine(Scene): title.to_edge(UP) sine = TexMobject("g(", "x", ")", "=", "\\sin(", "x", ")") - sine.highlight(SINE_COLOR) + sine.set_color(SINE_COLOR) x_squared = TexMobject("h(x)", "=", "x^2") - x_squared.highlight(X_SQUARED_COLOR) + x_squared.set_color(X_SQUARED_COLOR) group = VGroup(sine, x_squared) group.arrange_submobjects(buff = LARGE_BUFF) group.shift(UP) @@ -1515,9 +1515,9 @@ class ShoveXSquaredInSine(Scene): "g(", "h(x)", ")", "=", "\\sin(", "x^2", ")" ) for i in 0, 2, 4, 6: - composition[i].highlight(SINE_COLOR) + composition[i].set_color(SINE_COLOR) for i in 1, 5: - composition[i].highlight(X_SQUARED_COLOR) + composition[i].set_color(X_SQUARED_COLOR) composition.next_to(group, DOWN, buff = LARGE_BUFF) brace = Brace(VGroup(*composition[-3:]), DOWN) @@ -1623,14 +1623,14 @@ class ThreeLinesChainRule(ReconfigurableScene): def draw_function_arrows(self): lines, line_labels = self.line_group labels = VGroup(*[ - TexMobject("(\\dots)^2").highlight(X_SQUARED_COLOR), - TexMobject("\\sin(\\dots)").highlight(SINE_COLOR) + TexMobject("(\\dots)^2").set_color(X_SQUARED_COLOR), + TexMobject("\\sin(\\dots)").set_color(SINE_COLOR) ]) arrows = VGroup() for lines_subset, label in zip([lines[:2], lines[1:]], labels): arrow = Arc(start_angle = np.pi/3, angle = -2*np.pi/3) arrow.add_tip() - arrow.highlight(label.get_color()) + arrow.set_color(label.get_color()) arrow.next_to(VGroup(*lines_subset)) arrows.add(arrow) label.next_to(arrow, RIGHT) @@ -1692,14 +1692,14 @@ class ThreeLinesChainRule(ReconfigurableScene): nudge_line = Line(start, end) nudge_line.set_stroke(color, width = 6) brace = Brace(nudge_line, DOWN, buff = SMALL_BUFF) - brace.highlight(color) + brace.set_color(color) func_label = config["func_label"] if len(func_label) == 1: text = "$d%s$"%func_label else: text = "$d(%s)$"%func_label brace.text = brace.get_text(text, buff = SMALL_BUFF) - brace.text.highlight(color) + brace.text.set_color(color) brace.add(brace.text) line.add(nudge_line) @@ -1920,10 +1920,10 @@ class GeneralizeChainRule(Scene): example.shift(RIGHT) general.next_to(example, DOWN, buff = 1.5*LARGE_BUFF) for mob in example, general: - mob.highlight(SINE_COLOR) - mob[0].highlight(WHITE) + mob.set_color(SINE_COLOR) + mob[0].set_color(WHITE) for tex in "x^2", "2x", "(x)", "{dh", " dx}": - mob.highlight_by_tex(tex, X_SQUARED_COLOR, substring = True) + mob.set_color_by_tex(tex, X_SQUARED_COLOR, substring = True) example_outer = VGroup(*example[1:4]) example_inner = example[2] @@ -1972,7 +1972,7 @@ class GeneralizeChainRule(Scene): self.wait() self.wait() self.play(*it.chain(*[ - [mob.scale_in_place, 1.2, mob.highlight, YELLOW] + [mob.scale_in_place, 1.2, mob.set_color, YELLOW] for mob in example_inner, d_example_inner ]), rate_func = there_and_back) self.play(Transform( @@ -2020,7 +2020,7 @@ class GeneralizeChainRule(Scene): #Name chain rule name = TextMobject("``Chain rule''") name.scale(1.2) - name.highlight(YELLOW) + name.set_color(YELLOW) name.to_corner(UP+LEFT) self.play(Write(name)) self.wait() @@ -2097,7 +2097,7 @@ class GeneralizeChainRule(Scene): strike.stretch(2, dim = 0) strike.rotate(-np.pi/12) strike.move_to(dh) - strike.highlight(RED) + strike.set_color(RED) strikes.add(strike) self.play(Write(strikes)) self.play(morty.change_mode, "hooray") @@ -2214,7 +2214,7 @@ class NextVideo(TeacherStudentsScene): self.add(series) self.play( next_video.shift, 0.5*DOWN, - next_video.highlight, YELLOW, + next_video.set_color, YELLOW, self.get_teacher().change_mode, "raise_right_hand" ) self.wait() diff --git a/old_projects/eoc/chapter5.py b/old_projects/eoc/chapter5.py index ca3cc97d..36c19d9a 100644 --- a/old_projects/eoc/chapter5.py +++ b/old_projects/eoc/chapter5.py @@ -72,7 +72,7 @@ class LastVideo(TeacherStudentsScene): self.add(series) self.play( last_video_brace.restore, - last_video.highlight, YELLOW, + last_video.set_color, YELLOW, self.get_teacher().change_mode, "raise_right_hand", ) self.play(Write(known_formulas)) @@ -86,7 +86,7 @@ class LastVideo(TeacherStudentsScene): self.play( self.teacher.change_mode, "raise_right_hand", e_to_x.scale, 1.5, - e_to_x.highlight, YELLOW, + e_to_x.set_color, YELLOW, e_to_x.next_to, self.teacher.get_corner(UP+LEFT), UP ) self.wait(2) @@ -122,11 +122,11 @@ class DoublingPopulation(PiCreatureScene): function.to_corner(UP+LEFT) for function in functions[1:]: for i, j in (0, 2), (2, 1): - function[i][j].highlight(self.time_color) + function[i][j].set_color(self.time_color) t_expression = TexMobject("t", "=", "\\text{Time (in days)}") t_expression.to_corner(UP+RIGHT) - t_expression[0].highlight(self.time_color) + t_expression[0].set_color(self.time_color) pop_brace, mass_brace = [ Brace(function[0], DOWN) @@ -271,7 +271,7 @@ class DoublingPopulation(PiCreatureScene): difference_eq[2][-1], real_deriv[0][1], real_deriv[0][-2], - ).highlight(YELLOW) + ).set_color(YELLOW) VGroup( difference_eq[0][3], difference_eq[1][-1], @@ -279,7 +279,7 @@ class DoublingPopulation(PiCreatureScene): real_deriv[0][4], real_deriv[1][-2], real_deriv[1][-1], - ).highlight(GREEN) + ).set_color(GREEN) expressions = [false_deriv, difference_eq, real_deriv] text_arg_list = [ @@ -317,7 +317,7 @@ class DoublingPopulation(PiCreatureScene): self.wait(2) for expression in difference_eq, real_deriv: - expression.brace_text[1].highlight(GREEN) + expression.brace_text[1].set_color(GREEN) self.play( Transform(false_deriv, expression), Transform(false_deriv.brace, expression.brace), @@ -460,13 +460,13 @@ class DoublingPopulation(PiCreatureScene): buff = MED_LARGE_BUFF, aligned_edge = LEFT, ) - top_words[1].highlight(GREEN) + top_words[1].set_color(GREEN) bottom_words = TexMobject( str(2**curr_day), "\\text{ creatures}", "\\over {1 \\text{ day}}" ) - bottom_words[0].highlight(GREEN) + bottom_words[0].set_color(GREEN) bottom_words.next_to(top_words, DOWN, buff = MED_LARGE_BUFF) return top_words, bottom_words @@ -538,7 +538,7 @@ class GraphOfTwoToT(GraphScene): #Vary value threes = VGroup(height_label[1], slope_label[2][1]) ts = VGroup(*[ - TexMobject("t").highlight(YELLOW).scale(0.75).move_to(three) + TexMobject("t").set_color(YELLOW).scale(0.75).move_to(three) for three in threes ]) self.play(Transform(threes, ts)) @@ -590,7 +590,7 @@ class GraphOfTwoToT(GraphScene): DOWN+RIGHT, buff = 0 ) - slope_label.highlight_by_tex("Slope", RED) + slope_label.set_color_by_tex("Slope", RED) return VGroup( v_line, brace, height_label, ss_group, slope_label @@ -641,8 +641,8 @@ class FakeDiagram(TeacherStudentsScene): graph.add_control_points(3*[point]) graph.set_stroke(width = 1) graph.set_fill(opacity = 1) - graph.highlight(BLUE_D) - background_graph.highlight(YELLOW) + graph.set_color(BLUE_D) + background_graph.set_color(YELLOW) background_graph.set_stroke(width = 0.5) graphs.next_to(self.teacher, UP+LEFT, LARGE_BUFF) @@ -667,7 +667,7 @@ class FakeDiagram(TeacherStudentsScene): words = TextMobject("Not a real explanation") words.to_edge(UP) arrow = Arrow(words.get_bottom(), two_to_t.get_corner(UP+LEFT)) - arrow.highlight(WHITE) + arrow.set_color(WHITE) diagram = VGroup( graphs, two_to_t, dt_brace, dt, @@ -769,8 +769,8 @@ class AnalyzeExponentRatio(PiCreatureScene): extracted_two_to_t, lhs, func_def ] for expression in expressions: - expression.highlight_by_tex("t", YELLOW) - expression.highlight_by_tex("dt", GREEN) + expression.set_color_by_tex("t", YELLOW) + expression.set_color_by_tex("dt", GREEN) #Apply exponential property self.play( @@ -808,7 +808,7 @@ class AnalyzeExponentRatio(PiCreatureScene): for s in "Additive", "Multiplicative" ]) words[0].move_to(words[1], LEFT) - words.highlight(BLUE) + words.set_color(BLUE) words.next_to(two_to_t_plus_dt, RIGHT, buff = 1.5*LARGE_BUFF) arrows = VGroup(*[ Arrow(word.get_left(), rect, color = words.get_color()) @@ -866,7 +866,7 @@ class AnalyzeExponentRatio(PiCreatureScene): brace = Brace(VGroup(extracted_two_to_t, ratio), DOWN) alt_brace = Brace(parens, DOWN) dt_to_zero = TexMobject("dt", "\\to 0") - dt_to_zero.highlight_by_tex("dt", GREEN) + dt_to_zero.set_color_by_tex("dt", GREEN) dt_to_zero.next_to(brace, DOWN) self.play(GrowFromCenter(brace)) @@ -992,8 +992,8 @@ class AnalyzeExponentRatio(PiCreatureScene): "\\over \\,", "%s}"%dt_str, "=", output_str ) - expression.highlight_by_tex(dt_str, GREEN) - expression.highlight_by_tex(output_str, BLUE) + expression.set_color_by_tex(dt_str, GREEN) + expression.set_color_by_tex(output_str, BLUE) expression.to_corner(UP+RIGHT) expressions.append(expression) @@ -1089,7 +1089,7 @@ class CompareTwoConstantToEightConstant(PiCreatureScene): (const_str, BLUE) ] for tex, color in tex_color_paris: - result.highlight_by_tex(tex, color) + result.set_color_by_tex(tex, color) return result def create_pi_creature(self): @@ -1103,9 +1103,9 @@ class AskAboutConstantOne(TeacherStudentsScene): "{ d(a^", "t", ")", "\\over \\,", "dt}", "=", "a^", "t", "(\\text{Some constant})" ) - note.highlight_by_tex("t", YELLOW) - note.highlight_by_tex("dt", GREEN) - note.highlight_by_tex("constant", BLUE) + note.set_color_by_tex("t", YELLOW) + note.set_color_by_tex("dt", GREEN) + note.set_color_by_tex("constant", BLUE) note.to_corner(UP+LEFT) self.add(note) @@ -1137,11 +1137,11 @@ class WhyPi(PiCreatureScene): ghost_circle = circle.copy() ghost_circle.set_stroke(width = 1) diam = Line(circle.get_left(), circle.get_right()) - diam.highlight(YELLOW) + diam.set_color(YELLOW) one = TexMobject("1") one.next_to(diam, UP) circum = diam.copy() - circum.highlight(circle.get_color()) + circum.set_color(circle.get_color()) circum.scale(np.pi) circum.next_to(circle, DOWN, LARGE_BUFF) circum.insert_n_anchor_points(circle.get_num_anchor_points()-2) @@ -1273,7 +1273,7 @@ class ApplyChainRule(TeacherStudentsScene): ) deriv_equation.next_to(self.teacher, UP+LEFT) deriv_equation.shift(UP) - deriv_equation.highlight_by_tex("3", BLUE) + deriv_equation.set_color_by_tex("3", BLUE) deriv = VGroup(*deriv_equation[:7]) exponent = VGroup(*deriv_equation[-2:]) circle = Circle(color = YELLOW) @@ -1377,14 +1377,14 @@ class ChainRuleIntuition(ThreeLinesChainRule): nudge_line = Line(start, end) nudge_line.set_stroke(color, width = 6) brace = Brace(nudge_line, DOWN, buff = SMALL_BUFF) - brace.highlight(color) + brace.set_color(color) func_label = config["func_label"] if len(func_label) == 1: text = "$d%s$"%func_label else: text = "$d(%s)$"%func_label brace.text = brace.get_text(text, buff = SMALL_BUFF) - brace.text.highlight(color) + brace.text.set_color(color) brace.add(brace.text) line.add(nudge_line) @@ -1437,7 +1437,7 @@ class WhyNaturalLogOf2ShowsUp(TeacherStudentsScene): non_t_group.remove(*t_group) log_words = TextMobject("``$e$ to the ", "\\emph{what}", "equals 2?''") - log_words.highlight_by_tex("what", BLUE) + log_words.set_color_by_tex("what", BLUE) log_words.next_to(equation, UP+LEFT) log_words_arrow = Arrow( log_words.get_right(), @@ -1450,10 +1450,10 @@ class WhyNaturalLogOf2ShowsUp(TeacherStudentsScene): ) derivative.move_to(equation) for tex_mob in equation, derivative: - tex_mob.highlight_by_tex("ln(2)", BLUE) - tex_mob.highlight_by_tex("t", YELLOW) + tex_mob.set_color_by_tex("ln(2)", BLUE) + tex_mob.set_color_by_tex("t", YELLOW) derivative_arrow = Arrow(1.5*UP, ORIGIN, buff = 0) - derivative_arrow.highlight(WHITE) + derivative_arrow.set_color(WHITE) derivative_arrow.next_to( derivative.get_parts_by_tex("="), UP ) @@ -1531,7 +1531,7 @@ class WhyNaturalLogOf2ShowsUp(TeacherStudentsScene): "{d(", "e^", "{%s"%C_str, "t}", ")", "\\over", "dt}", "=", C_str, "e^", "{%s"%C_str, "t}", ) - result.highlight_by_tex(C_str, BLUE) + result.set_color_by_tex(C_str, BLUE) result.C_str = C_str return result @@ -1542,7 +1542,7 @@ class WhyNaturalLogOf2ShowsUp(TeacherStudentsScene): "{d(", a_str, "^t", ")", "\\over", "dt}", "=", log_str, a_str, "^t" ) - result.highlight_by_tex(log_str, BLUE) + result.set_color_by_tex(log_str, BLUE) return result def get_log_str(self, a): @@ -1567,10 +1567,10 @@ class CompareWaysToWriteExponentials(GraphScene): a_to_t.move_to(self.coords_to_point(6, 45)) cross = TexMobject("\\times") - cross.highlight(RED) + cross.set_color(RED) cross.replace(a_to_t, stretch = True) e_to_ct = TexMobject("e^", "{c", "t}") - e_to_ct.highlight_by_tex("c", BLUE) + e_to_ct.set_color_by_tex("c", BLUE) e_to_ct.scale(1.5) e_to_ct.next_to(a_to_t, DOWN) @@ -1581,7 +1581,7 @@ class CompareWaysToWriteExponentials(GraphScene): str(base), "^t", "=", "e^", "{(%s)"%log_str, "t}", ) - equation.highlight_by_tex(log_str, BLUE) + equation.set_color_by_tex(log_str, BLUE) equation.scale(1.2) equations.add(equation) @@ -1625,15 +1625,15 @@ class ManyExponentialForms(TeacherStudentsScene): group.scale_to_fit_width(FRAME_WIDTH - LARGE_BUFF) group.next_to(self.get_pi_creatures(), UP, 2*LARGE_BUFF) for part in group: - part.highlight_by_tex("t", YELLOW) + part.set_color_by_tex("t", YELLOW) const = part.get_part_by_tex("dots") if const: - const.highlight(BLUE) + const.set_color(BLUE) brace = Brace(const, UP) log = brace.get_text( "$\\log_{%s}(2)$"%part[1].get_tex_string()[:-1] ) - log.highlight(BLUE) + log.set_color(BLUE) part.add(brace, log) exp = VGroup(*rhs_list[0][1:4]) rect = BackgroundRectangle(group) @@ -1655,7 +1655,7 @@ class ManyExponentialForms(TeacherStudentsScene): ) self.play(*[ ApplyFunction( - lambda m : m.shift(SMALL_BUFF*UP).highlight(RED), + lambda m : m.shift(SMALL_BUFF*UP).set_color(RED), part, run_time = 2, rate_func = squish_rate_func(there_and_back, a, a+0.3) @@ -1707,8 +1707,8 @@ class TemperatureOverTimeOfWarmWater(GraphScene): "\\Delta T(", "t", ") = e", "^{-k", "t}" ) solution.next_to(ode, DOWN, MED_LARGE_BUFF) - solution.highlight_by_tex("t", YELLOW) - solution.highlight_by_tex("Delta", WHITE) + solution.set_color_by_tex("t", YELLOW) + solution.set_color_by_tex("Delta", WHITE) delta_T_brace = Brace(graph, RIGHT) delta_T_label = TexMobject("\\Delta T") @@ -1758,7 +1758,7 @@ class InvestedMoney(Scene): "{d", cash_str, "\\over", "dt}", "=", "(1 + r)", cash_str ) - equation.highlight_by_tex(cash_str, GREEN) + equation.set_color_by_tex(cash_str, GREEN) equation.next_to(ORIGIN, LEFT) equation.to_edge(UP) @@ -1768,8 +1768,8 @@ class InvestedMoney(Scene): solution = TexMobject( cash_str, "(", "t", ")", "=", "e^", "{(1+r)", "t}" ) - solution.highlight_by_tex("t", YELLOW) - solution.highlight_by_tex(cash_str, GREEN) + solution.set_color_by_tex("t", YELLOW) + solution.set_color_by_tex(cash_str, GREEN) solution.next_to(arrow, RIGHT) cash = TexMobject("\\$") @@ -1781,7 +1781,7 @@ class InvestedMoney(Scene): for x in range(40) for y in range(8) ]) - cash_pile.highlight(GREEN) + cash_pile.set_color(GREEN) cash_pile.center() cash_pile.shift(DOWN) @@ -1885,7 +1885,7 @@ class NaturalLog(Scene): FadeOut(expression[-2]), FadeOut(constant), ln_a.move_to, constant, LEFT, - ln_a.highlight, BLUE + ln_a.set_color, BLUE ) self.wait() self.play(*map(FadeOut, [log_expression, exp_expression])) @@ -1896,9 +1896,9 @@ class NaturalLog(Scene): "{d(", "%d^"%base, "t", ")", "\\over \\,", "dt}", "=", "%d^"%base, "t", "(%.4f\\dots)"%np.log(base), ) - expression.highlight_by_tex("t", YELLOW) - expression.highlight_by_tex("dt", GREEN) - expression.highlight_by_tex("\\dots", BLUE) + expression.set_color_by_tex("t", YELLOW) + expression.set_color_by_tex("dt", GREEN) + expression.set_color_by_tex("\\dots", BLUE) brace = Brace(expression.get_part_by_tex("\\dots"), UP) brace_text = brace.get_text("$\\ln(%d)$"%base) @@ -1916,13 +1916,13 @@ class NextVideo(TeacherStudentsScene): next_video = series[4] brace = Brace(this_video, DOWN) this_video.save_state() - this_video.highlight(YELLOW) + this_video.set_color(YELLOW) this_tex = TexMobject( "{d(", "a^t", ") \\over dt} = ", "a^t", "\\ln(a)" ) - this_tex[1][1].highlight(YELLOW) - this_tex[3][1].highlight(YELLOW) + this_tex[1][1].set_color(YELLOW) + this_tex[3][1].set_color(YELLOW) this_tex.next_to(brace, DOWN) next_tex = VGroup(*map(TextMobject, [ @@ -1959,7 +1959,7 @@ class NextVideo(TeacherStudentsScene): brace.next_to, next_video, DOWN, this_video.restore, Animation(this_tex), - next_video.highlight, YELLOW, + next_video.set_color, YELLOW, Write(next_tex), self.get_teacher().change_mode, "raise_right_hand" ) @@ -2026,11 +2026,11 @@ class Thumbnail(GraphOfTwoToT): derivative = TexMobject( "\\frac{d(a^t)}{dt} =", "a^t \\ln(a)" ) - derivative[0][3].highlight(YELLOW) - derivative[1][1].highlight(YELLOW) - derivative[0][2].highlight(BLUE) - derivative[1][0].highlight(BLUE) - derivative[1][5].highlight(BLUE) + derivative[0][3].set_color(YELLOW) + derivative[1][1].set_color(YELLOW) + derivative[0][2].set_color(BLUE) + derivative[1][0].set_color(BLUE) + derivative[1][5].set_color(BLUE) derivative.scale(2) derivative.add_background_rectangle() derivative.to_corner(DOWN+RIGHT, buff = MED_SMALL_BUFF) @@ -2050,7 +2050,7 @@ class Thumbnail(GraphOfTwoToT): question = TextMobject("What is $e\\,$?") e = question[-2] e.scale(1.2, about_point = e.get_bottom()) - e.highlight(BLUE) + e.set_color(BLUE) question.scale(3) question.add_background_rectangle() question.to_edge(UP) diff --git a/old_projects/eoc/chapter6.py b/old_projects/eoc/chapter6.py index cfb0f120..56fe915f 100644 --- a/old_projects/eoc/chapter6.py +++ b/old_projects/eoc/chapter6.py @@ -134,7 +134,7 @@ class SlopeOfCircleExample(ZoomedScene): self.play(ShowCreation(dot)) for line, tex in zip(lines, "5xy"): label = TexMobject(tex) - label.highlight(line.get_color()) + label.set_color(line.get_color()) label.add_background_rectangle() label.next_to( line.get_center(), @@ -199,7 +199,7 @@ class SlopeOfCircleExample(ZoomedScene): def draw_example_slope(self): point = self.example_point_dot.get_center() line = Line(ORIGIN, point) - line.highlight(self.example_color) + line.set_color(self.example_color) line.rotate(np.pi/2) line.scale(2) line.move_to(point) @@ -213,7 +213,7 @@ class SlopeOfCircleExample(ZoomedScene): coords.scale(0.7) coords.next_to(point, LEFT) coords.shift(SMALL_BUFF*DOWN) - coords.highlight(self.example_color) + coords.set_color(self.example_color) self.play(GrowFromCenter(line)) self.play(Write(word)) @@ -265,7 +265,7 @@ class SlopeOfCircleExample(ZoomedScene): step_vect *= step_length/np.linalg.norm(step_vect) step_line = Line(ORIGIN, LEFT) - step_line.highlight(WHITE) + step_line.set_color(WHITE) brace = Brace(step_line, DOWN) step_text = brace.get_text("Step", buff = SMALL_BUFF) step_group = VGroup(step_line, brace, step_text) @@ -276,8 +276,8 @@ class SlopeOfCircleExample(ZoomedScene): interim_point = step_line.get_corner(UP+RIGHT) dy_line = Line(point, interim_point) dx_line = Line(interim_point, point+step_vect) - dy_line.highlight(RED) - dx_line.highlight(GREEN) + dy_line.set_color(RED) + dx_line.set_color(GREEN) for line, tex in (dx_line, "dx"), (dy_line, "dy"): label = TexMobject(tex) label.scale(1./self.zoom_factor) @@ -288,7 +288,7 @@ class SlopeOfCircleExample(ZoomedScene): line, next_to_vect, buff = MED_SMALL_BUFF/self.zoom_factor ) - label.highlight(line.get_color()) + label.set_color(line.get_color()) line.label = label self.activate_zooming() @@ -324,8 +324,8 @@ class SlopeOfCircleExample(ZoomedScene): new_slope_word.shift(slope_word.get_center()[1]*UP) dy_dx = TexMobject("\\frac{dy}{dx}") - VGroup(*dy_dx[:2]).highlight(RED) - VGroup(*dy_dx[-2:]).highlight(GREEN) + VGroup(*dy_dx[:2]).set_color(RED) + VGroup(*dy_dx[-2:]).set_color(GREEN) dy_dx.next_to(new_slope_word, RIGHT) dy_dx.add_background_rectangle() @@ -344,14 +344,14 @@ class SlopeOfCircleExample(ZoomedScene): "Not $y = f(x)$", buff = SMALL_BUFF ) - brace_text.highlight(RED) + brace_text.set_color(RED) alt_brace_text = brace.get_text("Implicit curve") for text in brace_text, alt_brace_text: text.add_background_rectangle() text.to_edge(RIGHT, buff = MED_SMALL_BUFF) new_circle = self.circle.copy() - new_circle.highlight(BLUE) + new_circle.set_color(BLUE) self.play( GrowFromCenter(brace), @@ -394,8 +394,8 @@ class SlopeOfCircleExample(ZoomedScene): derivative = TexMobject("2x\\,dx + 2y\\,dy = 0") dx = VGroup(*derivative[2:4]) dy = VGroup(*derivative[7:9]) - dx.highlight(GREEN) - dy.highlight(RED) + dx.set_color(GREEN) + dy.set_color(RED) @@ -473,8 +473,8 @@ class SlopeOfCircleExample(ZoomedScene): ) new_dy = VGroup(*final_form[:2]) new_dx = VGroup(*final_form[3:5]) - new_dy.highlight(dy.get_color()) - new_dx.highlight(dx.get_color()) + new_dy.set_color(dy.get_color()) + new_dx.set_color(dx.get_color()) new_dy.add(final_form[2]) new_x = VGroup(*final_form[6:8]) new_y = VGroup(*final_form[8:10]) @@ -533,11 +533,11 @@ class SlopeOfCircleExample(ZoomedScene): scale_factor = 1.4 self.play( x.scale, scale_factor, - x.highlight, GREEN, + x.set_color, GREEN, x.move_to, frac[1], FadeOut(frac[1]), y.scale, scale_factor, - y.highlight, RED, + y.set_color, RED, y.move_to, frac[3], DOWN, y.shift, SMALL_BUFF*UP, FadeOut(frac[3]), @@ -555,8 +555,8 @@ class NameImplicitDifferentation(TeacherStudentsScene): derivative = TexMobject( "2x\\,dx", "+", "2y\\,dy", "=", "0" ) - VGroup(*derivative[0][2:]).highlight(GREEN) - VGroup(*derivative[2][2:]).highlight(RED) + VGroup(*derivative[0][2:]).set_color(GREEN) + VGroup(*derivative[2][2:]).set_color(RED) arrow = Arrow(ORIGIN, DOWN, buff = SMALL_BUFF) group = VGroup(title, equation, arrow, derivative) group.arrange_submobjects(DOWN) @@ -680,11 +680,11 @@ class RelatedRatesExample(ThreeDScene): y_label = TexMobject("%dm"%int(self.start_y)) y_label.next_to(y_line, LEFT, buff = SMALL_BUFF) - y_label.highlight(y_line.get_color()) + y_label.set_color(y_line.get_color()) x_label = TexMobject("%dm"%int(self.start_x)) x_label.next_to(x_line, UP) - x_label.highlight(x_line.get_color()) + x_label.set_color(x_line.get_color()) self.play(Write(ladder_brace)) self.wait() @@ -773,8 +773,8 @@ class RelatedRatesExample(ThreeDScene): equation = TexMobject( "x(t)", "^2", "+", "y(t)", "^2", "=", "5^2" ) - equation[0].highlight(GREEN) - equation[3].highlight(RED) + equation[0].set_color(GREEN) + equation[3].set_color(RED) equation.next_to(self.related_rates_words, DOWN, buff = MED_LARGE_BUFF) equation.to_edge(RIGHT, buff = LARGE_BUFF) @@ -810,8 +810,8 @@ class RelatedRatesExample(ThreeDScene): alt_equation = TexMobject( "x(t)", "=", "\\big(5^2", "-", "y(t)", "^2 \\big)", "^{1/2}", ) - alt_equation[0].highlight(GREEN) - alt_equation[4].highlight(RED) + alt_equation[0].set_color(GREEN) + alt_equation[4].set_color(RED) alt_equation.next_to(self.equation, DOWN, buff = MED_LARGE_BUFF) alt_equation.to_edge(RIGHT) @@ -825,7 +825,7 @@ class RelatedRatesExample(ThreeDScene): find_dx_dt = TexMobject("\\text{Find } \\,", "\\frac{dx}{dt}") find_dx_dt.next_to(randy, RIGHT, aligned_edge = UP) - find_dx_dt[1].highlight(GREEN) + find_dx_dt[1].set_color(GREEN) self.play(FadeIn(randy)) self.play( @@ -872,7 +872,7 @@ class RelatedRatesExample(ThreeDScene): """that happens to be constant""" ) - constant_words.highlight(YELLOW) + constant_words.set_color(YELLOW) constant_words.next_to(function_of_time, DOWN) derivative = TexMobject( @@ -918,10 +918,10 @@ class RelatedRatesExample(ThreeDScene): dt_words = TextMobject("After", "$dt$", "seconds...") dt_words.to_corner(UP+LEFT) dt = dt_words[1] - dt.highlight(YELLOW) + dt.set_color(YELLOW) dt_brace = Brace(dt, buff = SMALL_BUFF) dt_brace_text = dt_brace.get_text("Think 0.01", buff = SMALL_BUFF) - dt_brace_text.highlight(dt.get_color()) + dt_brace_text.set_color(dt.get_color()) shadow_ladder = self.ladder.copy() shadow_ladder.fade(0.5) @@ -952,14 +952,14 @@ class RelatedRatesExample(ThreeDScene): dy_line = Line(y_top, new_y_top) dy_brace = Brace(dy_line, RIGHT, buff = SMALL_BUFF) dy_label = dy_brace.get_text("$dy$", buff = SMALL_BUFF) - dy_label.highlight(RED) + dy_label.set_color(RED) dx_line = Line(x_left, new_x_left) dx_brace = Brace(dx_line, DOWN, buff = SMALL_BUFF) dx_label = dx_brace.get_text("$dx$") - dx_label.highlight(GREEN) + dx_label.set_color(GREEN) - VGroup(dy_line, dx_line).highlight(YELLOW) + VGroup(dy_line, dx_line).set_color(YELLOW) for line, brace, label in (dy_line, dy_brace, dy_label), (dx_line, dx_brace, dx_label): self.play( @@ -1009,10 +1009,10 @@ class RelatedRatesExample(ThreeDScene): "2", "x(t)", "\\frac{dx}{dt}", "+", "2", "y(t)", "\\frac{dy}{dt}", ) - lhs_derivative[1].highlight(GREEN) - VGroup(*lhs_derivative[2][:2]).highlight(GREEN) - lhs_derivative[5].highlight(RED) - VGroup(*lhs_derivative[6][:2]).highlight(RED) + lhs_derivative[1].set_color(GREEN) + VGroup(*lhs_derivative[2][:2]).set_color(GREEN) + lhs_derivative[5].set_color(RED) + VGroup(*lhs_derivative[6][:2]).set_color(RED) lhs_derivative.next_to( derivative_scaffold, DOWN, aligned_edge = RIGHT, @@ -1091,9 +1091,9 @@ class RelatedRatesExample(ThreeDScene): "2", "(%d)"%int(self.start_y), "(-1)", "= 0" ) - new_lhs_derivative[1].highlight(GREEN) - VGroup(*new_lhs_derivative[2][:2]).highlight(GREEN) - new_lhs_derivative[5].highlight(RED) + new_lhs_derivative[1].set_color(GREEN) + VGroup(*new_lhs_derivative[2][:2]).set_color(GREEN) + new_lhs_derivative[5].set_color(RED) new_lhs_derivative.next_to( self.lhs_derivative, DOWN, buff = MED_LARGE_BUFF, @@ -1124,8 +1124,8 @@ class RelatedRatesExample(ThreeDScene): "\\frac{dx}{dt} = \\frac{4}{3}" ) for i in 0, 1, -1: - solution[i].highlight(GREEN) - solution[-3].highlight(RED) + solution[i].set_color(GREEN) + solution[-3].set_color(RED) solution.next_to( self.new_lhs_derivative, DOWN, buff = MED_LARGE_BUFF, @@ -1202,11 +1202,11 @@ class RelatedRatesExample(ThreeDScene): x_line, y_line = self.x_and_y_lines x_label = TexMobject("x(t)") - x_label.highlight(x_line.get_color()) + x_label.set_color(x_line.get_color()) x_label.next_to(x_line, DOWN, buff = SMALL_BUFF) y_label = TexMobject("y(t)") - y_label.highlight(y_line.get_color()) + y_label.set_color(y_line.get_color()) y_label.next_to(y_line, LEFT, buff = SMALL_BUFF) return VGroup(x_label, y_label) @@ -1216,9 +1216,9 @@ class RelatedRatesExample(ThreeDScene): interim_point = top_point[0]*RIGHT + bottom_point[1]*UP interim_point += SMALL_BUFF*DOWN y_line = Line(top_point, interim_point) - y_line.highlight(RED) + y_line.set_color(RED) x_line = Line(bottom_point, interim_point) - x_line.highlight(GREEN) + x_line.set_color(GREEN) return VGroup(x_line, y_line) @@ -1389,7 +1389,7 @@ class CompareLadderAndCircle(PiCreatureScene, ThreeDScene): brace = Brace(mob) brace.next_to(mob[0], DOWN, buff = SMALL_BUFF, aligned_edge = LEFT) text = brace.get_text("No $dt$", buff = SMALL_BUFF) - text.highlight(YELLOW) + text.set_color(YELLOW) self.play( GrowFromCenter(brace), @@ -1411,9 +1411,9 @@ class CompareLadderAndCircle(PiCreatureScene, ThreeDScene): def color_equations(self, equation, derivative): for mob in equation[0], derivative[1]: - mob.highlight(GREEN) + mob.set_color(GREEN) for mob in equation[3], derivative[5]: - mob.highlight(RED) + mob.set_color(RED) class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): CONFIG = { @@ -1472,9 +1472,9 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): dot = Dot(point, color = self.example_color) new_s_expression = self.get_s_expression(*self.example_point) new_s_expression.next_to(dot, UP+RIGHT, buff = 0) - new_s_expression.highlight(self.example_color) + new_s_expression.set_color(self.example_color) equals_25 = TexMobject("=%d"%int(np.linalg.norm(self.example_point)**2)) - equals_25.highlight(YELLOW) + equals_25.set_color(YELLOW) equals_25.next_to(new_s_expression, RIGHT, align_using_submobjects = True) equals_25.add_background_rectangle() @@ -1503,11 +1503,11 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): point = self.plane.num_pair_to_point(coords) s_expression = self.get_s_expression(*coords) s_expression.next_to(point, UP+RIGHT, buff = SMALL_BUFF) - s_expression.highlight(self.example_color) + s_expression.set_color(self.example_color) result = coords[0]**2 + coords[1]**2 rhs = TexMobject("=%d"%int(result)) rhs.add_background_rectangle() - rhs.highlight(YELLOW) + rhs.set_color(YELLOW) rhs.next_to(s_expression, RIGHT, align_using_submobjects = True) point_label = VGroup(s_expression, rhs) @@ -1522,8 +1522,8 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): derivative = TexMobject( "dS =", "2", "x", "\\,dx", "+", "2", "y", "\\,dy", ) - derivative[2].highlight(GREEN) - derivative[6].highlight(RED) + derivative[2].set_color(GREEN) + derivative[6].set_color(RED) derivative.next_to(equation, DOWN, buff = MED_LARGE_BUFF) derivative.add_background_rectangle() derivative.to_edge(LEFT) @@ -1567,7 +1567,7 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): dy_line = Line(interim_point, new_point, color = RED) for line, tex, vect in (dx_line, "dx", UP), (dy_line, "dy", LEFT): label = TexMobject(tex) - label.highlight(line.get_color()) + label.set_color(line.get_color()) label.next_to(line, vect, buff = SMALL_BUFF) label.add_background_rectangle() label.scale( @@ -1614,9 +1614,9 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): aligned_edge = LEFT ) new_s_label.shift(MED_LARGE_BUFF*LEFT/self.zoom_factor) - new_s_label.highlight(self.example_color) - VGroup(*new_s_label[1][1][3:5]).highlight(GREEN) - VGroup(*new_s_label[1][1][-3:-1]).highlight(RED) + new_s_label.set_color(self.example_color) + VGroup(*new_s_label[1][1][3:5]).set_color(GREEN) + VGroup(*new_s_label[1][1][-3:-1]).set_color(RED) self.play(ShowCreation(new_dot)) self.play(Write(new_s_label)) @@ -1638,8 +1638,8 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): "dS =", "2", "(3)", "\\,(-0.02)", "+", "2", "(4)", "\\,(-0.01)", ) - deriv_example[2].highlight(GREEN) - deriv_example[6].highlight(RED) + deriv_example[2].set_color(GREEN) + deriv_example[6].set_color(RED) deriv_example.add_background_rectangle() deriv_example.scale(0.8) deriv_example.next_to(ORIGIN, UP, buff = SMALL_BUFF) @@ -1705,7 +1705,7 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): randy = self.randy equals_zero = TexMobject("=0") - equals_zero.highlight(YELLOW) + equals_zero.set_color(YELLOW) equals_zero.add_background_rectangle() equals_zero.next_to(self.derivative, RIGHT) @@ -1743,7 +1743,7 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): dx_line = Line(interim_point, new_point, color = GREEN) s_label = TexMobject("S = 25") - s_label.highlight(self.example_color) + s_label.set_color(self.example_color) s_label.next_to( point, DOWN, buff = MED_LARGE_BUFF, @@ -1763,7 +1763,7 @@ class TwoVariableFunctionAndDerivative(SlopeOfCircleExample): for line, tex, vect in (dy_line, "dy", RIGHT), (dx_line, "dx", UP): label = TexMobject(tex) - label.highlight(line.get_color()) + label.set_color(line.get_color()) label.next_to(line, vect) label.scale( 1./self.zoom_factor, @@ -1933,7 +1933,7 @@ class AlternateExample(ZoomedScene): dot = Dot(color = self.example_color) label = TexMobject("(x, y)") label.add_background_rectangle() - label.highlight(self.example_color) + label.set_color(self.example_color) def update_dot(dot, alpha): prop = interpolate(0.9, 0.1, alpha) @@ -2020,7 +2020,7 @@ class AlternateExample(ZoomedScene): for line, tex, vect in (dx_line, "dx", DOWN), (dy_line, "dy", LEFT): label = TexMobject(tex) label.next_to(line, vect, buff = SMALL_BUFF) - label.highlight(line.get_color()) + label.set_color(line.get_color()) label.scale(1./self.zoom_factor, about_point = line.get_center()) label.add_background_rectangle() line.label = label @@ -2080,8 +2080,8 @@ class AlternateExample(ZoomedScene): "''", arg_separator = "" ) - mnemonic.highlight_by_tex("d-Right", RED) - mnemonic.highlight_by_tex("d-Left", GREEN) + mnemonic.set_color_by_tex("d-Right", RED) + mnemonic.set_color_by_tex("d-Left", GREEN) mnemonic.add_background_rectangle() mnemonic.scale_to_fit_width(FRAME_X_RADIUS-2*MED_LARGE_BUFF) mnemonic.next_to(ORIGIN, UP) @@ -2091,8 +2091,8 @@ class AlternateExample(ZoomedScene): "\\sin(x)", "(2y\\,dy)", "+", "y^2", "(\\cos(x)\\,dx)", ) - derivative.highlight_by_tex("dx", GREEN) - derivative.highlight_by_tex("dy", RED) + derivative.set_color_by_tex("dx", GREEN) + derivative.set_color_by_tex("dy", RED) derivative.scale_to_fit_width(FRAME_X_RADIUS - 2*MED_LARGE_BUFF) derivative.next_to( brace, DOWN, @@ -2138,7 +2138,7 @@ class AlternateExample(ZoomedScene): equals, dx = equals_dx = TexMobject("=", "dx") equals_dx.scale(0.9) - equals_dx.highlight_by_tex("dx", GREEN) + equals_dx.set_color_by_tex("dx", GREEN) equals_dx.add_background_rectangle() equals_dx.next_to(lhs_derivative, RIGHT, buff = SMALL_BUFF) @@ -2147,7 +2147,7 @@ class AlternateExample(ZoomedScene): circle.scale_in_place(1.7) arrow = Arrow(rhs.get_right(), dx.get_top()) - arrow.highlight(GREEN) + arrow.set_color(GREEN) self.play(ReplacementTransform(lhs_brace, circle)) self.play(ShowCreation(arrow)) @@ -2203,8 +2203,8 @@ class AlternateExample(ZoomedScene): "Commonly, solve for", "$dy/dx$", buff = SMALL_BUFF ) - VGroup(*words[1][:2]).highlight(RED) - VGroup(*words[1][3:]).highlight(GREEN) + VGroup(*words[1][:2]).set_color(RED) + VGroup(*words[1][3:]).set_color(GREEN) words.add_background_rectangle() self.play(GrowFromCenter(brace)) @@ -2227,9 +2227,9 @@ class AskAboutNaturalLog(TeacherStudentsScene): def construct(self): exp_deriv = TexMobject("\\frac{d(e^x)}{dx} = e^x") for i in 2, 3, 9, 10: - exp_deriv[i].highlight(BLUE) + exp_deriv[i].set_color(BLUE) log_deriv = TexMobject("\\frac{d(\\ln(x))}{dx} = ???") - VGroup(*log_deriv[2:2+5]).highlight(GREEN) + VGroup(*log_deriv[2:2+5]).set_color(GREEN) for deriv in exp_deriv, log_deriv: deriv.next_to(self.get_teacher().get_corner(UP+LEFT), UP) @@ -2311,7 +2311,7 @@ class DerivativeOfNaturalLog(ZoomedScene): dot = Dot(color = self.example_color) label = TexMobject("(x, y)") label.add_background_rectangle() - label.highlight(self.example_color) + label.set_color(self.example_color) def update_dot(dot, alpha): prop = interpolate(0.1, 0.7, alpha) @@ -2339,7 +2339,7 @@ class DerivativeOfNaturalLog(ZoomedScene): self.wait() xy_start = VGroup(label[1][1], label[1][3]).copy() xy_end = VGroup(formula[1][5], formula[1][0]).copy() - xy_end.highlight(self.example_color) + xy_end.set_color(self.example_color) self.play(Transform( xy_start, xy_end, run_time = 2, @@ -2373,10 +2373,10 @@ class DerivativeOfNaturalLog(ZoomedScene): "\\frac{dy}{dx} = ", "\\frac{d(\\ln(x))}{dx}", ) - VGroup(*equation[1][:2]).highlight(RED) - VGroup(*equation[2][:8]).highlight(RED) - VGroup(*equation[1][3:5]).highlight(GREEN) - VGroup(*equation[2][-2:]).highlight(GREEN) + VGroup(*equation[1][:2]).set_color(RED) + VGroup(*equation[2][:8]).set_color(RED) + VGroup(*equation[1][3:5]).set_color(GREEN) + VGroup(*equation[2][-2:]).set_color(GREEN) for part in equation: rect = BackgroundRectangle(part) rect.stretch_in_place(1.2, 0) @@ -2437,8 +2437,8 @@ class DerivativeOfNaturalLog(ZoomedScene): new_e, new_y, dy, new_eq, dx = derivative derivative.next_to(new_formula, DOWN, MED_LARGE_BUFF) derivative.add_background_rectangle() - dx.highlight(GREEN) - dy.highlight(RED) + dx.set_color(GREEN) + dy.set_color(RED) pairs = [ (VGroup(e, y), VGroup(new_e, new_y)), @@ -2468,7 +2468,7 @@ class DerivativeOfNaturalLog(ZoomedScene): label = TexMobject(tex) label.add_background_rectangle() label.next_to(line, vect, buff = SMALL_BUFF) - label.highlight(line.get_color()) + label.set_color(line.get_color()) label.scale( 1./self.zoom_factor, about_point = line.get_center() @@ -2503,8 +2503,8 @@ class DerivativeOfNaturalLog(ZoomedScene): ) new_dy, new_dx, new_eq, one_over, new_e, new_y = rearranged new_ey_group = VGroup(new_e, new_y) - new_dx.highlight(GREEN) - new_dy.highlight(RED) + new_dx.set_color(GREEN) + new_dy.set_color(RED) rearranged.shift(eq.get_center() - new_eq.get_center()) rearranged.shift(MED_SMALL_BUFF*DOWN) new_rect = BackgroundRectangle(rearranged) @@ -2529,14 +2529,14 @@ class DerivativeOfNaturalLog(ZoomedScene): #Change denominator e, y, eq, x = self.new_formula ey_group = VGroup(e, y).copy() - ey_group.highlight(YELLOW) + ey_group.set_color(YELLOW) x_copy = x.copy() - self.play(new_ey_group.highlight, YELLOW) + self.play(new_ey_group.set_color, YELLOW) self.play(Transform(new_ey_group, ey_group)) self.play( - new_ey_group.highlight, WHITE, - x_copy.highlight, YELLOW + new_ey_group.set_color, WHITE, + x_copy.set_color, YELLOW ) self.play(x_copy.next_to, one_over, DOWN, MED_SMALL_BUFF) self.wait(2) @@ -2596,7 +2596,7 @@ class FinalWords(TeacherStudentsScene): "Multivariable", "calculus" ) mvc = VGroup(*words[1:]) - words.highlight_by_tex("Multivariable", YELLOW) + words.set_color_by_tex("Multivariable", YELLOW) formula = TexMobject("f(x, y) = \\sin(x)y^2") formula.next_to(self.get_teacher().get_corner(UP+LEFT), UP) @@ -2628,7 +2628,7 @@ class FinalWords(TeacherStudentsScene): ), ) self.play( - video.highlight, YELLOW, + video.set_color, YELLOW, video.shift, video.get_height()*DOWN/2 ) lim.next_to(video, DOWN) diff --git a/old_projects/eoc/chapter7.py b/old_projects/eoc/chapter7.py index a37963bc..22bf2f81 100644 --- a/old_projects/eoc/chapter7.py +++ b/old_projects/eoc/chapter7.py @@ -75,8 +75,8 @@ class ThisVideo(TeacherStudentsScene): ] deriv_tex, this_tex, integral_tex = tex_mobs for tex_mob, brace in zip(tex_mobs, braces): - tex_mob.highlight_by_tex("f", GREEN) - tex_mob.highlight_by_tex("dx", YELLOW) + tex_mob.set_color_by_tex("f", GREEN) + tex_mob.set_color_by_tex("dx", YELLOW) tex_mob.next_to(brace, DOWN) integral_tex.shift(LARGE_BUFF*RIGHT) @@ -96,7 +96,7 @@ class ThisVideo(TeacherStudentsScene): Write(tex_mob, run_time = 2) ) self.play( - this_video.highlight, YELLOW, + this_video.set_color, YELLOW, GrowFromCenter(this_brace), self.get_teacher().change_mode, "raise_right_hand", self.get_teacher().look_at, this_video @@ -154,7 +154,7 @@ class LimitJustMeansApproach(PiCreatureScene): def get_limit_expression(self): lim = TexMobject("\\lim_", "{dx", " \\to 0}") - lim.highlight_by_tex("dx", self.dx_color) + lim.set_color_by_tex("dx", self.dx_color) ratio = self.get_expression("dx") ratio.next_to(lim, RIGHT) limit_expression = VGroup(lim, ratio) @@ -177,7 +177,7 @@ class LimitJustMeansApproach(PiCreatureScene): result = TexMobject( "{(2 + ", str(dx), ")^3 - 2^3 \\over", str(dx) ) - result.highlight_by_tex(dx, self.dx_color) + result.set_color_by_tex(dx, self.dx_color) return result class Goals(Scene): @@ -237,9 +237,9 @@ class RefreshOnDerivativeDefinition(GraphScene): derivative = TexMobject( "{df", "\\over \\,", "dx}", "(", str(self.start_x), ")" ) - derivative.highlight_by_tex("df", self.df_color) - derivative.highlight_by_tex("dx", self.dx_color) - derivative.highlight_by_tex(str(self.start_x), RED) + derivative.set_color_by_tex("df", self.df_color) + derivative.set_color_by_tex("dx", self.dx_color) + derivative.set_color_by_tex(str(self.start_x), RED) df = derivative.get_part_by_tex("df") dx = derivative.get_part_by_tex("dx") input_x = derivative.get_part_by_tex(str(self.start_x)) @@ -247,7 +247,7 @@ class RefreshOnDerivativeDefinition(GraphScene): derivative.save_state() deriv_brace = Brace(derivative) dx_to_0 = TexMobject("dx", "\\to 0") - dx_to_0.highlight_by_tex("dx", self.dx_color) + dx_to_0.set_color_by_tex("dx", self.dx_color) dx_to_0.next_to(deriv_brace, DOWN) #Introduce graph @@ -299,9 +299,9 @@ class RefreshOnDerivativeDefinition(GraphScene): "-", "f", "(", str(self.start_x), ")", "\\over \\,", "dx" ) - new_deriv.highlight_by_tex("dx", self.dx_color) - new_deriv.highlight_by_tex("f", self.df_color) - new_deriv.highlight_by_tex(str(self.start_x), RED) + new_deriv.set_color_by_tex("dx", self.dx_color) + new_deriv.set_color_by_tex("f", self.df_color) + new_deriv.set_color_by_tex(str(self.start_x), RED) deriv_to_new_deriv = dict([ ( VGroup(derivative.get_part_by_tex(s)), @@ -351,7 +351,7 @@ class RefreshOnDerivativeDefinition(GraphScene): for sf, color in (1.2, YELLOW), (1/1.2, WHITE): self.play( lim.scale_in_place, sf, - lim.highlight, color, + lim.set_color, color, submobject_mode = "lagged_start" ) self.wait(2) @@ -433,7 +433,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS dx_list_replacement = [ TexMobject( tex - ).highlight(self.dx_color).move_to(dx, DOWN) + ).set_color(self.dx_color).move_to(dx, DOWN) for dx in dx_list ] self.play( @@ -477,7 +477,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS built in """) d_words.next_to(d_circles, DOWN) - d_words.highlight(d_circles[0].get_color()) + d_words.set_color(d_circles[0].get_color()) lhs_rect, rhs_rect = rects = [ Rectangle(color = GREEN_B).replace( @@ -493,7 +493,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS """) formal_definition_words.scale_to_fit_width(rhs_rect.get_width()) formal_definition_words.next_to(rhs_rect, UP) - formal_definition_words.highlight(rhs_rect.get_color()) + formal_definition_words.set_color(rhs_rect.get_color()) formal_definition_words.add_background_rectangle() df = VGroup(lhs.get_part_by_tex("df")) @@ -574,7 +574,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS buff = LARGE_BUFF, ) arrow = Arrow(words.get_top(), self.rhs_rect.get_bottom()) - arrow.highlight(WHITE) + arrow.set_color(WHITE) h_group = VGroup( self.rhs[1].get_part_by_tex("dx"), @@ -585,7 +585,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS dx_group = VGroup() for h in h_group: dx = TexMobject("dx") - dx.highlight(h.get_color()) + dx.set_color(h.get_color()) dx.replace(h, dim_to_match = 1) dx_group.add(dx) moving_dx = dx_group[0] @@ -629,7 +629,7 @@ class DiscussLowercaseDs(RefreshOnDerivativeDefinition, PiCreatureScene, ZoomedS dx = self.ss_group.dx_label dx.save_state() h = TexMobject("h") - h.highlight(dx.get_color()) + h.set_color(dx.get_color()) h.replace(dx, dim_to_match = 1) self.play(Transform(dx, h, path_arc = np.pi)) self.play(Indicate(dx)) @@ -664,7 +664,7 @@ class OtherViewsOfDx(TeacherStudentsScene): "2" : RED } for tex, color in tex_to_color.items(): - definition.highlight_by_tex(tex, color) + definition.set_color_by_tex(tex, color) definition.scale(0.8) definition.to_corner(UP+LEFT) dx_group = VGroup(*definition.get_parts_by_tex("dx")) @@ -684,7 +684,7 @@ class OtherViewsOfDx(TeacherStudentsScene): statement.h, statement.dx = [ VGroup(*statement.get_parts_by_tex( tex, substring = False - )).highlight(GREEN) + )).set_color(GREEN) for tex in "$h$", "$dx$" ] @@ -782,9 +782,9 @@ class GoalsListed(Scene): self.play(FadeIn(goal)) self.wait() for i, goal in enumerate(goals): - anims = [goal.highlight, YELLOW] + anims = [goal.set_color, YELLOW] if i > 0: - anims += [goals[i-1].highlight, WHITE] + anims += [goals[i-1].set_color, WHITE] self.play(*anims) self.wait() @@ -835,7 +835,7 @@ class GraphLimitExpression(GraphScene): } for tex_mob in expression, limit, derivative: for tex, color in tex_to_color.items(): - tex_mob.highlight_by_tex(tex, color) + tex_mob.set_color_by_tex(tex, color) tex_mob.next_to(ORIGIN, RIGHT, LARGE_BUFF) tex_mob.to_edge(UP) @@ -882,7 +882,7 @@ class GraphLimitExpression(GraphScene): ) self.wait() - colored_graph = graph.copy().highlight(YELLOW) + colored_graph = graph.copy().set_color(YELLOW) self.play(ShowCreation(colored_graph)) self.wait() self.play(ShowCreation(graph)) @@ -900,20 +900,20 @@ class GraphLimitExpression(GraphScene): h_equals_0 = TexMobject("h", "=", "0", "?") h_equals_0.next_to(self.graph_origin, UP+RIGHT, LARGE_BUFF) for tex in "h", "0": - h_equals_0.highlight_by_tex(tex, GREEN) + h_equals_0.set_color_by_tex(tex, GREEN) arrow = Arrow(h_equals_0.get_left(), self.graph_origin) - arrow.highlight(WHITE) + arrow.set_color(WHITE) new_expression = expression.deepcopy() h_group = VGroup(*new_expression.get_parts_by_tex("h")) for h in h_group: zero = TexMobject("0") - zero.highlight(h.get_color()) + zero.set_color(h.get_color()) zero.replace(h, dim_to_match = 1) Transform(h, zero).update(1) rhs = TexMobject("=", "{\\, 0\\,", "\\over \\,", "0\\,}") - rhs.highlight_by_tex("0", GREEN) + rhs.set_color_by_tex("0", GREEN) rhs.next_to(new_expression, RIGHT) equation = VGroup(new_expression, rhs) equation.next_to(expression, DOWN, buff = LARGE_BUFF) @@ -1333,11 +1333,11 @@ class LimitCounterExample(GraphLimitExpression): limit = TexMobject( "\\lim", "_{h", "\\to 0}", "f(", "h", ")" ) - limit.highlight_by_tex("h", GREEN) + limit.set_color_by_tex("h", GREEN) limit.move_to(self.coords_to_point(2, 1.5)) words = TextMobject("is not defined") - words.highlight(RED) + words.set_color(RED) words.next_to(limit, RIGHT, align_using_submobjects = True) limit_group = VGroup(limit, words) @@ -1457,7 +1457,7 @@ class PrefaceToEpsilonDeltaDefinition(TeacherStudentsScene): "It's a glimpse of\\\\", "real analysis" ) - words.highlight_by_tex("real", YELLOW) + words.set_color_by_tex("real", YELLOW) self.teacher_says( words, bubble_kwargs = {"height" : 3, "width" : 6} @@ -1762,10 +1762,10 @@ class TheoryHeavy(TeacherStudentsScene): derivative = VGroup(lhs, equals, rhs) derivative.arrange_submobjects(RIGHT) for tex_mob in derivative: - tex_mob.highlight_by_tex("x", RED) - tex_mob.highlight_by_tex("h", GREEN) - tex_mob.highlight_by_tex("dx", GREEN) - tex_mob.highlight_by_tex("f", YELLOW) + tex_mob.set_color_by_tex("x", RED) + tex_mob.set_color_by_tex("h", GREEN) + tex_mob.set_color_by_tex("dx", GREEN) + tex_mob.set_color_by_tex("f", YELLOW) derivative.next_to(self.get_pi_creatures(), UP, buff = MED_LARGE_BUFF) lim = rhs.get_part_by_tex("lim") @@ -1884,11 +1884,11 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi def setup_axes(self): GraphScene.setup_axes(self) - self.x_axis_label_mob.highlight(self.x_color) + self.x_axis_label_mob.set_color(self.x_color) def introduce_function(self): graph = self.get_graph(self.func) - colored_graph = graph.copy().highlight(YELLOW) + colored_graph = graph.copy().set_color(YELLOW) func_label = self.get_func_label() func_label.next_to(ORIGIN, RIGHT, buff = LARGE_BUFF) func_label.to_edge(UP) @@ -1920,7 +1920,7 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi def show_non_definedness_at_one(self): morty = self.get_primary_pi_creature() words = TexMobject("\\text{Try }", "x", "=1") - words.highlight_by_tex("x", self.x_color, substring = False) + words.set_color_by_tex("x", self.x_color, substring = False) v_line, alt_v_line = [ self.get_vertical_line_to_graph( @@ -1946,7 +1946,7 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi func_1_group.add_to_back(BackgroundRectangle(func_1_group)) lim = TexMobject("\\lim", "_{x", "\\to 1}") - lim.highlight_by_tex("x", self.x_color) + lim.set_color_by_tex("x", self.x_color) lim.move_to(self.func_label, LEFT) self.func_label.generate_target() self.func_label.target.next_to(lim, RIGHT) @@ -2191,8 +2191,8 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi d_labels = [] for tex_args, arrow in tex_arrow_pairs: label = TexMobject(*tex_args) - label.highlight_by_tex("x", self.x_color) - label.highlight_by_tex("dx", self.dx_color) + label.set_color_by_tex("x", self.x_color) + label.set_color_by_tex("dx", self.dx_color) label.scale(zoom_tex_scale_factor) label.next_to(arrow, RIGHT, buff = SMALL_BUFF/self.zoom_factor) d_labels.append(label) @@ -2336,11 +2336,11 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi buff = MED_SMALL_BUFF/self.zoom_factor, aligned_edge = LEFT ) - equation.highlight_by_tex("x", self.x_color) - equation.highlight_by_tex("1", self.x_color) + equation.set_color_by_tex("x", self.x_color) + equation.set_color_by_tex("1", self.x_color) dot_one = TexMobject("\\cdot", "1") dot_one.scale(zoom_tex_scale_factor) - dot_one.highlight(self.x_color) + dot_one.set_color(self.x_color) dot_one.move_to(x, DOWN+LEFT) self.play(x.move_to, eq_x) @@ -2440,7 +2440,7 @@ class LHopitalExample(LimitCounterExample, PiCreatureScene, ZoomedScene, Reconfi "{\\sin(\\pi ", in_tex, ")", " \\over \\,", in_tex, "^2 - 1}" ) - result.highlight_by_tex(in_tex, self.x_color) + result.set_color_by_tex(in_tex, self.x_color) return result def get_epsilon_delta_group(self, delta, **kwargs): @@ -2465,11 +2465,11 @@ class DerivativeLimitReciprocity(Scene): def construct(self): arrow = Arrow(LEFT, RIGHT, color = WHITE) lim = TexMobject("\\lim", "_{h", "\\to 0}") - lim.highlight_by_tex("h", GREEN) + lim.set_color_by_tex("h", GREEN) lim.next_to(arrow, LEFT) deriv = TexMobject("{df", "\\over\\,", "dx}") - deriv.highlight_by_tex("dx", GREEN) - deriv.highlight_by_tex("df", YELLOW) + deriv.set_color_by_tex("dx", GREEN) + deriv.set_color_by_tex("df", YELLOW) deriv.next_to(arrow, RIGHT) self.play(FadeIn(lim, submobject_mode = "lagged_start")) @@ -2520,7 +2520,7 @@ class GeneralLHoptial(LHopitalExample): a_label = TexMobject("x = a") a_label.next_to(a_dot, UP, LARGE_BUFF) a_arrow = Arrow(a_label.get_bottom(), a_dot, buff = SMALL_BUFF) - VGroup(a_dot, a_label, a_arrow).highlight(self.x_color) + VGroup(a_dot, a_label, a_arrow).set_color(self.x_color) self.play(ShowCreation(f_graph), Write(f_label)) self.play(ShowCreation(g_graph), Write(g_label)) @@ -2559,7 +2559,7 @@ class GeneralLHoptial(LHopitalExample): frac_a = self.get_frac("a", self.x_color) frac_x = self.get_frac("x") lim = TexMobject("\\lim", "_{x", "\\to", "a}") - lim.highlight_by_tex("a", self.x_color) + lim.set_color_by_tex("a", self.x_color) equals_zero_over_zero = TexMobject( "=", "{\\, 0 \\,", "\\over \\,", "0 \\,}" ) @@ -2645,8 +2645,8 @@ class GeneralLHoptial(LHopitalExample): "\\frac{d%s}{dx}"%char, "(", "a", ")", "\\,dx" ) label.scale(zoom_tex_scale_factor) - label.highlight_by_tex("a", self.x_color) - label.highlight_by_tex("frac", arrow.get_color()) + label.set_color_by_tex("a", self.x_color) + label.set_color_by_tex("frac", arrow.get_color()) label.next_to(arrow, RIGHT, z_small_buff) v_labels.append(label) df_label, dg_label = v_labels @@ -2672,9 +2672,9 @@ class GeneralLHoptial(LHopitalExample): "\\over \\,", "\\frac{dg}{dx}", "(", "a", ")", "\\,dx}", ) - deriv_ratio.highlight_by_tex("a", self.x_color) - deriv_ratio.highlight_by_tex("df", self.f_color) - deriv_ratio.highlight_by_tex("dg", self.g_color) + deriv_ratio.set_color_by_tex("a", self.x_color) + deriv_ratio.set_color_by_tex("df", self.f_color) + deriv_ratio.set_color_by_tex("dg", self.g_color) deriv_ratio.move_to(q_marks, LEFT) dxs = VGroup(*deriv_ratio.get_parts_by_tex("\\,dx")) @@ -2712,7 +2712,7 @@ class GeneralLHoptial(LHopitalExample): equation = VGroup(lhs, rhs) equation.to_corner(UP+RIGHT) for part in equation: - part.highlight_by_tex("0", self.x_color) + part.set_color_by_tex("0", self.x_color) brace = Brace(lhs, DOWN) brace_text = brace.get_text("Looks like 0/0") brace_text.add_background_rectangle() @@ -2778,7 +2778,7 @@ class GeneralLHoptial(LHopitalExample): for dollar, alpha in zip(dollars, np.linspace(0, 1, len(dollars))): angle = alpha*np.pi dollar.move_to(np.sin(angle)*RIGHT + np.cos(angle)*UP) - dollars.highlight(GREEN) + dollars.set_color(GREEN) dollars.next_to(arrow, RIGHT, MED_LARGE_BUFF) dollars[0].set_fill(opacity = 0) dollars.save_state() @@ -2818,9 +2818,9 @@ class GeneralLHoptial(LHopitalExample): "{f", "(", input_tex, ")", "\\over \\,", "g", "(", input_tex, ")}" ) - result.highlight_by_tex("f", self.f_color) - result.highlight_by_tex("g", self.g_color) - result.highlight_by_tex(input_tex, color) + result.set_color_by_tex("f", self.f_color) + result.set_color_by_tex("g", self.g_color) + result.set_color_by_tex(input_tex, color) result.numerator = VGroup(*result[:4]) result.denominator = VGroup(*result[-4:]) @@ -2838,10 +2838,10 @@ class CannotUseLHopital(TeacherStudentsScene): "\\over \\,", "h}" ) deriv.to_edge(UP) - deriv.highlight_by_tex("x", RED) - deriv.highlight_by_tex("dx", GREEN) - deriv.highlight_by_tex("h", GREEN) - deriv.highlight_by_tex("e^", YELLOW) + deriv.set_color_by_tex("x", RED) + deriv.set_color_by_tex("dx", GREEN) + deriv.set_color_by_tex("h", GREEN) + deriv.set_color_by_tex("e^", YELLOW) self.play( Write(deriv), @@ -2860,8 +2860,8 @@ class CannotUseLHopital(TeacherStudentsScene): "\\text{That requires knowing }", "{d(e^x)", "\\over \\,", "dx}" ) - answer.highlight_by_tex("e^", YELLOW) - answer.highlight_by_tex("dx", GREEN) + answer.set_color_by_tex("e^", YELLOW) + answer.set_color_by_tex("dx", GREEN) self.teacher_says( answer, bubble_kwargs = {"height" : 2.5}, @@ -2883,15 +2883,15 @@ class NextVideo(TeacherStudentsScene): "{dF", "\\over \\,", "dx}", "(x)", "dx" ) for tex_mob in integral, ftc: - tex_mob.highlight_by_tex("dx", GREEN) - tex_mob.highlight_by_tex("f", YELLOW) - tex_mob.highlight_by_tex("F", YELLOW) + tex_mob.set_color_by_tex("dx", GREEN) + tex_mob.set_color_by_tex("f", YELLOW) + tex_mob.set_color_by_tex("F", YELLOW) tex_mob.next_to(brace, DOWN) self.add(series) self.play( GrowFromCenter(brace), - next_video.highlight, YELLOW, + next_video.set_color, YELLOW, self.get_teacher().change_mode, "raise_right_hand", self.get_teacher().look_at, next_video ) @@ -2960,7 +2960,7 @@ class Chapter7PatreonThanks(PatreonThanks): class Thumbnail(Scene): def construct(self): lim = TexMobject("\\lim", "_{h", "\\to 0}") - lim.highlight_by_tex("h", GREEN) + lim.set_color_by_tex("h", GREEN) lim.scale_to_fit_height(5) self.add(lim) diff --git a/old_projects/eoc/chapter8.py b/old_projects/eoc/chapter8.py index 13207624..7c18b8ef 100644 --- a/old_projects/eoc/chapter8.py +++ b/old_projects/eoc/chapter8.py @@ -103,8 +103,8 @@ class Chapter8OpeningQuote(OpeningQuote, PiCreatureScene): "\\sin(", "h", ")\\cos(\\theta)\\big] - \\sin(\\theta) \\over", "h}", "= \\dots" ) - result.highlight_by_tex("h", GREEN, substring = False) - result.highlight_by_tex("d\\theta", GREEN) + result.set_color_by_tex("h", GREEN, substring = False) + result.set_color_by_tex("d\\theta", GREEN) result.scale_to_fit_width(FRAME_WIDTH - 2*MED_SMALL_BUFF) return result @@ -122,13 +122,13 @@ class ThisVideo(TeacherStudentsScene): "\\int_0^T", "v(t)", "\\,dt", "=", "v(T)" ) - formula.highlight_by_tex("v", VELOCITY_COLOR) + formula.set_color_by_tex("v", VELOCITY_COLOR) formula.next_to(self.teacher.get_corner(UP+LEFT), UP, MED_LARGE_BUFF) self.play(FadeIn(series, submobject_mode = "lagged_start")) self.play( this_video.shift, this_video.get_height()*DOWN/2, - this_video.highlight, YELLOW, + this_video.set_color, YELLOW, self.teacher.change_mode, "raise_right_hand", ) self.play(Write(VGroup(integral, v_t, dt))) @@ -140,7 +140,7 @@ class ThisVideo(TeacherStudentsScene): self.play( this_video.restore, next_video.shift, next_video.get_height()*DOWN/2, - next_video.highlight, YELLOW, + next_video.set_color, YELLOW, integral[0].copy().next_to, next_video, DOWN, MED_LARGE_BUFF, FadeOut(formula), *it.chain(*[ @@ -178,7 +178,7 @@ class InCarRestrictedView(ShowSpeedometer): dots = VGroup(*map(Dot, [self.point_A, self.point_B])) line = Line(*dots, buff = 0) - line.highlight(DISTANCE_COLOR) + line.set_color(DISTANCE_COLOR) brace = Brace(line, DOWN) brace_text = brace.get_text("Distance traveled?") @@ -298,7 +298,7 @@ class PlotVelocity(GraphScene): for t in times ] dots = VGroup(*[Dot(p, radius = 0.07) for p in points]) - dots.highlight(VELOCITY_COLOR) + dots.set_color(VELOCITY_COLOR) pre_dots = VGroup() dot_intro_anims = [] @@ -355,7 +355,7 @@ class PlotVelocity(GraphScene): color = VELOCITY_COLOR ) graph_label = TexMobject("v(t)", "=t(8-t)") - graph_label.highlight_by_tex("v(t)", VELOCITY_COLOR) + graph_label.set_color_by_tex("v(t)", VELOCITY_COLOR) graph_label.next_to( graph.point_from_proportion(7./8.), UP+RIGHT @@ -418,8 +418,8 @@ class AskAboutAntiderivative(PlotVelocity): def write_s_formula(self): ds_dt = TexMobject("ds", "\\over\\,", "dt") - ds_dt.highlight_by_tex("ds", DISTANCE_COLOR) - ds_dt.highlight_by_tex("dt", TIME_COLOR) + ds_dt.set_color_by_tex("ds", DISTANCE_COLOR) + ds_dt.set_color_by_tex("dt", TIME_COLOR) ds_dt.next_to(self.graph_label, UP, LARGE_BUFF) v_t = self.graph_label.get_part_by_tex("v(t)") @@ -441,9 +441,9 @@ class AskAboutAntiderivative(PlotVelocity): words = TexMobject( "{d(", "???", ") \\over \\,", "dt}", "=", "t(8-t)" ) - words.highlight_by_tex("t(8-t)", VELOCITY_COLOR) - words.highlight_by_tex("???", DISTANCE_COLOR) - words.highlight_by_tex("dt", TIME_COLOR) + words.set_color_by_tex("t(8-t)", VELOCITY_COLOR) + words.set_color_by_tex("???", DISTANCE_COLOR) + words.set_color_by_tex("dt", TIME_COLOR) words.scale(0.7) self.play(FadeIn(randy)) @@ -490,10 +490,10 @@ class Antiderivative(PiCreatureScene): def get_functions(self, left_tex, right_tex): left = TexMobject(left_tex) left.shift(2*LEFT) - left.highlight(DISTANCE_COLOR) + left.set_color(DISTANCE_COLOR) right = TexMobject(right_tex) right.shift(2*RIGHT) - right.highlight(VELOCITY_COLOR) + right.set_color(VELOCITY_COLOR) result = VGroup(left, right) result.shift(UP) return result @@ -511,7 +511,7 @@ class Antiderivative(PiCreatureScene): arc.add_tip() top_arc.next_to(top_line, UP) bottom_arc.next_to(bottom_line, DOWN) - bottom_arc.highlight(MAROON_B) + bottom_arc.set_color(MAROON_B) return arcs @@ -521,7 +521,7 @@ class Antiderivative(PiCreatureScene): derivative.next_to(top_arc, UP) antiderivative = TextMobject("``Antiderivative''") antiderivative.next_to(bottom_arc, DOWN) - antiderivative.highlight(bottom_arc.get_color()) + antiderivative.set_color(bottom_arc.get_color()) return VGroup(derivative, antiderivative) @@ -611,15 +611,15 @@ class ConstantVelocityPlot(PlotVelocity): v_label = right_brace.get_text( "$10 \\frac{\\text{meters}}{\\text{second}}$", ) - v_label.highlight(VELOCITY_COLOR) + v_label.set_color(VELOCITY_COLOR) t_label = top_brace.get_text( "8 seconds" ) - t_label.highlight(TIME_COLOR) + t_label.set_color(TIME_COLOR) s_label = TexMobject("10", "\\times", "8", "\\text{ meters}") - s_label.highlight_by_tex("10", VELOCITY_COLOR) - s_label.highlight_by_tex("8", TIME_COLOR) + s_label.set_color_by_tex("10", VELOCITY_COLOR) + s_label.set_color_by_tex("8", TIME_COLOR) s_label.move_to(rect) self.play( @@ -657,7 +657,7 @@ class ConstantVelocityPlot(PlotVelocity): self.play(FadeIn(randy)) self.play(randy.change_mode, "pondering") self.play( - self.area_rect.highlight, YELLOW, + self.area_rect.set_color, YELLOW, *map(Animation, self.get_mobjects()), rate_func = there_and_back ) @@ -684,7 +684,7 @@ class ConstantVelocityPlot(PlotVelocity): axis.main_line.copy() for axis in self.x_axis, self.y_axis ]) - lines.highlight(TIME_COLOR) + lines.set_color(TIME_COLOR) square = Square( stroke_color = BLACK, stroke_width = 1, @@ -821,13 +821,13 @@ class PiecewiseConstantPlot(PlotVelocity): def show_piecewise_constant_graph(self): pw_constant_graph = self.get_pw_constant_graph() alt_lines = [ - line.copy().highlight(YELLOW) + line.copy().set_color(YELLOW) for line in pw_constant_graph[:4] ] for line in alt_lines: line.start_dot = Dot(line.get_start()) line.end_dot = Dot(line.get_end()) - VGroup(line.start_dot, line.end_dot).highlight(line.get_color()) + VGroup(line.start_dot, line.end_dot).set_color(line.get_color()) line = alt_lines[0] faders = [self.v_graph, self.v_graph_label] @@ -928,7 +928,7 @@ class PiecewiseConstantPlot(PlotVelocity): "$dt$", "$=0.25$" ) example_text.to_corner(UP+RIGHT) - example_text.highlight_by_tex("dt", YELLOW) + example_text.set_color_by_tex("dt", YELLOW) self.play(ReplacementTransform( rects, target_rects, @@ -1054,7 +1054,7 @@ class PiecewiseConstantPlot(PlotVelocity): for group in v_lines, h_lines, height_labels ])) self.play( - v_lines[0].highlight, RED, + v_lines[0].set_color, RED, rate_func = there_and_back, ) self.wait() @@ -1158,7 +1158,7 @@ class PiecewiseConstantPlot(PlotVelocity): for mob, tex in (self.v_t, "v(t)"), (self.dt_label, "dt"): self.play(ReplacementTransform( - mob.copy().highlight(YELLOW), + mob.copy().set_color(YELLOW), integral.get_part_by_tex(tex), run_time = 2 )) @@ -1181,7 +1181,7 @@ class PiecewiseConstantPlot(PlotVelocity): morty.change_mode, "raise_right_hand", morty.look, UP+RIGHT, dt_copy.next_to, morty.get_corner(UP+RIGHT), UP, - dt_copy.highlight, YELLOW + dt_copy.set_color, YELLOW ) self.play(Blink(morty)) self.play( @@ -1267,7 +1267,7 @@ class PiecewiseConstantPlot(PlotVelocity): cross = TexMobject("\\times") cross.replace(self.sum_word, stretch = True) - cross.highlight(RED) + cross.set_color(RED) brace = Brace(self.integral, DOWN) dt_to_0 = brace.get_text("$dt \\to 0$") @@ -1367,7 +1367,7 @@ class PiecewiseConstantPlot(PlotVelocity): self.coords_to_point(x, y) for x in xs ]) - line.highlight(self.v_graph.get_color()) + line.set_color(self.v_graph.get_color()) result.add(line) return result @@ -1380,7 +1380,7 @@ class PiecewiseConstantPlot(PlotVelocity): for t in np.linspace(0, 8, len(rects)+1) for point in [self.coords_to_point(t, 0)] ]) - ticks.highlight(YELLOW) + ticks.set_color(YELLOW) return ticks class DontKnowHowToHandleNonConstant(TeacherStudentsScene): @@ -1404,7 +1404,7 @@ class CarJourneyApproximation(Scene): TextMobject("Real motion (smooth)").shift(3*UP), TextMobject(self.bottom_words).shift(0.5*DOWN), ] - words[1].highlight(GREEN) + words[1].set_color(GREEN) self.add(h_line, *cars + words) @@ -1560,7 +1560,7 @@ class AreaIsDerivative(PlotVelocity, ReconfigurableScene): moving_T = self.T_label_group[0] s_T = TexMobject("s(T)", "= ") - s_T.highlight_by_tex("s", DISTANCE_COLOR) + s_T.set_color_by_tex("s", DISTANCE_COLOR) s_T.next_to(integral, LEFT) int_arrow, s_arrow = [ @@ -1635,9 +1635,9 @@ class AreaIsDerivative(PlotVelocity, ReconfigurableScene): ds_label = TexMobject("ds") ds_label.next_to(rect, RIGHT, LARGE_BUFF, UP) - ds_label.highlight(DISTANCE_COLOR) + ds_label.set_color(DISTANCE_COLOR) ds_arrow = Arrow(ds_label.get_left(), rect.get_left()) - ds_arrow.highlight(WHITE) + ds_arrow.set_color(WHITE) v_brace = Brace(rect, LEFT, buff = SMALL_BUFF) v_T_label = v_brace.get_text("$v(T)$", buff = SMALL_BUFF) @@ -1677,7 +1677,7 @@ class AreaIsDerivative(PlotVelocity, ReconfigurableScene): formula2 = TexMobject("{ds", "\\over\\,", "dT}", "=", "v(T)") for formula in formula1, formula2: formula.next_to(self.v_graph_label, UP, LARGE_BUFF) - formula.highlight_by_tex("ds", DISTANCE_COLOR) + formula.set_color_by_tex("ds", DISTANCE_COLOR) self.play( DrawBorderThenFill(self.rect), @@ -1767,7 +1767,7 @@ class AreaIsDerivative(PlotVelocity, ReconfigurableScene): new_v_line = self.get_vertical_line_to_graph( t_max, self.v_graph ) - new_v_line.highlight(v_line.get_color()) + new_v_line.set_color(v_line.get_color()) T_label.move_to(new_v_line.get_bottom(), UP) #Fade close to 0 @@ -1789,21 +1789,21 @@ class DirectInterpretationOfDsDt(TeacherStudentsScene): ds, over, dt, of_T, equals, v = equation equation.next_to(self.get_pi_creatures(), UP, LARGE_BUFF) equation.shift(RIGHT) - v.highlight(VELOCITY_COLOR) + v.set_color(VELOCITY_COLOR) s_words = TextMobject("Tiny change in", "distance") s_words.next_to(ds, UP+LEFT, LARGE_BUFF) s_words.shift_onto_screen() s_arrow = Arrow(s_words[1].get_bottom(), ds.get_left()) s_words.add(s_arrow) - s_words.highlight(DISTANCE_COLOR) + s_words.set_color(DISTANCE_COLOR) t_words = TextMobject("Tiny change in", "time") t_words.next_to(dt, DOWN+LEFT) t_words.to_edge(LEFT) t_arrow = Arrow(t_words[1].get_top(), dt.get_left()) t_words.add(t_arrow) - t_words.highlight(TIME_COLOR) + t_words.set_color(TIME_COLOR) self.add(ds, over, dt, of_T) for words, part in (s_words, ds), (t_words, dt): @@ -1815,7 +1815,7 @@ class DirectInterpretationOfDsDt(TeacherStudentsScene): ), self.students[1].change_mode, "raise_right_hand" ) - self.play(part.highlight, words.get_color()) + self.play(part.set_color, words.get_color()) self.wait() self.play(Write(VGroup(equals, v))) self.change_student_modes(*["pondering"]*3) @@ -1833,7 +1833,7 @@ class FindAntiderivative(Antiderivative): q_marks, rhs = functions = self.get_functions("???", "t(8-t)") expanded_rhs = TexMobject("8t - t^2") expanded_rhs.move_to(rhs, LEFT) - expanded_rhs.highlight(rhs.get_color()) + expanded_rhs.set_color(rhs.get_color()) self.v_part1 = VGroup(*expanded_rhs[:2]) self.v_part2 = VGroup(*expanded_rhs[2:]) for part in self.v_part1, self.v_part2: @@ -1902,7 +1902,7 @@ class FindAntiderivative(Antiderivative): self.play(four.shift, DOWN) self.play(FadeOut(two_t)) self.play(self.v_part1.restore) - self.play(four.highlight, DISTANCE_COLOR) + self.play(four.set_color, DISTANCE_COLOR) self.wait(2) self.s_part1 = four_t_squared @@ -1983,7 +1983,7 @@ class FindAntiderivative(Antiderivative): for d in range(1, 8) ] for plus_C in plus_Cs: - plus_C.highlight(YELLOW) + plus_C.set_color(YELLOW) plus_C.move_to(s_group, RIGHT) plus_C = plus_Cs[0] @@ -2017,11 +2017,11 @@ class GraphSPlusC(GraphDistanceVsTime): 6, graph, line_class = DashedLine ) v_line.scale_in_place(2) - v_line.highlight(WHITE) + v_line.set_color(WHITE) graph_label, plus_C = full_label = TexMobject( "s(t) = 4t^2 - \\frac{1}{3}t^3", "+C" ) - plus_C.highlight(YELLOW) + plus_C.set_color(YELLOW) full_label.next_to(graph.points[-1], DOWN) full_label.to_edge(RIGHT) @@ -2089,7 +2089,7 @@ class LowerBound(AreaIsDerivative): def drag_right_endpoint_to_zero(self): zero_integral = self.get_integral("0", "0") - zero_integral[1].highlight(YELLOW) + zero_integral[1].set_color(YELLOW) zero_int_bounds = list(reversed( zero_integral.get_parts_by_tex("0") )) @@ -2101,7 +2101,7 @@ class LowerBound(AreaIsDerivative): self.integral.save_state() equals_zero = TexMobject("=0") equals_zero.next_to(zero_integral, RIGHT) - equals_zero.highlight(GREEN) + equals_zero.set_color(GREEN) self.change_area_bounds(0, 0, run_time = 3) self.play(ReplacementTransform( @@ -2139,7 +2139,7 @@ class LowerBound(AreaIsDerivative): part.brace.save_state() antideriv_text = at_T.brace.get_text("Antiderivative", buff = SMALL_BUFF) - antideriv_text.highlight(MAROON_B) + antideriv_text.set_color(MAROON_B) value_at_eight = at_eight.brace.get_text( "%.2f"%s_func(8) ) @@ -2205,9 +2205,9 @@ class LowerBound(AreaIsDerivative): ] tex_mobs = [new_integral]+new_antideriv_diff[1::2]+numbers for tex_mob in tex_mobs: - tex_mob.highlight_by_tex("1", RED) - tex_mob.highlight_by_tex("7", GREEN) - tex_mob.highlight_by_tex("\\frac{1}{3}", WHITE) + tex_mob.set_color_by_tex("1", RED) + tex_mob.set_color_by_tex("7", GREEN) + tex_mob.set_color_by_tex("\\frac{1}{3}", WHITE) self.change_area_bounds(1, 7, run_time = 2) self.play( @@ -2226,7 +2226,7 @@ class LowerBound(AreaIsDerivative): def add_constant_to_antiderivative(self): antideriv_diff = self.antideriv_diff plus_fives = VGroup(*[TexMobject("+5") for i in range(2)]) - plus_fives.highlight(YELLOW) + plus_fives.set_color(YELLOW) for five, part in zip(plus_fives, antideriv_diff[1::2]): five.next_to(part, DOWN) group = VGroup( @@ -2271,7 +2271,7 @@ class LowerBound(AreaIsDerivative): "4", s, "^2", "-", "\\frac{1}{3}", s, "^3" "\\right))" ) - part.highlight_by_tex(s, YELLOW, substring = False) + part.set_color_by_tex(s, YELLOW, substring = False) parts.append(part) result = VGroup( TexMobject("="), parts[0], @@ -2306,8 +2306,8 @@ class FundamentalTheorem(GraphScene): integral = TexMobject("\\int", "^b", "_a", "f(x)", "\\,dx") integral.next_to(ORIGIN, LEFT) integral.to_edge(UP) - integral.highlight_by_tex("a", self.lower_bound_color) - integral.highlight_by_tex("b", self.upper_bound_color) + integral.set_color_by_tex("a", self.lower_bound_color) + integral.set_color_by_tex("b", self.upper_bound_color) graph = self.get_graph( lambda x : -0.01*x*(x-3)*(x-6)*(x-12) + 3, ) @@ -2407,8 +2407,8 @@ class FundamentalTheorem(GraphScene): deriv_F = deriv.get_part_by_tex("F") deriv.next_to(self.integral, DOWN, MED_LARGE_BUFF) rhs = TexMobject(*"=F(b)-F(a)") - rhs.highlight_by_tex("a", self.lower_bound_color) - rhs.highlight_by_tex("b", self.upper_bound_color) + rhs.set_color_by_tex("a", self.lower_bound_color) + rhs.set_color_by_tex("b", self.upper_bound_color) rhs.next_to(self.integral, RIGHT) self.play(Write(deriv)) @@ -2481,9 +2481,9 @@ class FundamentalTheorem(GraphScene): self.rhs.set_fill, None, 1, ) for label, line in reversed(zip(self.bound_labels, self.v_lines)): - new_line = line.copy().highlight(YELLOW) + new_line = line.copy().set_color(YELLOW) label.save_state() - self.play(label.highlight, YELLOW) + self.play(label.set_color, YELLOW) self.play(ShowCreation(new_line)) self.play(ShowCreation(line)) self.remove(new_line) @@ -2553,7 +2553,7 @@ class NegativeArea(GraphScene): def write_negative_area(self): words = TextMobject("Negative area") - words.highlight(RED) + words.set_color(RED) words.next_to( self.coords_to_point(7, -2), RIGHT, @@ -2617,11 +2617,11 @@ class NegativeArea(GraphScene): brace = Brace(self.nose_lines, DOWN, buff = 0) equation = TexMobject("ds", "=", "v(t)", "dt") equation.next_to(brace, DOWN, SMALL_BUFF, LEFT) - equation.highlight_by_tex("ds", DISTANCE_COLOR) - equation.highlight_by_tex("dt", TIME_COLOR) + equation.set_color_by_tex("ds", DISTANCE_COLOR) + equation.set_color_by_tex("dt", TIME_COLOR) negative = TextMobject("Negative") - negative.highlight(RED) + negative.set_color(RED) negative.next_to(equation.get_corner(UP+RIGHT), UP, LARGE_BUFF) ds_arrow, v_arrow = arrows = VGroup(*[ Arrow( @@ -2664,7 +2664,7 @@ class NegativeArea(GraphScene): dt_brace = Brace(rect, UP, buff = 0) v_brace = Brace(rect, LEFT, buff = 0) dt_label = dt_brace.get_text("$dt$", buff = SMALL_BUFF) - dt_label.highlight(YELLOW) + dt_label.set_color(YELLOW) v_label = v_brace.get_text("$v(t)$", buff = SMALL_BUFF) v_label.add_background_rectangle() @@ -2719,7 +2719,7 @@ class NextVideo(TeacherStudentsScene): self.play(FadeIn(series, submobject_mode = "lagged_start")) self.play( - next_video.highlight, YELLOW, + next_video.set_color, YELLOW, next_video.shift, next_video.get_height()*DOWN/2, self.teacher.change_mode, "raise_right_hand" ) diff --git a/old_projects/eoc/chapter9.py b/old_projects/eoc/chapter9.py index 4a4c452d..5d0f0277 100644 --- a/old_projects/eoc/chapter9.py +++ b/old_projects/eoc/chapter9.py @@ -63,7 +63,7 @@ class AverageOfContinuousVariable(GraphScene): line_class = DashedLine ) for line, color in zip(boundary_lines, self.bound_colors): - line.highlight(color) + line.set_color(color) v_line = self.get_vertical_line_to_graph( self.bounds[0], graph, color = YELLOW, ) @@ -112,7 +112,7 @@ class ThisVideo(TeacherStudentsScene): bubble_kwargs = {"height" : 3}, added_anims = [ this_video.shift, this_video.get_height()*DOWN/2, - this_video.highlight, YELLOW, + this_video.set_color, YELLOW, ] ) self.change_student_modes(*["pondering"]*3) @@ -233,7 +233,7 @@ class LengthOfDayGraph(GraphScene): self.setup_axes() self.add_graph() self.show_solar_pannel() - self.highlight_summer_months() + self.set_color_summer_months() self.mention_constants() def add_graph(self): @@ -246,8 +246,8 @@ class LengthOfDayGraph(GraphScene): ) graph_label = TexMobject("2.7\\sin(2\\pi x/365) + 12.4") graph_label.to_corner(UP+RIGHT).shift(LEFT) - VGroup(*graph_label[3:6]).highlight(graph.get_color()) - graph_label[9].highlight(YELLOW) + VGroup(*graph_label[3:6]).set_color(graph.get_color()) + graph_label[9].set_color(YELLOW) self.remove(x_label, y_label) for label in y_label, x_label: @@ -317,7 +317,7 @@ class LengthOfDayGraph(GraphScene): self.play(Blink(randy)) self.play(*map(FadeOut, [randy, panels])) - def highlight_summer_months(self): + def set_color_summer_months(self): summer_rect = Rectangle() summer_rect.set_stroke(width = 0) summer_rect.set_fill(YELLOW, opacity = 0.25) @@ -359,7 +359,7 @@ class LengthOfDayGraph(GraphScene): self.play(*[ ApplyFunction( - lambda c : c.scale_in_place(0.9).shift(SMALL_BUFF*DOWN).highlight(RED), + lambda c : c.scale_in_place(0.9).shift(SMALL_BUFF*DOWN).set_color(RED), constant, run_time = 3, rate_func = squish_rate_func(there_and_back, a, a+0.7) @@ -404,7 +404,7 @@ class AverageOfFiniteSet(Scene): brace = Brace(lines.target, UP) labels = VGroup(*[ - TexMobject(str(d)).next_to(line, UP).highlight(line.get_color()) + TexMobject(str(d)).next_to(line, UP).set_color(line.get_color()) for d, line in zip(lengths, lines) ]) plusses = [TexMobject("+") for x in range(len(lengths)-1)] @@ -510,7 +510,7 @@ class TryToAddInfinitelyManyPoints(AverageOfSineStart): h_line = Line(LEFT, RIGHT) h_line.scale_to_fit_width(start_lines.get_width()) - h_line.highlight(WHITE) + h_line.set_color(WHITE) h_line.next_to(sum_eq, DOWN, aligned_edge = LEFT) infinity = TexMobject("\\infty") @@ -540,7 +540,7 @@ class TryToAddInfinitelyManyPoints(AverageOfSineStart): self.coords_to_point(bound, 0) for bound in self.bounds ]) - VGroup(arrow, input_range).highlight(RED) + VGroup(arrow, input_range).set_color(RED) self.play(FadeIn(arrow)) self.play( @@ -815,7 +815,7 @@ class IntegralOfSine(FiniteSample): self.coords_to_point(bound, 0) for bound in self.bounds ]) - input_range.highlight(RED) + input_range.set_color(RED) #Bring back average self.play( @@ -846,7 +846,7 @@ class IntegralOfSine(FiniteSample): v_lines = self.v_lines self.play(*[ ApplyFunction( - lambda l : l.shift(0.5*UP).highlight(GREEN), + lambda l : l.shift(0.5*UP).set_color(GREEN), line, rate_func = squish_rate_func( there_and_back, a, a+0.3 @@ -858,7 +858,7 @@ class IntegralOfSine(FiniteSample): np.linspace(0, 0.7, len(self.v_lines)) ) ] + [ - num_samples_copy.highlight, GREEN + num_samples_copy.set_color, GREEN ]) self.play(FadeOut(v_lines)) self.wait() @@ -1009,7 +1009,7 @@ class LetsSolveThis(TeacherStudentsScene): "?" ) for tex_mob in expression, question: - tex_mob.highlight_by_tex("sin", BLUE) + tex_mob.set_color_by_tex("sin", BLUE) self.add(expression) self.teacher_says("Let's compute it.") @@ -1034,7 +1034,7 @@ class Antiderivative(AverageOfSineStart): self.show_difference_in_antiderivative() self.comment_on_area() self.divide_by_pi() - self.highlight_antiderivative_fraction() + self.set_color_antiderivative_fraction() self.show_slope() self.bring_back_derivative() self.show_tangent_slope() @@ -1053,8 +1053,8 @@ class Antiderivative(AverageOfSineStart): lambda x : -np.sin(x), ] ] - VGroup(cos, neg_cos).highlight(self.antideriv_color) - VGroup(sin, neg_sin).highlight(self.deriv_color) + VGroup(cos, neg_cos).set_color(self.antideriv_color) + VGroup(sin, neg_sin).set_color(self.deriv_color) labels = ["\\cos(x)", "-\\cos(x)", "\\sin(x)", "-\\sin(x)"] x_vals = [2*np.pi, 2*np.pi, 5*np.pi/2, 5*np.pi/2] vects = [UP, DOWN, UP, DOWN] @@ -1072,8 +1072,8 @@ class Antiderivative(AverageOfSineStart): "{d(", F, ")", "\\over\\,", "dx}", "(x)", "=", f, "(x)" ) - deriv.highlight_by_tex(F, self.antideriv_color) - deriv.highlight_by_tex(f, self.deriv_color) + deriv.set_color_by_tex(F, self.antideriv_color) + deriv.set_color_by_tex(f, self.deriv_color) deriv.to_edge(UP) derivs.append(deriv) cos_deriv, neg_cos_deriv = derivs @@ -1184,10 +1184,10 @@ class Antiderivative(AverageOfSineStart): ] for tex_mob in integral, rhs: - tex_mob.highlight_by_tex("sin", self.deriv_color) - tex_mob.highlight_by_tex("cos", self.antideriv_color) - tex_mob.highlight_by_tex("0", YELLOW) - tex_mob.highlight_by_tex("\\pi", YELLOW) + tex_mob.set_color_by_tex("sin", self.deriv_color) + tex_mob.set_color_by_tex("cos", self.antideriv_color) + tex_mob.set_color_by_tex("0", YELLOW) + tex_mob.set_color_by_tex("\\pi", YELLOW) self.play( Write(integral), @@ -1238,7 +1238,7 @@ class Antiderivative(AverageOfSineStart): pi = self.x_axis_labels[1] #Horrible hack - black_pi = pi.copy().highlight(BLACK) + black_pi = pi.copy().set_color(BLACK) self.add(black_pi, pi) cos_tex = self.rhs.get_part_by_tex("cos") @@ -1311,7 +1311,7 @@ class Antiderivative(AverageOfSineStart): ]) for tex_mob in pi_minus_zeros: for tex in "pi", "0": - tex_mob.highlight_by_tex(tex, YELLOW) + tex_mob.set_color_by_tex(tex, YELLOW) answer = TexMobject(" = \\frac{2}{\\pi}") answer.next_to( @@ -1370,7 +1370,7 @@ class Antiderivative(AverageOfSineStart): equals ) - def highlight_antiderivative_fraction(self): + def set_color_antiderivative_fraction(self): fraction = self.antiderivative_fraction big_rect = Rectangle( stroke_width = 0, @@ -1401,11 +1401,11 @@ class Antiderivative(AverageOfSineStart): self.zero_dot.get_center(), self.pi_dot.get_center(), ) - line.highlight(RED) + line.set_color(RED) line.scale_in_place(1.2) - new_v_line = self.v_line.copy().highlight(RED) - new_h_line = self.h_line.copy().highlight(RED) + new_v_line = self.v_line.copy().set_color(RED) + new_h_line = self.h_line.copy().set_color(RED) pi = TexMobject("\\pi") pi.next_to(self.h_line, DOWN) @@ -1476,12 +1476,12 @@ class GeneralAverage(AverageOfContinuousVariable): for x in self.bounds ]) for line, color in zip(v_lines, self.bound_colors): - line.highlight(color) + line.set_color(color) labels = map(TexMobject, "ab") for line, label in zip(v_lines, labels): vect = line.get_start()-line.get_end() label.next_to(line, vect/np.linalg.norm(vect)) - label.highlight(line.get_color()) + label.set_color(line.get_color()) self.y_axis_label_mob.shift(0.7*LEFT) @@ -1517,8 +1517,8 @@ class GeneralAverage(AverageOfContinuousVariable): "\\over", "b", "-", "a}" ) for color, tex in zip(self.bound_colors, "ab"): - fraction.highlight_by_tex(tex, color) - fraction.highlight_by_tex("displaystyle", WHITE) + fraction.set_color_by_tex(tex, color) + fraction.set_color_by_tex("displaystyle", WHITE) integral = VGroup(*fraction[:5]) denominator = VGroup(*fraction[5:]) average.next_to(fraction.get_part_by_tex("over"), LEFT) @@ -1633,7 +1633,7 @@ class GeneralAverage(AverageOfContinuousVariable): ) for line in v_lines: if self.y_axis.point_to_number(line.get_end()) < 0: - line.highlight(RED) + line.set_color(RED) line.save_state() line_pair = VGroup(*v_lines[6:8]) @@ -1644,7 +1644,7 @@ class GeneralAverage(AverageOfContinuousVariable): approx = TexMobject("\\approx") rhs = TexMobject("{b", "-", "a", "\\over", "dx}") for tex, color in zip("ab", self.bound_colors): - rhs.highlight_by_tex(tex, color) + rhs.set_color_by_tex(tex, color) expression = VGroup(num_samples, approx, rhs) expression.arrange_submobjects(RIGHT) expression.next_to(self.y_axis, RIGHT) @@ -1738,7 +1738,7 @@ class GeneralAverage(AverageOfContinuousVariable): for new_v_lines in new_v_lines_list: for line in new_v_lines: if self.y_axis.point_to_number(line.get_end()) < 0: - line.highlight(RED) + line.set_color(RED) for new_v_lines in new_v_lines_list: self.play(Transform( @@ -1778,8 +1778,8 @@ class GeneralAntiderivative(GeneralAverage): "\\over", "b", "-", "a}" ) for tex, color in zip("ab", self.bound_colors): - fraction.highlight_by_tex(tex, color) - fraction.highlight_by_tex("display", WHITE) + fraction.set_color_by_tex(tex, color) + fraction.set_color_by_tex("display", WHITE) fraction.scale(0.8) fraction.next_to(self.y_axis, RIGHT) @@ -1806,8 +1806,8 @@ class GeneralAntiderivative(GeneralAverage): deriv = TexMobject( "{dF", "\\over", "dx}", "(x)", "=", "f(x)" ) - deriv.highlight_by_tex("dF", antideriv_graph.get_color()) - deriv.highlight_by_tex("f(x)", BLUE) + deriv.set_color_by_tex("dF", antideriv_graph.get_color()) + deriv.set_color_by_tex("f(x)", BLUE) deriv.next_to( antideriv_graph_label, DOWN, MED_LARGE_BUFF, LEFT ) @@ -1834,7 +1834,7 @@ class GeneralAntiderivative(GeneralAverage): "b", "-", "a}" ) for tex, color in zip("abF", self.bound_colors+[YELLOW]): - new_fraction.highlight_by_tex(tex, color) + new_fraction.set_color_by_tex(tex, color) new_fraction.next_to( self.fraction.get_part_by_tex("over"), RIGHT, align_using_submobjects = True @@ -1892,7 +1892,7 @@ class GeneralAntiderivative(GeneralAverage): v_line = Line(b_point, interim_point) h_line = Line(interim_point, a_point) - VGroup(v_line, h_line).highlight(WHITE) + VGroup(v_line, h_line).set_color(WHITE) brace = Brace(v_line, RIGHT, buff = SMALL_BUFF) graph_within_bounds = self.get_graph( @@ -1936,7 +1936,7 @@ class GeneralAntiderivative(GeneralAverage): def draw_slope(self): line = Line(*self.graph_points_at_bounds) - line.highlight(PINK) + line.set_color(PINK) line.scale_in_place(1.3) self.play(ShowCreation(line, run_time = 2)) @@ -1987,7 +1987,7 @@ class ASecondIntegralSensation(TeacherStudentsScene): ) continuum.next_to(finite_average, RIGHT, 2) line = Line(continuum.get_left(), continuum.get_right()) - line.highlight(YELLOW) + line.set_color(YELLOW) arrow = Arrow(DOWN+RIGHT, ORIGIN) arrow.next_to(line.get_start(), DOWN+RIGHT, SMALL_BUFF) diff --git a/old_projects/eoc/footnote.py b/old_projects/eoc/footnote.py index 121eb9b6..82527e77 100644 --- a/old_projects/eoc/footnote.py +++ b/old_projects/eoc/footnote.py @@ -40,11 +40,11 @@ from old_projects.eoc.chapter10 import derivative class Introduce(TeacherStudentsScene): def construct(self): words = TextMobject("Next up is \\\\", "Taylor series") - words.highlight_by_tex("Taylor", BLUE) + words.set_color_by_tex("Taylor", BLUE) derivs = VGroup(*[ TexMobject( "{d", "^%d"%n, "f \\over dx", "^%d}"%n - ).highlight_by_tex(str(n), YELLOW) + ).set_color_by_tex(str(n), YELLOW) for n in range(2, 5) ]) derivs.next_to(self.teacher, UP, LARGE_BUFF) @@ -131,7 +131,7 @@ class SecondDerivativeGraphically(GraphScene): def show_derivative(self): deriv = TexMobject("\\frac{df}{dx}") deriv.next_to(self.graph_label, DOWN, MED_LARGE_BUFF) - deriv.highlight(self.deriv_color) + deriv.set_color(self.deriv_color) ss_group = self.get_secant_slope_group( 1, self.graph, dx = 0.01, @@ -159,7 +159,7 @@ class SecondDerivativeGraphically(GraphScene): def write_second_derivative(self): second_deriv = TexMobject("\\frac{d^2 f}{dx^2}") second_deriv.next_to(self.deriv, DOWN, MED_LARGE_BUFF) - second_deriv.highlight(self.second_deriv_color) + second_deriv.set_color(self.second_deriv_color) points = [ self.input_to_graph_point(x, self.graph) for x in self.x2, self.x3 @@ -350,7 +350,7 @@ class IntroduceNotation(TeacherStudentsScene): d_over_dx = VGroup(d, overs[1], dxs[1]) d2f_over_dx2 = TexMobject("{d^2 f", "\\over", "dx", "^2}") - d2f_over_dx2.highlight_by_tex("dx", YELLOW) + d2f_over_dx2.set_color_by_tex("dx", YELLOW) for mob in clunky_deriv, d2f_over_dx2: mob.next_to(self.teacher, UP+LEFT) @@ -361,7 +361,7 @@ class IntroduceNotation(TeacherStudentsScene): circle.scale_in_place(1.3) mob.circle = circle dx_to_zero = TexMobject("dx \\to 0") - dx_to_zero.highlight(YELLOW) + dx_to_zero.set_color(YELLOW) dx_to_zero.next_to(clunky_deriv, UP+LEFT) self.student_says( @@ -389,7 +389,7 @@ class IntroduceNotation(TeacherStudentsScene): self.play( FadeOut(denominator.circle), Write(dx_to_zero), - dxs.highlight, YELLOW + dxs.set_color, YELLOW ) self.wait() self.play( @@ -522,7 +522,7 @@ class HowToReadNotation(GraphScene, ReconfigurableScene): ) df_lines.add(df_line) df_label = TexMobject("df_%d"%i) - df_label.highlight(YELLOW) + df_label.set_color(YELLOW) df_label.scale(0.8) df_label.next_to(df_line.get_center(), UP+LEFT, MED_LARGE_BUFF) df_arrow = Arrow( @@ -590,7 +590,7 @@ class HowToReadNotation(GraphScene, ReconfigurableScene): df_labels[0].get_height()/ddf.get_height(), about_point = ddf.get_right() ) - ddf.highlight(MAROON_B) + ddf.set_color(MAROON_B) self.play( *map(MoveToTarget, [df_dx_groups, df_labels]), @@ -635,7 +635,7 @@ class HowToReadNotation(GraphScene, ReconfigurableScene): ) ddf_over_dx_squared.scale(0.8) ddf_over_dx_squared.move_to(self.ddf, RIGHT) - ddf_over_dx_squared.highlight_by_tex("df", self.ddf.get_color()) + ddf_over_dx_squared.set_color_by_tex("df", self.ddf.get_color()) parens = VGroup( ddf_over_dx_squared[0][1], ddf_over_dx_squared[0][4], @@ -647,7 +647,7 @@ class HowToReadNotation(GraphScene, ReconfigurableScene): left_shifter = ddf_over_dx_squared[2][4] exp_two = TexMobject("2") - exp_two.highlight(self.ddf.get_color()) + exp_two.set_color(self.ddf.get_color()) exp_two.scale(0.5) exp_two.move_to(right_shifter.get_corner(UP+RIGHT), LEFT) exp_two.shift(MED_SMALL_BUFF*RIGHT) @@ -726,8 +726,8 @@ class SecondDerivativeAsAcceleration(Scene): "{d^2 s \\over dt^2}(t)", "\\Leftrightarrow", "\\text{Acceleration}" ) - a_words.highlight_by_tex("d^2 s", MAROON_B) - a_words.highlight_by_tex("Acceleration", YELLOW) + a_words.set_color_by_tex("d^2 s", MAROON_B) + a_words.set_color_by_tex("Acceleration", YELLOW) a_words.to_corner(UP+RIGHT ) self.add(a_words) self.show_car_movement() @@ -773,17 +773,17 @@ class SecondDerivativeAsAcceleration(Scene): s_words = TexMobject( "s(t)", "\\Leftrightarrow", "\\text{Displacement}" ) - s_words.highlight_by_tex("s(t)", s_scene.graph.get_color()) + s_words.set_color_by_tex("s(t)", s_scene.graph.get_color()) v_words = TexMobject( "\\frac{ds}{dt}(t)", "\\Leftrightarrow", "\\text{Velocity}" ) - v_words.highlight_by_tex("ds", v_scene.graph.get_color()) + v_words.set_color_by_tex("ds", v_scene.graph.get_color()) j_words = TexMobject( "\\frac{d^3 s}{dt^3}(t)", "\\Leftrightarrow", "\\text{Jerk}" ) - j_words.highlight_by_tex("d^3", j_scene.graph.get_color()) + j_words.set_color_by_tex("d^3", j_scene.graph.get_color()) self.a_words.generate_target() words_group = VGroup(s_words, v_words, self.a_words.target, j_words) words_group.arrange_submobjects( @@ -910,8 +910,8 @@ class Thumbnail(SecondDerivativeGraphically): self.graph.set_stroke(GREEN, width = 8) tex = TexMobject("{d^n f", "\\over", "dx^n}") - tex.highlight_by_tex("d^n", YELLOW) - tex.highlight_by_tex("dx", BLUE) + tex.set_color_by_tex("d^n", YELLOW) + tex.set_color_by_tex("dx", BLUE) tex.scale_to_fit_height(4) tex.to_edge(UP) diff --git a/old_projects/eoc/old_chapter1.py b/old_projects/eoc/old_chapter1.py index d051963f..c7d92e6e 100644 --- a/old_projects/eoc/old_chapter1.py +++ b/old_projects/eoc/old_chapter1.py @@ -118,7 +118,7 @@ class CircleScene(PiCreatureScene): nudge_label = TexMobject("%.01f"%self.dR) else: nudge_label = TexMobject("dr") - nudge_label.highlight(self.dR_color) + nudge_label.set_color(self.dR_color) nudge_label.scale(0.75) nudge_label.next_to(nudge_arrow.get_start(), DOWN) @@ -213,7 +213,7 @@ class PatronsOnly(Scene): This is a draft for patrons only """) - title.highlight(RED) + title.set_color(RED) title.scale(2) title.to_edge(UP) @@ -241,7 +241,7 @@ class Introduction(TeacherStudentsScene): series = VideoSeries() series.to_edge(UP) this_video = series[0] - this_video.highlight(YELLOW) + this_video.set_color(YELLOW) this_video.save_state() this_video.set_fill(opacity = 0) this_video.center() @@ -252,7 +252,7 @@ class Introduction(TeacherStudentsScene): "Welcome to \\\\", "Essence of calculus" ) - words.highlight_by_tex("Essence of calculus", YELLOW) + words.set_color_by_tex("Essence of calculus", YELLOW) self.remove(self.teacher) self.teacher.change_mode("happy") self.add(self.teacher) @@ -387,14 +387,14 @@ class IntroduceCircle(Scene): circle = Circle(radius = 3, color = WHITE) circle.to_edge(LEFT) radius = Line(circle.get_center(), circle.get_right()) - radius.highlight(MAROON_B) + radius.set_color(MAROON_B) R = TexMobject("R").next_to(radius, UP) area, circumference = words = VGroup(*map(TextMobject, [ "Area =", "Circumference =" ])) - area.highlight(BLUE) - circumference.highlight(YELLOW) + area.set_color(BLUE) + circumference.set_color(YELLOW) words.arrange_submobjects(DOWN, aligned_edge = LEFT) words.next_to(circle, RIGHT) @@ -420,7 +420,7 @@ class IntroduceCircle(Scene): brace = Brace(calc_stuffs, RIGHT) to_be_explained = brace.get_text("To be \\\\ explained") - VGroup(brace, to_be_explained).highlight(GREEN) + VGroup(brace, to_be_explained).set_color(GREEN) self.play(ShowCreation(radius), Write(R)) self.play( @@ -572,13 +572,13 @@ class IntroduceTinyChangeInArea(CircleScene): new_area_form, minus, area_form = expression = TexMobject( "\\pi (R + 0.1)^2", "-", "\\pi R^2" ) - VGroup(*new_area_form[4:7]).highlight(self.dR_color) + VGroup(*new_area_form[4:7]).set_color(self.dR_color) expression_brace = Brace(expression, UP) change_in_area = expression_brace.get_text("Change in area") - change_in_area.highlight(self.outer_ring_color) + change_in_area.set_color(self.outer_ring_color) area_brace = Brace(area_form) area_word = area_brace.get_text("Area") - area_word.highlight(BLUE) + area_word.set_color(BLUE) new_area_brace = Brace(new_area_form) new_area_word = new_area_brace.get_text("New area") group = VGroup( @@ -617,7 +617,7 @@ class IntroduceTinyChangeInArea(CircleScene): ) self.wait() self.play( - outer_ring.highlight, YELLOW, + outer_ring.set_color, YELLOW, Animation(self.nudge_arrow), Animation(self.nudge_line), rate_func = there_and_back @@ -627,7 +627,7 @@ class IntroduceTinyChangeInArea(CircleScene): self.work_out_expression(group) self.second_unwrapping(outer_ring) insignificant = TextMobject("Insignificant") - insignificant.highlight(self.dR_color) + insignificant.set_color(self.dR_color) insignificant.move_to(self.error_words) self.play(Transform(self.error_words, insignificant)) self.wait() @@ -641,8 +641,8 @@ class IntroduceTinyChangeInArea(CircleScene): ) self.play( FadeIn(big_rect), - area_form.highlight, BLUE, - self.two_pi_R.highlight, GREEN, + area_form.set_color, BLUE, + self.two_pi_R.set_color, GREEN, self.pi_creature.change_mode, "happy" ) @@ -659,7 +659,7 @@ class IntroduceTinyChangeInArea(CircleScene): dR_brace.next_to(almost_rect, RIGHT) two_pi_R = circum_brace.get_text("$2\\pi R$") dR = TexMobject("$0.1$").scale(0.7).next_to(dR_brace, RIGHT) - dR.highlight(self.dR_color) + dR.set_color(self.dR_color) two_pi_R.generate_target() dR.generate_target() @@ -673,8 +673,8 @@ class IntroduceTinyChangeInArea(CircleScene): ) final_area.arrange_submobjects(RIGHT, buff = SMALL_BUFF) final_area.next_to(almost_rect, DOWN, buff = MED_LARGE_BUFF) - final_area.highlight(GREEN_A) - final_area[3].highlight(self.dR_color) + final_area.set_color(GREEN_A) + final_area[3].set_color(self.dR_color) change_in_area.shift(0.1*LEFT) self.play( @@ -717,7 +717,7 @@ class IntroduceTinyChangeInArea(CircleScene): ) pi_R_squared, plus, two_pi_R_dR, plus2, pi_dR_squared, minus2, pi_R_squared2 = expanded for subset in two_pi_R_dR[4:7], pi_dR_squared[2:5]: - VGroup(*subset).highlight(self.dR_color) + VGroup(*subset).set_color(self.dR_color) expanded.next_to(new_area_form, DOWN, aligned_edge = LEFT, buff = MED_SMALL_BUFF) expanded.shift(LEFT/2.) @@ -748,7 +748,7 @@ class IntroduceTinyChangeInArea(CircleScene): self.add(self.pi_creature, *expanded) self.wait(2) self.play(*[ - ApplyMethod(mob.highlight, RED) + ApplyMethod(mob.set_color, RED) for mob in pi_R_squared, pi_R_squared2 ]) self.wait() @@ -761,7 +761,7 @@ class IntroduceTinyChangeInArea(CircleScene): approx_brace = Brace(two_pi_R_dR) error_brace = Brace(pi_dR_squared, buff = SMALL_BUFF) error_words = error_brace.get_text("Error", buff = SMALL_BUFF) - error_words.highlight(RED) + error_words.set_color(RED) self.error_words = error_words self.play( @@ -787,7 +787,7 @@ class IntroduceTinyChangeInArea(CircleScene): stroke_width = 0, ) self.play( - almost_rect.highlight, YELLOW, + almost_rect.set_color, YELLOW, self.pi_creature.change_mode, "pondering" ) self.unwrap_ring(almost_rect) @@ -830,11 +830,11 @@ class BuildToDADR(CircleScene): def write_initial_terms(self): change = TextMobject("Change in area") - change.highlight(GREEN_B) + change.set_color(GREEN_B) equals, two_pi_R, dR, plus, pi, dR2, squared = rhs = TexMobject( "=", "2 \\pi R", "(0.1)", "+", "\\pi", "(0.1)", "^2" ) - VGroup(dR, dR2).highlight(self.dR_color) + VGroup(dR, dR2).set_color(self.dR_color) change.next_to(self.circle, buff = LARGE_BUFF) rhs.next_to(change) @@ -842,7 +842,7 @@ class BuildToDADR(CircleScene): circum_text = circum_brace.get_text("Circumference") error_brace = Brace(VGroup(pi, squared), UP) error_text = error_brace.get_text("Error") - error_text.highlight(RED) + error_text.set_color(RED) self.play( Write(change, run_time = 1), @@ -875,7 +875,7 @@ class BuildToDADR(CircleScene): term.frac_line.next_to(term, DOWN, buff = SMALL_BUFF) term.denom = TexMobject("(0.1)") term.denom.next_to(term.frac_line, DOWN, buff = SMALL_BUFF) - term.denom.highlight(self.dR_color) + term.denom.set_color(self.dR_color) term.denom.save_state() term.denom.replace(self.nudge_label) @@ -891,7 +891,7 @@ class BuildToDADR(CircleScene): self.play(*[term.denom.restore for term in terms]) self.wait(2) self.play( - self.outer_ring.highlight, YELLOW, + self.outer_ring.set_color, YELLOW, rate_func = there_and_back ) self.play( @@ -900,7 +900,7 @@ class BuildToDADR(CircleScene): ) self.wait(2) canceleres = VGroup(self.circum_term[1], self.circum_term.denom) - self.play(canceleres.highlight, RED) + self.play(canceleres.set_color, RED) self.play(FadeOut(canceleres)) self.remove(self.circum_term) self.play( @@ -943,7 +943,7 @@ class BuildToDADR(CircleScene): TexMobject(s).move_to(mob, LEFT) for mob in dRs ]) - new_dRs.highlight(self.dR_color) + new_dRs.set_color(self.dR_color) new_outer_ring = self.get_ring(self.radius, width) new_nudge_line = self.nudge_line.copy() new_nudge_line.scale_to_fit_width(width) @@ -970,7 +970,7 @@ class BuildToDADR(CircleScene): self.error_term.target.next_to(self.plus.target) error_brace.target = Brace(self.error_term.target) error_text.target = error_brace.target.get_text("Truly tiny") - error_text.target.highlight(error_text.get_color()) + error_text.target.set_color(error_text.get_color()) self.play(*map(MoveToTarget, [ error_brace, error_text, self.plus, self.error_term ])) @@ -981,7 +981,7 @@ class BuildToDADR(CircleScene): arg_separator = "" ) - difference_text.highlight_by_tex("d", self.dR_color) + difference_text.set_color_by_tex("d", self.dR_color) difference_text.next_to(self.pi_creature, UP+RIGHT) difference_arrow = Arrow(difference_text, self.change.denom) self.play( @@ -992,7 +992,7 @@ class BuildToDADR(CircleScene): self.wait() dA = TexMobject("dA") - dA.highlight(self.change.get_color()) + dA.set_color(self.change.get_color()) frac_line = self.change.frac_line frac_line.generate_target() frac_line.target.stretch_to_fit_width(dA.get_width()) @@ -1007,7 +1007,7 @@ class BuildToDADR(CircleScene): MoveToTarget(frac_line), MoveToTarget(self.change.denom), Transform(difference_text[3], A), - difference_text[1].highlight, dA.get_color(), + difference_text[1].set_color, dA.get_color(), MoveToTarget(difference_arrow), ) self.wait(2) @@ -1053,7 +1053,7 @@ class BuildToDADR(CircleScene): self.wait(2) equality_brace = Brace(VGroup(self.change.denom, self.circum_term)) equal_word = equality_brace.get_text("Equality") - VGroup(equality_brace, equal_word).highlight(BLUE) + VGroup(equality_brace, equal_word).set_color(BLUE) self.play( GrowFromCenter(equality_brace), Write(equal_word, run_time = 1) @@ -1121,7 +1121,7 @@ class BuildToDADR(CircleScene): for mob in to_infs: mob.save_state() mob.inf = TexMobject("1/\\infty") - mob.inf.highlight(mob.get_color()) + mob.inf.set_color(mob.get_color()) mob.inf.move_to(mob) self.play(*[ Transform(mob, mob.inf) @@ -1138,7 +1138,7 @@ class BuildToDADR(CircleScene): )) for n in range(7): target = TexMobject("0.%s1"%("0"*n)) - target.highlight(self.nudge_label.get_color()) + target.set_color(self.nudge_label.get_color()) target.move_to(self.nudge_label, LEFT) self.outer_ring.target = self.get_ring(self.radius, 0.1/(n+1)) self.nudge_line.get_center = self.nudge_line.get_left @@ -1158,7 +1158,7 @@ class BuildToDADR(CircleScene): Write(bubble.content, run_time = 1), randy.change_mode, "angry", ) - self.play(randy.highlight, RED) + self.play(randy.set_color, RED) self.play(self.pi_creature.change_mode, "guilty") self.wait() @@ -1174,7 +1174,7 @@ class BuildToDADR(CircleScene): ShowCreation(new_bubble), Write(new_bubble.content), randy.change_mode, "erm", - randy.highlight, BLUE_E, + randy.set_color, BLUE_E, self.pi_creature.change_mode, "shruggie" ) self.wait(2) @@ -1193,7 +1193,7 @@ class NameDerivative(IntroduceTinyChangeInArea): new_label = TexMobject("dR") new_label.move_to(self.nudge_label) new_label.to_edge(UP) - new_label.highlight(self.nudge_label.get_color()) + new_label.set_color(self.nudge_label.get_color()) new_arrow = Arrow(new_label, self.nudge_line) self.remove(self.nudge_label, self.nudge_arrow) @@ -1210,15 +1210,15 @@ class NameDerivative(IntroduceTinyChangeInArea): ) dArea_fom.to_edge(UP, buff = MED_LARGE_BUFF).shift(RIGHT) dA, frac_line, dR = VGroup(*dA_dR[:2]), dA_dR[2], VGroup(*dA_dR[3:]) - dA.highlight(GREEN_B) - dR.highlight(self.dR_color) - VGroup(*d_formula_dR[7:]).highlight(self.dR_color) + dA.set_color(GREEN_B) + dR.set_color(self.dR_color) + VGroup(*d_formula_dR[7:]).set_color(self.dR_color) dA_dR_circle = Circle() dA_dR_circle.replace(dA_dR, stretch = True) dA_dR_circle.scale_in_place(1.5) - dA_dR_circle.highlight(BLUE) + dA_dR_circle.set_color(BLUE) words = TextMobject( "``Derivative'' of $A$\\\\", @@ -1227,7 +1227,7 @@ class NameDerivative(IntroduceTinyChangeInArea): words.next_to(dA_dR_circle, DOWN, buff = 1.5*LARGE_BUFF) words.shift(0.5*LEFT) arrow = Arrow(words, dA_dR_circle) - arrow.highlight(dA_dR_circle.get_color()) + arrow.set_color(dA_dR_circle.get_color()) self.play(Transform(self.outer_ring.copy(), dA, run_time = 2)) self.play( @@ -1253,13 +1253,13 @@ class NameDerivative(IntroduceTinyChangeInArea): target_formula = TexMobject( "\\frac{d \\quad}{dR} = " ) - VGroup(*target_formula[2:4]).highlight(self.dR_color) + VGroup(*target_formula[2:4]).set_color(self.dR_color) target_formula.scale(1.3) target_formula.next_to(self.dArea_fom, DOWN) target_formula.shift(2*RIGHT + 0.5*DOWN) area_form = VGroup(*self.dArea_fom[2][2:5]).copy() - area_form.highlight(BLUE_D) + area_form.set_color(BLUE_D) circum_form = self.dArea_fom[-1] circle_width = 1 @@ -1268,7 +1268,7 @@ class NameDerivative(IntroduceTinyChangeInArea): area_circle.generate_target() area_circle.target.scale_to_fit_width(circle_width) area_circle.target.next_to(target_formula[0], RIGHT, buff = 0) - area_circle.target.highlight(BLUE_D) + area_circle.target.set_color(BLUE_D) circum_circle = self.circle.copy() circum_circle.set_fill(opacity = 0) circum_circle.generate_target() @@ -1313,8 +1313,8 @@ class NameDerivative(IntroduceTinyChangeInArea): for dR in sample_dRs: dA = 2*np.pi*dR + np.pi*(dR**2) frac = TexMobject("\\frac{%.3f}{%.2f}"%(dA, dR)) - VGroup(*frac[:5]).highlight(self.outer_ring.get_color()) - VGroup(*frac[6:]).highlight(self.dR_color) + VGroup(*frac[:5]).set_color(self.outer_ring.get_color()) + VGroup(*frac[6:]).set_color(self.dR_color) fracs.add(frac) fracs.add(TexMobject("\\cdots \\rightarrow")) fracs.add(TexMobject("???")) @@ -1325,15 +1325,15 @@ class NameDerivative(IntroduceTinyChangeInArea): arrows = VGroup() for frac in fracs[:len(sample_dRs)] + [fracs[-1]]: arrow = Arrow(self.words.get_bottom(), frac.get_top()) - arrow.highlight(WHITE) + arrow.set_color(WHITE) if frac is fracs[-1]: check = TexMobject("\\checkmark") - check.highlight(GREEN) + check.set_color(GREEN) check.next_to(arrow.get_center(), UP+RIGHT, SMALL_BUFF) arrow.add(check) else: cross = TexMobject("\\times") - cross.highlight(RED) + cross.set_color(RED) cross.move_to(arrow.get_center()) cross.set_stroke(RED, width = 5) arrow.add(cross) @@ -1378,7 +1378,7 @@ class NameDerivative(IntroduceTinyChangeInArea): self.remove(self.last_mover) self.play( equals.scale_in_place, 1.5, - equals.highlight, GREEN, + equals.set_color, GREEN, rate_func = there_and_back, run_time = 2 ) @@ -1455,7 +1455,7 @@ class DerivativeAsTangentLine(ZoomedScene): graph = ParametricFunction(func, color = BLUE) graph_label = TexMobject("A(R) = \\pi R^2") - graph_label.highlight(BLUE) + graph_label.set_color(BLUE) graph_label.next_to( graph.point_from_proportion(2), LEFT ) @@ -1502,9 +1502,9 @@ class DerivativeAsTangentLine(ZoomedScene): self.play(FadeIn(dot)) dR_line = Line(graph_point, interim_point) - dR_line.highlight(YELLOW) + dR_line.set_color(YELLOW) dA_line = Line(interim_point, nudged_point) - dA_line.highlight(GREEN) + dA_line.set_color(GREEN) tiny_buff = SMALL_BUFF/self.zoom_factor for line, vect, char in (dR_line, DOWN, "R"), (dA_line, RIGHT, "A"): line.brace = Brace(Line(LEFT, RIGHT)) @@ -1514,7 +1514,7 @@ class DerivativeAsTangentLine(ZoomedScene): line.brace.next_to(line, vect, buff = tiny_buff) line.text = TexMobject("d%s"%char) line.text.scale(1./self.zoom_factor) - line.text.highlight(line.get_color()) + line.text.set_color(line.get_color()) line.text.next_to(line.brace, vect, buff = tiny_buff) self.play(ShowCreation(line)) self.play(Write(VGroup(line.brace, line.text))) @@ -1524,8 +1524,8 @@ class DerivativeAsTangentLine(ZoomedScene): "\\frac{dA}{dR} =", "\\text{Slope}" ) self.slope_word = deriv_is_slope[1] - VGroup(*deriv_is_slope[0][:2]).highlight(GREEN) - VGroup(*deriv_is_slope[0][3:5]).highlight(YELLOW) + VGroup(*deriv_is_slope[0][:2]).set_color(GREEN) + VGroup(*deriv_is_slope[0][3:5]).set_color(YELLOW) deriv_is_slope.next_to(self.y_axis, RIGHT) deriv_is_slope.shift(UP) @@ -1559,7 +1559,7 @@ class DerivativeAsTangentLine(ZoomedScene): def show_tangent_lines(self): R = self.R_to_zoom_in_on line = Line(LEFT, RIGHT).scale(FRAME_Y_RADIUS) - line.highlight(MAROON_B) + line.set_color(MAROON_B) line.rotate(self.angle_of_tangent(R)) line.move_to(self.graph_point(R)) x_axis_y = self.x_axis.number_to_point(0)[1] @@ -1720,7 +1720,7 @@ class IntroduceConcentricRings(CircleScene): dr_text = TexMobject("dr") dr_text.move_to(self.circle.get_corner(UP+RIGHT)) dr_text.shift(LEFT) - dr_text.highlight(YELLOW) + dr_text.set_color(YELLOW) dr_arrow = Arrow(dr_text, dr_line, buff = SMALL_BUFF) self.dr_group = VGroup(dr_text, dr_arrow, dr_line) @@ -1795,7 +1795,7 @@ class IntroduceConcentricRings(CircleScene): radial_line = Line(ORIGIN, radius*RIGHT) radial_line.rotate(np.pi/4) radial_line.shift(self.circle.get_center()) - radial_line.highlight(YELLOW) + radial_line.set_color(YELLOW) r_label = TexMobject("r") r_label.next_to(radial_line.get_center(), UP+LEFT, buff = SMALL_BUFF) @@ -2029,7 +2029,7 @@ class IntroduceConcentricRings(CircleScene): self.wait() for term in self.integral_terms: term.save_state() - self.play(term.highlight, YELLOW) + self.play(term.set_color, YELLOW) self.play(term.restore) self.wait(3) @@ -2087,13 +2087,13 @@ class GraphIntegral(GraphScene): moving_arrow = arrows[0].copy() self.play( ShowCreation(moving_arrow), - self.little_r.highlight, YELLOW + self.little_r.set_color, YELLOW ) for arrow in reversed(arrows): self.play(Transform(moving_arrow, arrow, run_time = 4)) self.play( FadeOut(moving_arrow), - self.little_r.highlight, WHITE + self.little_r.set_color, WHITE ) def add_rectangles(self): @@ -2104,7 +2104,7 @@ class GraphIntegral(GraphScene): for x in np.arange(0, self.R+self.dr, self.dr) ]) ticks.stretch_to_fit_height(tick_height) - ticks.highlight(YELLOW) + ticks.set_color(YELLOW) R_label = TexMobject("R") R_label.next_to(self.coords_to_point(self.R, 0), DOWN) @@ -2124,7 +2124,7 @@ class GraphIntegral(GraphScene): buff = SMALL_BUFF ) dr_text = dr_brace.get_text("$dr$", buff = SMALL_BUFF) - # dr_text.highlight(YELLOW) + # dr_text.set_color(YELLOW) rectangles = self.get_rectangles(self.dr) special_rect = rectangles[special_tick_index] @@ -2275,12 +2275,12 @@ class FundamentalTheorem(CircleScene): symbolic = TexMobject( "\\frac{d(\\pi R^2)}{dR} =", "2\\pi R" ) - VGroup(*symbolic[0][2:5]).highlight(self.area_color) - VGroup(*symbolic[0][7:9]).highlight(self.dR_color) - symbolic[1].highlight(self.circum_color) + VGroup(*symbolic[0][2:5]).set_color(self.area_color) + VGroup(*symbolic[0][7:9]).set_color(self.dR_color) + symbolic[1].set_color(self.circum_color) geometric = TexMobject("\\frac{d \\quad}{dR}=") - VGroup(*geometric[2:4]).highlight(self.dR_color) + VGroup(*geometric[2:4]).set_color(self.dR_color) radius = geometric[0].get_height() area_circle = Circle( stroke_width = 0, @@ -2311,9 +2311,9 @@ class FundamentalTheorem(CircleScene): symbolic = TexMobject( "\\int_0^R", "2\\pi r", "\\cdot", "dr", "=", "\\pi R^2" ) - symbolic.highlight_by_tex("2\\pi r", self.circum_color) - symbolic.highlight_by_tex("dr", self.dR_color) - symbolic.highlight_by_tex("\\pi R^2", self.area_color) + symbolic.set_color_by_tex("2\\pi r", self.circum_color) + symbolic.set_color_by_tex("dr", self.dR_color) + symbolic.set_color_by_tex("\\pi R^2", self.area_color) geometric = symbolic.copy() area_circle = Circle( @@ -2367,8 +2367,8 @@ class FundamentalTheorem(CircleScene): brace = Brace(ring_copy, UP) brace.stretch_in_place(0.95, 0) deriv = brace.get_text("$\\dfrac{dA}{dR}$") - VGroup(*deriv[:2]).highlight(self.outer_ring.get_color()) - VGroup(*deriv[-2:]).highlight(self.dR_color) + VGroup(*deriv[:2]).set_color(self.outer_ring.get_color()) + VGroup(*deriv[-2:]).set_color(self.dR_color) self.play( GrowFromCenter(brace), Write(deriv), diff --git a/old_projects/eola/chapter0.py b/old_projects/eola/chapter0.py index 2f8e6be1..773bd578 100644 --- a/old_projects/eola/chapter0.py +++ b/old_projects/eola/chapter0.py @@ -62,9 +62,9 @@ class OpeningQuote(Scene): words.scale_to_fit_width(2*(FRAME_X_RADIUS-1)) words.to_edge(UP) for mob in words.submobjects[48:49+13]: - mob.highlight(GREEN) + mob.set_color(GREEN) author = TextMobject("-Jean Dieudonn\\'e") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN) self.play(FadeIn(words)) @@ -226,11 +226,11 @@ class AboutLinearAlgebra(Scene): def get_eigenvalue(self): result = TextMobject("\\Text{Det}\\left(A - \\lambda I \\right) = 0") - result.submobjects[-5].highlight(YELLOW) + result.submobjects[-5].set_color(YELLOW) return result def get_matrix_multiplication_question(self): - why = TextMobject("Why?").highlight(BLUE) + why = TextMobject("Why?").set_color(BLUE) mult = self.get_matrix_multiplication() why.next_to(mult, UP) result = VMobject(why, mult) @@ -255,7 +255,7 @@ class AboutLinearAlgebra(Scene): ) for mob in result.submobjects[-11:-6]: - mob.highlight(YELLOW) + mob.set_color(YELLOW) return result @@ -277,7 +277,7 @@ class NumericVsGeometric(Scene): hline.to_edge(LEFT, buff = 0) vline = Line(FRAME_Y_RADIUS*UP, FRAME_Y_RADIUS*DOWN) for mob in hline, vline: - mob.highlight(GREEN) + mob.set_color(GREEN) self.play(ShowCreation(VMobject(hline, vline))) digest_locals(self) @@ -336,7 +336,7 @@ class NumericVsGeometric(Scene): ] bulb = SVGMobject("light_bulb") bulb.scale_to_fit_height(1) - bulb.highlight(YELLOW) + bulb.set_color(YELLOW) thoughts = [ matrix_to_mobject(EXAMPLE_TRANFORM), bulb, @@ -402,7 +402,7 @@ class LinAlgPyramid(Scene): ) self.wait() self.play(*[ - ApplyMethod(m.highlight, DARK_GREY) + ApplyMethod(m.set_color, DARK_GREY) for m in words[0], rects[0] ]) self.wait() @@ -519,11 +519,11 @@ class SineApproximations(Scene): def construct(self): series = self.get_series() one_approx = self.get_approx_series("1", 1) - one_approx.highlight(YELLOW) + one_approx.set_color(YELLOW) pi_sixts_approx = self.get_approx_series("\\pi/6", np.pi/6) - pi_sixts_approx.highlight(RED) + pi_sixts_approx.set_color(RED) words = TextMobject("(How calculators compute sine)") - words.highlight(GREEN) + words.set_color(GREEN) series.to_edge(UP) one_approx.next_to(series, DOWN, buff = 1.5) @@ -627,13 +627,13 @@ class PhysicsExample(Scene): v_label = TexMobject("\\vec{v}") v_label.shift(p1 + RIGHT*vector[0]/4 + UP*vector[1]/2) - v_label.highlight(v_mob.get_color()) + v_label.set_color(v_mob.get_color()) vx_label = TexMobject("||\\vec{v}|| \\cos(\\theta)") vx_label.next_to(vx, UP) - vx_label.highlight(vx.get_color()) + vx_label.set_color(vx.get_color()) vy_label = TexMobject("||\\vec{v}|| \\sin(\\theta)") vy_label.next_to(vy, RIGHT) - vy_label.highlight(vy.get_color()) + vy_label.set_color(vy.get_color()) kwargs = {"submobject_mode" : "one_at_a_time"} for v in v_mob, vx, vy: @@ -673,7 +673,7 @@ class LinearAlgebraIntuitions(Scene): title.to_edge(UP) h_line = Line(FRAME_X_RADIUS*LEFT, FRAME_X_RADIUS*RIGHT) h_line.next_to(title, DOWN) - h_line.highlight(BLUE_E) + h_line.set_color(BLUE_E) intuitions = [ "Matrices transform space", "Matrix multiplication corresponds to applying " + @@ -720,9 +720,9 @@ class ExampleTransformationForIntuitionList(LinearTransformationScene): class MatrixMultiplicationIs(Scene): def construct(self): matrix1 = matrix_to_mobject([[1, -1], [1, 2]]) - matrix1.highlight(BLUE) + matrix1.set_color(BLUE) matrix2 = matrix_to_mobject([[2, 1], [1, 2]]) - matrix2.highlight(GREEN) + matrix2.set_color(GREEN) for m in matrix1, matrix2: m.scale_to_fit_height(3) arrow = Arrow(LEFT, RIGHT, stroke_width = 6, preserve_tip_size_when_scaling = False) @@ -830,7 +830,7 @@ class ExampleMatrixMultiplication(NumericalMatrixMultiplication): class TableOfContents(Scene): def construct(self): title = TextMobject("Essence of Linear Algebra") - title.highlight(BLUE) + title.set_color(BLUE) title.to_corner(UP+LEFT) h_line = Line(FRAME_X_RADIUS*LEFT, FRAME_X_RADIUS*RIGHT) h_line.next_to(title, DOWN) @@ -863,13 +863,13 @@ class TableOfContents(Scene): entry3 = chapters.split()[2] added_words = TextMobject("(Personally, I'm most excited \\\\ to do this one)") added_words.scale(0.5) - added_words.highlight(YELLOW) + added_words.set_color(YELLOW) added_words.next_to(h_line, DOWN) added_words.to_edge(RIGHT) arrow = Arrow(added_words.get_bottom(), entry3) self.play( - ApplyMethod(entry3.highlight, YELLOW), + ApplyMethod(entry3.set_color, YELLOW), ShowCreation(arrow, submobject_mode = "one_at_a_time"), Write(added_words), run_time = 1 diff --git a/old_projects/eola/chapter1.py b/old_projects/eola/chapter1.py index 6440af80..547317f9 100644 --- a/old_projects/eola/chapter1.py +++ b/old_projects/eola/chapter1.py @@ -50,9 +50,9 @@ class OpeningQuote(Scene): ) words.to_edge(UP) for mob in words.submobjects[27:27+11]: - mob.highlight(GREEN) + mob.set_color(GREEN) author = TextMobject("-Hermann Weyl") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -151,7 +151,7 @@ class DifferentConceptions(Scene): ).shift( random.uniform(0, 4)*RIGHT + \ random.uniform(-1, 2)*UP - ).highlight(random_color()) + ).set_color(random_color()) for x in range(5) ]) @@ -238,13 +238,13 @@ class DifferentConceptions(Scene): house.to_edge(LEFT).shift(UP) square_footage_words.next_to(house, RIGHT) square_footage_words.shift(0.5*UP) - square_footage_words.highlight(RED) + square_footage_words.set_color(RED) price_words.next_to(square_footage_words, DOWN, aligned_edge = LEFT) - price_words.highlight(GREEN) + price_words.set_color(GREEN) square_footage.next_to(square_footage_words) - square_footage.highlight(RED) + square_footage.set_color(RED) price.next_to(price_words) - price.highlight(GREEN) + price.set_color(GREEN) vector = Matrix([square_footage.copy(), price.copy()]) vector.next_to(house, RIGHT).shift(0.25*UP) @@ -252,8 +252,8 @@ class DifferentConceptions(Scene): not_equals = TexMobject("\\ne") not_equals.next_to(vector) alt_vector = Matrix([ - TextMobject("300{,}000\\text{ ft}^2").highlight(RED), - TextMobject("\\$2{,}600").highlight(GREEN) + TextMobject("300{,}000\\text{ ft}^2").set_color(RED), + TextMobject("\\$2{,}600").set_color(GREEN) ]) alt_vector.next_to(not_equals) @@ -336,15 +336,15 @@ class DifferentConceptions(Scene): syms.center().shift(2*UP) statement = TextMobject("We'll ignore him \\\\ for now") - statement.highlight(PINK) + statement.set_color(PINK) statement.scale_to_fit_width(arrays.get_width()) statement.next_to(arrays, DOWN, buff = 1.5) circle = Circle() circle.shift(syms.get_bottom()) - VMobject(v_arrow, v_array, v_sym).highlight(v_color) - VMobject(w_arrow, w_array, w_sym).highlight(w_color) - VMobject(sum_arrow, sum_array).highlight(sum_color) + VMobject(v_arrow, v_array, v_sym).set_color(v_color) + VMobject(w_arrow, w_array, w_sym).set_color(w_color) + VMobject(sum_arrow, sum_array).set_color(sum_color) self.play( Write(syms), Write(arrays), @@ -366,8 +366,8 @@ class DifferentConceptions(Scene): def add_scaling(self, arrows, syms, arrays): s_arrows = VMobject( - TexMobject("2"), Vector([1, 1]).highlight(YELLOW), - TexMobject("="), Vector([2, 2]).highlight(WHITE) + TexMobject("2"), Vector([1, 1]).set_color(YELLOW), + TexMobject("="), Vector([2, 2]).set_color(WHITE) ) s_arrows.arrange_submobjects(RIGHT) s_arrows.scale(0.75) @@ -375,7 +375,7 @@ class DifferentConceptions(Scene): s_arrays = VMobject( TexMobject("2"), - matrix_to_mobject([3, -5]).highlight(YELLOW), + matrix_to_mobject([3, -5]).set_color(YELLOW), TextMobject("="), matrix_to_mobject(["2(3)", "2(-5)"]) ) @@ -384,7 +384,7 @@ class DifferentConceptions(Scene): s_arrays.next_to(arrays, DOWN) s_syms = TexMobject(["2", "\\vec{\\textbf{v}}"]) - s_syms.split()[-1].highlight(YELLOW) + s_syms.split()[-1].set_color(YELLOW) s_syms.next_to(syms, DOWN) self.play( @@ -403,7 +403,7 @@ class DifferentConceptions(Scene): def restore_creatures(self, creatures): self.play(*[ - ApplyFunction(lambda m : m.change_mode("plain").highlight(m.color), pi) + ApplyFunction(lambda m : m.change_mode("plain").set_color(m.color), pi) for pi in creatures ] + [ ApplyMethod(pi.title.set_fill, WHITE, 1.0) @@ -472,11 +472,11 @@ class HowIWantYouToThinkAboutVectors(Scene): ])) colors = [GREEN_B, MAROON_B, PINK] for v, color in zip(other_vectors.split(), colors): - v.highlight(color) + v.set_color(color) shift_val = 4*RIGHT+DOWN dot = Dot(radius = 0.1) - dot.highlight(RED) + dot.set_color(RED) tail_word = TextMobject("Tail") tail_word.shift(0.5*DOWN+2.5*LEFT) line = Line(tail_word, dot) @@ -558,14 +558,14 @@ class CoordinateSystemWalkthrough(VectorScene): x_tick_marks = number_line.get_tick_marks() y_tick_marks = x_tick_marks.copy().rotate(np.pi/2) tick_marks = VMobject(x_tick_marks, y_tick_marks) - tick_marks.highlight(WHITE) + tick_marks.set_color(WHITE) plane_lines = filter( lambda m : isinstance(m, Line), plane.submobject_family() ) origin_words = TextMobject("Origin") origin_words.shift(2*UP+2*LEFT) - dot = Dot(radius = 0.1).highlight(RED) + dot = Dot(radius = 0.1).set_color(RED) line = Line(origin_words.get_bottom(), dot.get_corner(UP+LEFT)) unit_brace = Brace(Line(RIGHT, 2*RIGHT)) @@ -615,15 +615,15 @@ class CoordinateSystemWalkthrough(VectorScene): vector = Vector([-2, 3]) x_line = Line(ORIGIN, -2*RIGHT) y_line = Line(-2*RIGHT, -2*RIGHT+3*UP) - x_line.highlight(X_COLOR) - y_line.highlight(Y_COLOR) + x_line.set_color(X_COLOR) + y_line.set_color(Y_COLOR) array = vector_coordinate_label(vector) x_label, y_label = array.get_mob_matrix().flatten() x_label_copy = x_label.copy() - x_label_copy.highlight(X_COLOR) + x_label_copy.set_color(X_COLOR) y_label_copy = y_label.copy() - y_label_copy.highlight(Y_COLOR) + y_label_copy.set_color(Y_COLOR) point = Dot(4*LEFT+2*UP) point_word = TextMobject("(-4, 2) as \\\\ a point") @@ -643,7 +643,7 @@ class CoordinateSystemWalkthrough(VectorScene): self.play(FadeIn(point)) self.wait() self.play(ApplyFunction( - lambda m : m.scale_in_place(1.25).highlight(YELLOW), + lambda m : m.scale_in_place(1.25).set_color(YELLOW), array.get_brackets(), rate_func = there_and_back )) @@ -659,7 +659,7 @@ class LabeledThreeDVector(Scene): class WriteZ(Scene): def construct(self): - z = TexMobject("z").highlight(Z_COLOR) + z = TexMobject("z").set_color(Z_COLOR) z.scale_to_fit_height(4) self.play(Write(z, run_time = 2)) self.wait(3) @@ -670,9 +670,9 @@ class Write3DVector(Scene): array = Matrix([2, 1, 3]).scale(2) x, y, z = array.get_mob_matrix().flatten() brackets = array.get_brackets() - x.highlight(X_COLOR) - y.highlight(Y_COLOR) - z.highlight(Z_COLOR) + x.set_color(X_COLOR) + y.set_color(Y_COLOR) + z.set_color(Z_COLOR) self.add(brackets) for mob in x, y, z: @@ -891,9 +891,9 @@ class VectorAdditionNumerically(VectorScene): ]) for i, (var, starter) in enumerate(zip(variables, starters)): if i%2 == 0: - var.highlight(X_COLOR) + var.set_color(X_COLOR) else: - var.highlight(Y_COLOR) + var.set_color(Y_COLOR) var.scale(VECTOR_LABEL_SCALE_FACTOR) var.move_to(starter) self.play( @@ -917,7 +917,7 @@ class VectorAdditionNumerically(VectorScene): class MultiplicationByANumberIntro(Scene): def construct(self): v = TexMobject("\\vec{\\textbf{v}}") - v.highlight(YELLOW) + v.set_color(YELLOW) nums = map(TexMobject, ["2", "\\dfrac{1}{3}", "-1.8"]) for mob in [v] + nums: mob.scale(1.5) @@ -979,8 +979,8 @@ class ShowScalarMultiplication(VectorScene): self.play(Write(factor_mob, run_time = 1)) self.wait() self.play( - ApplyMethod(v.copy().highlight, DARK_GREY), - ApplyMethod(v_label.copy().highlight, DARK_GREY), + ApplyMethod(v.copy().set_color, DARK_GREY), + ApplyMethod(v_label.copy().set_color, DARK_GREY), Transform(factor_mob, factor_in_label), Transform(v.copy(), scaled_vector), Transform(v_label.copy(), label_remainder), @@ -1048,8 +1048,8 @@ class ScalingNumerically(VectorScene): two_v_elems = two_v_coords.get_mob_matrix().flatten() x_sym, y_sym = map(TexMobject, ["x", "y"]) two_x_sym, two_y_sym = map(TexMobject, ["2x", "2y"]) - VMobject(x_sym, two_x_sym).highlight(X_COLOR) - VMobject(y_sym, two_y_sym).highlight(Y_COLOR) + VMobject(x_sym, two_x_sym).set_color(X_COLOR) + VMobject(y_sym, two_y_sym).set_color(Y_COLOR) syms = [x_sym, y_sym, two_x_sym, two_y_sym] VMobject(*syms).scale(VECTOR_LABEL_SCALE_FACTOR) for sym, num in zip(syms, [x, y] + list(two_v_elems)): @@ -1095,7 +1095,7 @@ class FollowingVideos(UpcomingSeriesOfVidoes): UpcomingSeriesOfVidoes.construct(self) last_video = self.mobjects[-1] - self.play(ApplyMethod(last_video.highlight, YELLOW)) + self.play(ApplyMethod(last_video.set_color, YELLOW)) self.wait() everything = VMobject(*self.mobjects) everything.remove(last_video) @@ -1206,7 +1206,7 @@ class DataAnalyst(Scene): self.wait() self.play( ApplyMethod(plane.fade, 0.7), - ApplyMethod(vects.highlight, DARK_GREY), + ApplyMethod(vects.set_color, DARK_GREY), ShowCreation(ellipse) ) self.wait(3) diff --git a/old_projects/eola/chapter10.py b/old_projects/eola/chapter10.py index 29798ee9..b6d67b35 100644 --- a/old_projects/eola/chapter10.py +++ b/old_projects/eola/chapter10.py @@ -40,12 +40,12 @@ class OpeningQuote(Scene): enforce_new_line_structure = False, alignment = "", ) - words.highlight_by_tex("mathematics", BLUE) - words.highlight_by_tex("music", BLUE) + words.set_color_by_tex("mathematics", BLUE) + words.set_color_by_tex("music", BLUE) words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) author = TextMobject("-Serge Lang") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(Write(words, run_time = 10)) @@ -101,7 +101,7 @@ class StudentsFindThisConfusing(TeacherStudentsScene): ["c", "d-\\lambda"], ]) ) - equation.highlight(YELLOW) + equation.set_color(YELLOW) self.teacher_says( equation, added_anims = [MoveToTarget(question2)] @@ -166,7 +166,7 @@ class ExampleTranformationScene(LinearTransformationScene): def add_matrix(self): matrix = Matrix(self.t_matrix.T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(ORIGIN, LEFT, buff = MED_SMALL_BUFF) matrix.to_edge(UP) matrix.rect = BackgroundRectangle(matrix) @@ -186,7 +186,7 @@ class IntroduceExampleTransformation(ExampleTranformationScene): self.apply_transposed_matrix(self.t_matrix) for coords, vect in (i_coords, self.i_hat), (j_coords, self.j_hat): - coords.highlight(vect.get_color()) + coords.set_color(vect.get_color()) coords.scale(0.8) coords.rect = BackgroundRectangle(coords) coords.add_to_back(coords.rect) @@ -270,12 +270,12 @@ class VectorRemainsOnSpan(ExampleTranformationScene): class IHatAsEigenVector(ExampleTranformationScene): def construct(self): - self.highlight_first_column() - self.highlight_x_axis() + self.set_color_first_column() + self.set_color_x_axis() self.apply_transposed_matrix(self.t_matrix, path_arc = 0) self.label_i_hat_landing_spot() - def highlight_first_column(self): + def set_color_first_column(self): faders = VGroup(self.plane, self.i_hat, self.j_hat) faders.save_state() column1 = VGroup(*self.matrix.get_mob_matrix()[:,0]) @@ -286,7 +286,7 @@ class IHatAsEigenVector(ExampleTranformationScene): self.play(faders.restore, Animation(self.matrix)) self.wait() - def highlight_x_axis(self): + def set_color_x_axis(self): x_axis = self.plane.axes[0] targets = [ self.i_hat.copy().scale(val) @@ -303,11 +303,11 @@ class IHatAsEigenVector(ExampleTranformationScene): ) self.wait() self.remove(*lines) - x_axis.highlight(YELLOW) + x_axis.set_color(YELLOW) def label_i_hat_landing_spot(self): array = Matrix(self.t_matrix[0]) - array.highlight(X_COLOR) + array.set_color(X_COLOR) array.rect = BackgroundRectangle(array) array.add_to_back(array.rect) brace = Brace(self.i_hat, buff = 0) @@ -344,7 +344,7 @@ class SneakierEigenVector(ExampleTranformationScene): vector = Vector(coords) array = Matrix(coords) array.scale(0.7) - array.highlight(vector.get_color()) + array.set_color(vector.get_color()) array.add_to_back(BackgroundRectangle(array)) array.target = array.copy() array.next_to(vector.get_end(), LEFT) @@ -353,7 +353,7 @@ class SneakierEigenVector(ExampleTranformationScene): two_times.add_background_rectangle() two_times.next_to(array.target, LEFT) span_line = Line(-4*vector.get_end(), 4*vector.get_end()) - span_line.highlight(MAROON_B) + span_line.set_color(MAROON_B) self.matrix.shift(-2*self.matrix.get_center()[0]*RIGHT) @@ -441,8 +441,8 @@ class NameEigenvectorsAndEigenvalues(ExampleTranformationScene): eigen_val_words.add_background_rectangle() eigen_val_words.next_to(words, DOWN, aligned_edge = RIGHT) words.eigen_val_words = eigen_val_words - x_words.eigen_val_words.highlight(X_COLOR) - sneak_words.eigen_val_words.highlight(YELLOW) + x_words.eigen_val_words.set_color(X_COLOR) + sneak_words.eigen_val_words.set_color(YELLOW) VGroup( sneak_words, @@ -513,7 +513,7 @@ class EigenvalueNegativeOneHalf(LinearTransformationScene): def construct(self): matrix = Matrix(self.t_matrix.T) matrix.add_to_back(BackgroundRectangle(matrix)) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(ORIGIN, LEFT) matrix.to_edge(UP) self.add_foreground_mobject(matrix) @@ -575,7 +575,7 @@ class EigenvectorToAxisOfRotation(Scene): class EigenvalueOne(Scene): def construct(self): text = TextMobject("Eigenvalue = $1$") - text.highlight(MAROON_B) + text.set_color(MAROON_B) self.play(Write(text)) self.wait() @@ -585,8 +585,8 @@ class ContrastMatrixUnderstandingWithEigenvalue(TeacherStudentsScene): "Rotate", "$30^\\circ$", "around", "$%s$"%matrix_to_tex_string([2, 3, 1]) ) - axis_and_rotation[1].highlight(BLUE) - axis_and_rotation[-1].highlight(MAROON_B) + axis_and_rotation[1].set_color(BLUE) + axis_and_rotation[-1].set_color(MAROON_B) matrix = Matrix([ [ @@ -688,8 +688,8 @@ class SymbolicEigenvectors(Scene): self.expression.shift(UP+2*LEFT) A, v1, equals, lamb, v2 = self.expression vs = VGroup(v1, v2) - vs.highlight(YELLOW) - lamb.highlight(MAROON_B) + vs.set_color(YELLOW) + lamb.set_color(MAROON_B) A_brace = Brace(A, UP, buff = 0) A_text = TextMobject("Transformation \\\\ matrix") @@ -697,11 +697,11 @@ class SymbolicEigenvectors(Scene): lamb_brace = Brace(lamb, UP, buff = 0) lamb_text = TextMobject("Eigenvalue") - lamb_text.highlight(lamb.get_color()) + lamb_text.set_color(lamb.get_color()) lamb_text.next_to(lamb_brace, UP, aligned_edge = LEFT) v_text = TextMobject("Eigenvector") - v_text.highlight(vs.get_color()) + v_text.set_color(vs.get_color()) v_text.next_to(vs, DOWN, buff = 1.5*LARGE_BUFF) v_arrows = VGroup(*[ Arrow(v_text.get_top(), v.get_bottom()) @@ -741,7 +741,7 @@ class SymbolicEigenvectors(Scene): right_group = VGroup(lamb, v2) right_group.brace = Brace(right_group, DOWN) right_group.text = right_group.brace.get_text("Scalar multiplication") - right_group.text.highlight(lamb.get_color()) + right_group.text.set_color(lamb.get_color()) for group in left_group, right_group: self.play( @@ -759,8 +759,8 @@ class SymbolicEigenvectors(Scene): "Solve for \\\\", "$\\lambda$", "and", "$\\vec{\\textbf{v}}$" ) - solve_text.highlight_by_tex("$\\lambda$", lamb.get_color()) - solve_text.highlight_by_tex("$\\vec{\\textbf{v}}$", v1.get_color()) + solve_text.set_color_by_tex("$\\lambda$", lamb.get_color()) + solve_text.set_color_by_tex("$\\vec{\\textbf{v}}$", v1.get_color()) bubble.add_content(solve_text) self.play( @@ -816,7 +816,7 @@ class SymbolicEigenvectors(Scene): for entry in diag_entries: new_lamb = TexMobject("\\lambda") new_lamb.move_to(entry) - new_lamb.highlight(lamb.get_color()) + new_lamb.set_color(lamb.get_color()) Transform(entry, new_lamb).update(1) new_lamb = lamb.copy() new_lamb.next_to(matrix, LEFT) @@ -931,7 +931,7 @@ class SymbolicEigenvectors(Scene): matrix.next_to(brace.text, DOWN) for entry in matrix.get_entries(): if len(entry.get_tex_string()) > 1: - entry[-1].highlight(lamb.get_color()) + entry[-1].set_color(lamb.get_color()) self.play( GrowFromCenter(brace), Write(brace.text), @@ -961,7 +961,7 @@ class SymbolicEigenvectors(Scene): equation = TexMobject( "\\det(A-", "\\lambda", "I)", "=0" ) - equation.highlight_by_tex("\\lambda", MAROON_B) + equation.set_color_by_tex("\\lambda", MAROON_B) equation.next_to(words, DOWN) words.add(equation) bubble.add_content(words) @@ -996,8 +996,8 @@ class NonZeroSolutionsVisually(LinearTransformationScene): "= \\vec{\\textbf{0}}" ) equation_matrix = VGroup(*equation[:3]) - equation.highlight_by_tex("\\lambda", MAROON_B) - equation.highlight_by_tex("\\vec{\\textbf{v}}", YELLOW) + equation.set_color_by_tex("\\lambda", MAROON_B) + equation.set_color_by_tex("\\vec{\\textbf{v}}", YELLOW) equation.add_background_rectangle() equation.next_to(ORIGIN, DOWN, buff = MED_SMALL_BUFF) equation.to_edge(LEFT) @@ -1007,7 +1007,7 @@ class NonZeroSolutionsVisually(LinearTransformationScene): "\\det", "(A-", "\\lambda", "I", ")", "=0" ) det_equation_matrix = VGroup(*det_equation[2:2+4]) - det_equation.highlight_by_tex("\\lambda", MAROON_B) + det_equation.set_color_by_tex("\\lambda", MAROON_B) det_equation.next_to(equation, DOWN, buff = MED_SMALL_BUFF) det_equation.to_edge(LEFT) det_equation.add_background_rectangle() @@ -1048,20 +1048,20 @@ class TweakLambda(LinearTransformationScene): entry = matrix.get_mob_matrix()[i,i] place_holders = VGroup(*entry[2:]) entry.remove(*place_holders) - place_holders.highlight(MAROON_B) + place_holders.set_color(MAROON_B) self.lambda_vals.append(place_holders) brace = Brace(matrix) brace_text = TexMobject("(A-", "\\lambda", "I)") - brace_text.highlight_by_tex("\\lambda", MAROON_B) + brace_text.set_color_by_tex("\\lambda", MAROON_B) brace_text.next_to(brace, DOWN) brace_text.add_background_rectangle() det_text = get_det_text(matrix) equals = TexMobject("=").next_to(det_text) det = DecimalNumber(np.linalg.det(self.t_matrix)) - det.highlight(YELLOW) + det.set_color(YELLOW) det.next_to(equals) det.rect = BackgroundRectangle(det) @@ -1131,7 +1131,7 @@ class TweakLambda(LinearTransformationScene): for lambda_val in self.lambda_vals: new_lambda = DecimalNumber(val) new_lambda.move_to(lambda_val, aligned_edge = LEFT) - new_lambda.highlight(lambda_val.get_color()) + new_lambda.set_color(lambda_val.get_color()) new_lambda_vals.append(new_lambda) self.lambda_vals = new_lambda_vals self.add(*self.lambda_vals) @@ -1143,7 +1143,7 @@ class TweakLambda(LinearTransformationScene): ]) ) new_det.move_to(self.det, aligned_edge = LEFT) - new_det.highlight(self.det.get_color()) + new_det.set_color(self.det.get_color()) self.det = new_det self.add(self.det) @@ -1174,8 +1174,8 @@ class ShowEigenVectorAfterComputing(LinearTransformationScene): "\\vec{\\textbf{v}}", ) v_label.next_to(matrix, RIGHT) - v_label.highlight_by_tex("\\vec{\\textbf{v}}", YELLOW) - v_label.highlight_by_tex("1", MAROON_B) + v_label.set_color_by_tex("\\vec{\\textbf{v}}", YELLOW) + v_label.set_color_by_tex("1", MAROON_B) v_label.add_background_rectangle() v = self.add_vector(self.v_coords) @@ -1210,15 +1210,15 @@ class LineOfReasoning(Scene): equals = expression[i] expression.shift(equals.get_center()[0]*LEFT) break - expression.highlight_by_tex(v_tex, YELLOW) - expression.highlight_by_tex("\\lambda", MAROON_B) + expression.set_color_by_tex(v_tex, YELLOW) + expression.set_color_by_tex("\\lambda", MAROON_B) self.play(FadeIn(expression)) self.wait() class IfYouDidntKnowDeterminants(TeacherStudentsScene): def construct(self): expression = TexMobject("\\det(A-", "\\lambda", "I" ")=0") - expression.highlight_by_tex("\\lambda", MAROON_B) + expression.set_color_by_tex("\\lambda", MAROON_B) expression.scale(1.3) self.teacher_says(expression) self.random_blink() @@ -1239,7 +1239,7 @@ class RevisitExampleTransformation(ExampleTranformationScene): seeking_eigenvalue = TextMobject("Seeking eigenvalue") seeking_eigenvalue.add_background_rectangle() lamb = TexMobject("\\lambda") - lamb.highlight(MAROON_B) + lamb.set_color(MAROON_B) words = VGroup(seeking_eigenvalue, lamb) words.arrange_submobjects() words.next_to(self.matrix, DOWN, buff = LARGE_BUFF) @@ -1262,7 +1262,7 @@ class RevisitExampleTransformation(ExampleTranformationScene): self.apply_transposed_matrix(self.t_matrix) for coords, vect in (i_coords, self.i_hat), (j_coords, self.j_hat): - coords.highlight(vect.get_color()) + coords.set_color(vect.get_color()) coords.scale(0.8) coords.rect = BackgroundRectangle(coords) coords.add_to_back(coords.rect) @@ -1362,7 +1362,7 @@ class RevisitExampleTransformation(ExampleTranformationScene): brace_text.target = brace.target.get_text( "Quadratic polynomial in ", "$\\lambda$" ) - brace_text.target.highlight_by_tex("$\\lambda$", MAROON_B) + brace_text.target.set_color_by_tex("$\\lambda$", MAROON_B) brace_text.target.add_background_rectangle() equals_0 = TexMobject("=0") @@ -1374,7 +1374,7 @@ class RevisitExampleTransformation(ExampleTranformationScene): "\\lambda", "=2", "\\text{ or }", "\\lambda", "=3" ) - final_text.highlight_by_tex("\\lambda", MAROON_B) + final_text.set_color_by_tex("\\lambda", MAROON_B) final_text.next_to(final_brace, DOWN) lambda_equals_two = VGroup(*final_text[:2]).copy() lambda_equals_two.add_to_back(BackgroundRectangle(lambda_equals_two)) @@ -1439,7 +1439,7 @@ class RevisitExampleTransformation(ExampleTranformationScene): for entry in self.diag_entries: lamb = entry[-1] two = TexMobject("2") - two.highlight(lamb.get_color()) + two.set_color(lamb.get_color()) two.move_to(lamb) self.play(Transform(lamb, two)) self.play(*it.chain( @@ -1448,7 +1448,7 @@ class RevisitExampleTransformation(ExampleTranformationScene): )) xy_array = Matrix(["x", "y"]) - xy_array.highlight(YELLOW) + xy_array.set_color(YELLOW) zero_array = Matrix([0, 0]) for array in xy_array, zero_array: array.scale_to_fit_height(self.matrix.get_height()) @@ -1527,7 +1527,7 @@ class Rotate90Degrees(LinearTransformationScene): def setup(self): LinearTransformationScene.setup(self) matrix = Matrix(self.t_matrix.T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(ORIGIN, LEFT) matrix.to_edge(UP) matrix.rect = BackgroundRectangle(matrix) @@ -1564,7 +1564,7 @@ class SolveRotationEigenvalues(Rotate90Degrees): ] for entry in diag_entries: minus_lambda = TexMobject("-\\lambda") - minus_lambda.highlight(MAROON_B) + minus_lambda.set_color(MAROON_B) minus_lambda.move_to(entry) self.play(Transform(entry, minus_lambda)) self.wait() @@ -1597,7 +1597,7 @@ class SolveRotationEigenvalues(Rotate90Degrees): polynomial = TexMobject( "=", "\\lambda^2", "+1=0" ) - polynomial.highlight_by_tex("\\lambda^2", MAROON_B) + polynomial.set_color_by_tex("\\lambda^2", MAROON_B) polynomial.add_background_rectangle() polynomial.next_to(equals, DOWN, buff = MED_LARGE_BUFF, aligned_edge = LEFT) self.play(Write(polynomial)) @@ -1607,7 +1607,7 @@ class SolveRotationEigenvalues(Rotate90Degrees): "\\lambda", "= i", "\\text{ or }", "\\lambda", "= -i" ) - result.highlight_by_tex("\\lambda", MAROON_B) + result.set_color_by_tex("\\lambda", MAROON_B) result.add_background_rectangle() result.next_to(polynomial, DOWN, buff = MED_LARGE_BUFF, aligned_edge = LEFT) self.play(Write(result)) @@ -1644,7 +1644,7 @@ class ShearExample(RevisitExampleTransformation): self.introduce_matrix() self.point_out_eigenvectors() lamb = TexMobject("\\lambda") - lamb.highlight(MAROON_B) + lamb.set_color(MAROON_B) lamb.next_to(self.matrix, DOWN) self.play(FadeIn(lamb)) self.play(*self.get_lambda_to_diag_movements(lamb)) @@ -1664,7 +1664,7 @@ class ShearExample(RevisitExampleTransformation): TextMobject("with eigenvalue", "1") ) for word in words: - word.highlight_by_tex("1", MAROON_B) + word.set_color_by_tex("1", MAROON_B) word.add_to_back(BackgroundRectangle(word)) words.arrange_submobjects(DOWN, buff = MED_SMALL_BUFF) words.next_to(ORIGIN, DOWN+RIGHT, buff = MED_SMALL_BUFF) @@ -1702,7 +1702,7 @@ class ShearExample(RevisitExampleTransformation): brace_text.target = brace.target.get_text( "Quadratic polynomial in ", "$\\lambda$" ) - brace_text.target.highlight_by_tex("$\\lambda$", MAROON_B) + brace_text.target.set_color_by_tex("$\\lambda$", MAROON_B) brace_text.target.add_background_rectangle() equals_0 = TexMobject("=0") @@ -1711,7 +1711,7 @@ class ShearExample(RevisitExampleTransformation): final_brace = Brace(VGroup(parens, equals_0)) final_text = TexMobject("\\lambda", "=1") - final_text.highlight_by_tex("\\lambda", MAROON_B) + final_text.set_color_by_tex("\\lambda", MAROON_B) final_text.next_to(final_brace, DOWN) lambda_equals_two = VGroup(*final_text[:2]).copy() lambda_equals_two.add_to_back(BackgroundRectangle(lambda_equals_two)) @@ -1787,7 +1787,7 @@ class ScalingExample(LinearTransformationScene): } def construct(self): matrix = Matrix(self.t_matrix.T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.add_to_back(BackgroundRectangle(matrix)) matrix.next_to(ORIGIN, LEFT) matrix.to_edge(UP) @@ -1808,7 +1808,7 @@ class IntroduceEigenbasis(TeacherStudentsScene): """Make sure you've watched the last video""" ]) - words1.highlight(YELLOW) + words1.set_color(YELLOW) self.teacher_says(words1) self.change_student_modes( "pondering", "raise_right_hand", "erm" @@ -1836,7 +1836,7 @@ class BasisVectorsAreEigenvectors(LinearTransformationScene): } def construct(self): matrix = Matrix(self.t_matrix.T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(ORIGIN, LEFT) matrix.to_edge(UP) @@ -1858,10 +1858,10 @@ class BasisVectorsAreEigenvectors(LinearTransformationScene): i_coords = Matrix(self.t_matrix[0]) i_coords.next_to(self.i_hat.get_end(), DOWN+LEFT) - i_coords.highlight(X_COLOR) + i_coords.set_color(X_COLOR) j_coords = Matrix(self.t_matrix[1]) j_coords.next_to(self.j_hat.get_end(), RIGHT) - j_coords.highlight(Y_COLOR) + j_coords.set_color(Y_COLOR) for array in matrix, i_coords, j_coords: array.rect = BackgroundRectangle(array) @@ -1898,7 +1898,7 @@ class BasisVectorsAreEigenvectors(LinearTransformationScene): for entries in diag_entries, off_diag_entries: self.play( entries.scale_in_place, 1.3, - entries.highlight, YELLOW, + entries.set_color, YELLOW, run_time = 2, rate_func = there_and_back ) @@ -1930,18 +1930,18 @@ class DefineDiagonalMatrix(Scene): for entries in off_diag_entries, diag_entries: self.play( entries.scale_in_place, 1.1, - entries.highlight, YELLOW, + entries.set_color, YELLOW, rate_func = there_and_back, ) self.wait() self.play(Write(title)) self.wait() self.play( - matrix.highlight_columns, + matrix.set_color_columns, X_COLOR, Y_COLOR, Z_COLOR, YELLOW ) self.wait() - self.play(diag_entries.highlight, MAROON_B) + self.play(diag_entries.set_color, MAROON_B) self.play( diag_entries.scale_in_place, 1.1, rate_func = there_and_back, @@ -1951,7 +1951,7 @@ class DefineDiagonalMatrix(Scene): class RepeatedMultiplicationInAction(Scene): def construct(self): vector = Matrix(["x", "y"]) - vector.highlight(YELLOW) + vector.set_color(YELLOW) vector.scale(1.2) vector.shift(RIGHT) matrix, scalars = self.get_matrix(vector) @@ -1984,7 +1984,7 @@ class RepeatedMultiplicationInAction(Scene): to_remove = [] for v_entry, scalar, new_scalar in zip(vector.get_entries(), scalars, new_scalars): scalar.exp.target = new_exp_mob.copy() - scalar.exp.target.highlight(scalar.get_color()) + scalar.exp.target.set_color(scalar.get_color()) scalar.exp.target.move_to(scalar.exp, aligned_edge = LEFT) new_scalar.target = scalar.exp.target scalar.target = scalar.copy() @@ -2010,7 +2010,7 @@ class RepeatedMultiplicationInAction(Scene): def get_matrix(self, vector): matrix = Matrix([[3, 0], [0, 2]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(vector, LEFT) scalars = [matrix.get_mob_matrix()[i, i] for i in range(2)] matrix.remove(*scalars) @@ -2023,9 +2023,9 @@ class RepeatedMultilpicationOfMatrices(Scene): } def construct(self): vector = Matrix(["x", "y"]) - vector.highlight(YELLOW) + vector.set_color(YELLOW) matrix = Matrix(self.matrix) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrices = VGroup(*[ matrix.copy(), TexMobject("\\dots\\dots"), @@ -2059,7 +2059,7 @@ class RepeatedMultilpicationOfMatrices(Scene): hund.target = hund.copy() hund.target.scale(0.5) hund.target.next_to(entry, UP+RIGHT, buff = 0) - hund.target.highlight(entry.get_color()) + hund.target.set_color(entry.get_color()) VGroup(hund.target, entry).move_to(entry, aligned_edge = DOWN) lb, rb = last_matrix.target.get_brackets() lb.shift(SMALL_BUFF*LEFT) @@ -2177,7 +2177,7 @@ class ChangeToEigenBasis(ExampleTranformationScene): b1, b2 = self.b1, self.b2 for vect in b1, b2: vect.coords = vector_coordinate_label(vect) - vect.coords.highlight(vect.get_color()) + vect.coords.set_color(vect.get_color()) vect.entries = vect.coords.get_entries() vect.entries.target = vect.entries.copy() b1.coords.next_to(b1.get_end(), DOWN+RIGHT) @@ -2242,20 +2242,20 @@ class ChangeToEigenBasis(ExampleTranformationScene): self.play(FadeOut(self.plane)) cob_transform = self.get_matrix_transformation([[1, 0], [-1, 1]]) ApplyMethod(self.plane.apply_function, cob_transform).update(1) - self.plane.main_lines.highlight(BLUE_D) - self.plane.axes.highlight(WHITE) + self.plane.main_lines.set_color(BLUE_D) + self.plane.axes.set_color(WHITE) self.play( FadeIn(self.plane), *map(Animation, self.foreground_mobjects+self.moving_vectors) ) - self.add(self.plane.copy().highlight(GREY).set_stroke(width = 2)) + self.add(self.plane.copy().set_color(GREY).set_stroke(width = 2)) self.apply_transposed_matrix(self.t_matrix) equals = TexMobject("=").next_to(cob_matrix) final_matrix = Matrix([[3, 0], [0, 2]]) final_matrix.add_to_back(BackgroundRectangle(final_matrix)) for i in range(2): - final_matrix.get_mob_matrix()[i, i].highlight(MAROON_B) + final_matrix.get_mob_matrix()[i, i].set_color(MAROON_B) final_matrix.next_to(equals, RIGHT) self.play( Write(equals), diff --git a/old_projects/eola/chapter11.py b/old_projects/eola/chapter11.py index 70b55ec9..e6b11bc9 100644 --- a/old_projects/eola/chapter11.py +++ b/old_projects/eola/chapter11.py @@ -60,12 +60,12 @@ class OpeningQuote(Scene): enforce_new_line_structure = False, alignment = "", ) - words.highlight_by_tex("axioms,", BLUE) - words.highlight_by_tex("difficult for the uninitiated", RED) + words.set_color_by_tex("axioms,", BLUE) + words.set_color_by_tex("difficult for the uninitiated", RED) words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) author = TextMobject("-Vladmir Arnold") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = MED_LARGE_BUFF) self.play(Write(words, run_time = 8)) @@ -78,7 +78,7 @@ class RevisitOriginalQuestion(TeacherStudentsScene): self.teacher_says("Let's revisit ", "\\\\ an old question") self.random_blink() question = TextMobject("What are ", "vectors", "?", arg_separator = "") - question.highlight_by_tex("vectors", YELLOW) + question.set_color_by_tex("vectors", YELLOW) self.teacher_says( question, added_anims = [ @@ -116,7 +116,7 @@ class WhatIsA2DVector(LinearTransformationScene): "``Two-dimensional ", "vector", "''", arg_separator = "" ) - two_d_vector.highlight_by_tex("vector", YELLOW) + two_d_vector.set_color_by_tex("vector", YELLOW) two_d_vector.add_background_rectangle() two_d_vector.to_edge(UP) @@ -232,8 +232,8 @@ class HigherDimensionalVectorsNumerically(Scene): colors = [YELLOW, MAROON_B, GREEN] for word, vector, color in zip(words, vectors, colors): vector.shift(word.get_center()[0]*RIGHT) - word.highlight(color) - vector.highlight(color) + word.set_color(color) + vector.set_color(color) for word in words: self.play(FadeIn(word)) @@ -256,7 +256,7 @@ class HigherDimensionalVectorsNumerically(Scene): self.play(*[ Transform( entries[i], - entries[i].copy().scale_in_place(1.2).highlight(WHITE), + entries[i].copy().scale_in_place(1.2).set_color(WHITE), rate_func = squish_rate_func( there_and_back, i/(2.*num_entries), @@ -388,8 +388,8 @@ class ManyCoordinateSystems(LinearTransformationScene): inv_cob = np.linalg.inv(cob_matrix) coords = np.dot(inv_cob, self.v_coords) array = Matrix(map(DecimalNumber, coords)) - array.get_entries()[0].highlight(X_COLOR) - array.get_entries()[1].highlight(Y_COLOR) + array.get_entries()[0].set_color(X_COLOR) + array.get_entries()[1].set_color(Y_COLOR) array.add_to_back(BackgroundRectangle(array)) for entry in array.get_entries(): entry.add_to_back(BackgroundRectangle(entry)) @@ -434,8 +434,8 @@ class DeterminantAndEigenvectorDontCare(LinearTransformationScene): "eigenvectors", "don't \\\\ care about the coordinate system" ) - words.highlight_by_tex("Determinant", YELLOW) - words.highlight_by_tex("eigenvectors", MAROON_B) + words.set_color_by_tex("Determinant", YELLOW) + words.set_color_by_tex("eigenvectors", MAROON_B) words.add_background_rectangle() words.to_edge(UP) dark_yellow = Color(rgb = interpolate( @@ -452,7 +452,7 @@ class DeterminantAndEigenvectorDontCare(LinearTransformationScene): blob.shift(2*LEFT+UP) det_label = TexMobject("A") det_label = VGroup( - VectorizedPoint(det_label.get_left()).highlight(WHITE), + VectorizedPoint(det_label.get_left()).set_color(WHITE), det_label ) det_label_target = TexMobject("\\det(M)\\cdot", "A") @@ -569,14 +569,14 @@ class OtherVectorishThings(TeacherStudentsScene): "vectorish", "things..." ) - words.highlight_by_tex("vectorish", YELLOW) + words.set_color_by_tex("vectorish", YELLOW) self.teacher_says(words) self.change_student_modes( "pondering", "raise_right_hand", "erm" ) self.random_blink(2) words = TextMobject("...like", "functions") - words.highlight_by_tex("functions", PINK) + words.set_color_by_tex("functions", PINK) self.teacher_says(words) self.change_student_modes(*["pondering"]*3) self.random_blink(2) @@ -638,7 +638,7 @@ class FunctionGraphScene(Scene): x += nudge_size y = function_graph.function(x) lines.add(Line(x*RIGHT, x*RIGHT+y*UP)) - lines.highlight(function_graph.get_color()) + lines.set_color(function_graph.get_color()) return lines def add_lines(self, output_lines): @@ -655,7 +655,7 @@ class FunctionGraphScene(Scene): label = TexMobject("%s(x)"%name) label.next_to(function_graph.point_from_proportion(1), RIGHT) label.shift_onto_screen() - label.highlight(function_graph.get_color()) + label.set_color(function_graph.get_color()) if animate: self.play(Write(label)) else: @@ -745,9 +745,9 @@ class AddTwoFunctions(FunctionGraphScene): TexMobject(")") )) result.arrange_submobjects() - result[0].highlight(self.graph_colors[2]) - VGroup(result[5], result[7]).highlight(self.graph_colors[0]) - VGroup(result[9], result[11]).highlight(self.graph_colors[1]) + result[0].set_color(self.graph_colors[2]) + VGroup(result[5], result[7]).set_color(self.graph_colors[0]) + VGroup(result[9], result[11]).set_color(self.graph_colors[1]) return result @@ -765,7 +765,7 @@ class AddTwoFunctions(FunctionGraphScene): dots.add(dot) dots.target.add(dot.target) for group in dots, dots.target: - group.highlight(sum_lines[0].get_color()) + group.set_color(sum_lines[0].get_color()) self.play(ShowCreation(dots)) if len(list(g_lines)) == 1: kwargs = {} @@ -790,9 +790,9 @@ class AddVectorsCoordinateByCoordinate(Scene): v2 = Matrix(["x_2", "y_2", "z_2"]) v_sum = Matrix(["x_1 + x_2", "y_1 + y_2", "z_1 + z_2"]) for v in v1, v2, v_sum: - v.get_entries()[0].highlight(X_COLOR) - v.get_entries()[1].highlight(Y_COLOR) - v.get_entries()[2].highlight(Z_COLOR) + v.get_entries()[0].set_color(X_COLOR) + v.get_entries()[1].set_color(Y_COLOR) + v.get_entries()[2].set_color(Z_COLOR) plus, equals = TexMobject("+=") VGroup(v1, plus, v2, equals, v_sum).arrange_submobjects() @@ -826,8 +826,8 @@ class ScaleFunction(FunctionGraphScene): self.remove(two_f_label) title = TexMobject("(2f)", "(x) = 2", "f", "(x)") - title.highlight_by_tex("(2f)", scaled_graph.get_color()) - title.highlight_by_tex("f", graph.get_color()) + title.set_color_by_tex("(2f)", scaled_graph.get_color()) + title.set_color_by_tex("f", graph.get_color()) title.next_to(ORIGIN, LEFT, buff = MED_SMALL_BUFF) title.to_edge(UP) self.add(title) @@ -928,9 +928,9 @@ class FromVectorsToFunctions(VectorScene): fg_scene_config = FunctionGraphScene.CONFIG graph = FunctionGraph(fg_scene_config["default_functions"][0]) - graph.highlight(MAROON_B) + graph.set_color(MAROON_B) func_tex = TexMobject("\\frac{1}{9}x^3 - x") - func_tex.highlight(graph.get_color()) + func_tex.set_color(graph.get_color()) func_tex.shift(5.5*RIGHT+2*UP) words = VGroup(*[ @@ -973,7 +973,7 @@ class FromVectorsToFunctions(VectorScene): def show_derivative(self): func_tex, graph = self.func_tex, self.graph new_graph = FunctionGraph(lambda x : (x**2)/3.-1) - new_graph.highlight(YELLOW) + new_graph.set_color(YELLOW) func_tex.generate_target() lp, rp = parens = TexMobject("()") @@ -981,7 +981,7 @@ class FromVectorsToFunctions(VectorScene): L, equals = TexMobject("L=") deriv = TexMobject("\\frac{d}{dx}") new_func = TexMobject("\\frac{1}{3}x^2 - 1") - new_func.highlight(YELLOW) + new_func.set_color(YELLOW) group = VGroup( L, lp, func_tex.target, rp, equals, new_func @@ -1059,7 +1059,7 @@ class ManyFunctions(FunctionGraphScene): graph.stretch_to_fit_height(FRAME_HEIGHT) graph.shift(graph.point_from_proportion(0.5)[1]*DOWN) graph.shift(interpolate(-3, 3, random.random())*UP) - graph.highlight(random_bright_color()) + graph.set_color(random_bright_color()) self.play( ShowCreation(graph, run_time = run_time), *added_anims @@ -1073,7 +1073,7 @@ class WhatDoesLinearMean(TeacherStudentsScene): to be """, "linear", "?", arg_separator = "" ) - words.highlight_by_tex("linear", BLUE) + words.set_color_by_tex("linear", BLUE) self.student_says(words) self.change_student_modes("pondering") self.random_blink(4) @@ -1124,9 +1124,9 @@ class FormalDefinitionOfLinear(LinearTransformationScene): for tex_set in tex_sets: words = VGroup(*it.starmap(TexMobject, tex_set)) for word in words: - word.highlight_by_tex(v_tex, YELLOW) - word.highlight_by_tex(w_tex, MAROON_B) - word.highlight_by_tex("c", GREEN) + word.set_color_by_tex(v_tex, YELLOW) + word.set_color_by_tex(w_tex, MAROON_B) + word.set_color_by_tex("c", GREEN) words.arrange_submobjects() words.lhs = words[1] words.rhs = words[2] @@ -1233,8 +1233,8 @@ class FormalDefinitionOfLinear(LinearTransformationScene): v_label = self.add_transformable_label(v, "v") scaled_v = v.copy().scale(2) scaled_v_label = TexMobject("c\\vec{\\textbf{v}}") - scaled_v_label.highlight(YELLOW) - scaled_v_label[0].highlight(GREEN) + scaled_v_label.set_color(YELLOW) + scaled_v_label[0].set_color(GREEN) scaled_v_label.next_to(scaled_v.get_end(), RIGHT) scaled_v_label.add_background_rectangle() v_copy, v_label_copy = v.copy(), v_label.copy() @@ -1250,8 +1250,8 @@ class FormalDefinitionOfLinear(LinearTransformationScene): transform = self.get_matrix_transformation(self.t_matrix) point = transform(scaled_v.get_end()) scaled_v_label.target = TexMobject("L(", "c", "\\vec{\\textbf{v}}", ")") - scaled_v_label.target.highlight_by_tex("c", GREEN) - scaled_v_label.target.highlight_by_tex("\\vec{\\textbf{v}}", YELLOW) + scaled_v_label.target.set_color_by_tex("c", GREEN) + scaled_v_label.target.set_color_by_tex("\\vec{\\textbf{v}}", YELLOW) scaled_v_label.target.scale(0.8) scaled_v_label.target.next_to(point, RIGHT) scaled_v_label.target.add_background_rectangle() @@ -1263,8 +1263,8 @@ class FormalDefinitionOfLinear(LinearTransformationScene): self.wait() scaled_v = v.copy().scale(2) rhs = TexMobject("=", "c", "L(", "\\vec{\\textbf{v}}", ")") - rhs.highlight_by_tex("c", GREEN) - rhs.highlight_by_tex("\\vec{\\textbf{v}}", YELLOW) + rhs.set_color_by_tex("c", GREEN) + rhs.set_color_by_tex("\\vec{\\textbf{v}}", YELLOW) rhs.add_background_rectangle() rhs.scale(0.8) rhs.next_to(scaled_v_label, RIGHT) @@ -1291,7 +1291,7 @@ class FormalDefinitionOfLinear(LinearTransformationScene): "addition and \\\\ scalar multiplication", ) words.scale(0.9) - words.highlight_by_tex("preserve", YELLOW) + words.set_color_by_tex("preserve", YELLOW) bubble.add_content(words) self.play(FadeIn(randy)) @@ -1311,7 +1311,7 @@ class CalcStudentsKnowThatDerivIsLinear(TeacherStudentsScene): "$\\dfrac{d}{dx}$", "is linear" ) - words.highlight_by_tex("$\\dfrac{d}{dx}$", BLUE) + words.set_color_by_tex("$\\dfrac{d}{dx}$", BLUE) self.teacher_says(words) self.change_student_modes( "pondering", "confused", "erm" @@ -1340,9 +1340,9 @@ class DerivativeIsLinear(Scene): "L(", "c", v_tex, ")=", "c", "L(", v_tex, ")" ) for text in additivity, scaling: - text.highlight_by_tex(v_tex, YELLOW) - text.highlight_by_tex(w_tex, MAROON_B) - text.highlight_by_tex("c", GREEN) + text.set_color_by_tex(v_tex, YELLOW) + text.set_color_by_tex(w_tex, MAROON_B) + text.set_color_by_tex("c", GREEN) deriv_tex = "\\dfrac{d}{dx}" deriv_additivity = TexMobject( @@ -1355,9 +1355,9 @@ class DerivativeIsLinear(Scene): "4", deriv_tex, "(", "x^3", ")" ) for text in deriv_additivity, deriv_scaling: - text.highlight_by_tex("x^3", YELLOW) - text.highlight_by_tex("x^2", MAROON_B) - text.highlight_by_tex("4", GREEN) + text.set_color_by_tex("x^3", YELLOW) + text.set_color_by_tex("x^2", MAROON_B) + text.set_color_by_tex("4", GREEN) self.additivity = additivity self.scaling = scaling @@ -1412,7 +1412,7 @@ class DerivativeIsLinear(Scene): for term in terms: anims += [ term.scale_in_place, 1.2, - term.highlight, RED, + term.set_color, RED, ] self.play( *anims, @@ -1476,19 +1476,19 @@ class GeneneralPolynomialCoordinates(Scene): "a_1", "x", "+", "a_0", ) - poly.highlight_by_tex("a_n", YELLOW) - poly.highlight_by_tex("a_{n-1}", MAROON_B) - poly.highlight_by_tex("a_1", RED) - poly.highlight_by_tex("a_0", GREEN) + poly.set_color_by_tex("a_n", YELLOW) + poly.set_color_by_tex("a_{n-1}", MAROON_B) + poly.set_color_by_tex("a_1", RED) + poly.set_color_by_tex("a_0", GREEN) poly.scale(1.3) array = Matrix( ["a_0", "a_1", "\\vdots", "a_{n-1}", "a_n", "0", "\\vdots"] ) - array.get_entries()[0].highlight(GREEN) - array.get_entries()[1].highlight(RED) - array.get_entries()[3].highlight(MAROON_B) - array.get_entries()[4].highlight(YELLOW) + array.get_entries()[0].set_color(GREEN) + array.get_entries()[1].set_color(RED) + array.get_entries()[3].set_color(MAROON_B) + array.get_entries()[4].set_color(YELLOW) array.scale(1.2) equals = TexMobject("=").scale(1.3) @@ -1529,7 +1529,7 @@ class IntroducePolynomialSpace(Scene): def add_title(self): title = TextMobject("Our current space: ", "All polynomials") title.to_edge(UP) - title[1].highlight(BLUE) + title[1].set_color(BLUE) self.play(Write(title)) self.wait() self.title = title @@ -1562,7 +1562,7 @@ class IntroducePolynomialSpace(Scene): FadeOut(cloud), FadeOut(polys), self.poly1.next_to, ORIGIN, LEFT, - self.poly1.highlight, WHITE + self.poly1.set_color, WHITE ) def split_individual_polynomial(self): @@ -1573,7 +1573,7 @@ class IntroducePolynomialSpace(Scene): one.next_to(self.poly1[-1], RIGHT, aligned_edge = DOWN) self.poly1.add(one) for mob in leading_coef, one: - mob.highlight(BLACK) + mob.set_color(BLACK) brace = Brace(self.poly1) brace.text = brace.get_text("Already written as \\\\ a linear combination") @@ -1588,7 +1588,7 @@ class IntroducePolynomialSpace(Scene): GrowFromCenter(brace), Write(brace.text), *[ - ApplyMethod(self.poly1[index].highlight, color) + ApplyMethod(self.poly1[index].set_color, color) for index, color in index_to_color.items() ] ) @@ -1603,7 +1603,7 @@ class IntroducePolynomialSpace(Scene): h_line.next_to(title, DOWN) x_cubed = TexMobject("x^3") - x_cubed.highlight(MAROON_B) + x_cubed.set_color(MAROON_B) x_cubed.to_corner(DOWN+RIGHT).shift(2*(DOWN+RIGHT)) basis_group = VGroup( self.poly1[7][1], @@ -1624,7 +1624,7 @@ class IntroducePolynomialSpace(Scene): for i in range(len(list(basis_group))) ] for basis_func, term in zip(basis_functions, basis_group.target): - basis_func.highlight(term.get_color()) + basis_func.set_color(term.get_color()) basis_func.next_to(term, LEFT) for i in 2, 3: basis_functions[i].shift(SMALL_BUFF*DOWN) @@ -1645,7 +1645,7 @@ class IntroducePolynomialSpace(Scene): def show_example_coordinates(self): coords = Matrix(["5", "3", "1", "0", "0", "\\vdots"]) for i, color in enumerate([X_COLOR, Y_COLOR, Z_COLOR]): - coords[i].highlight(color) + coords[i].set_color(color) self.poly1.generate_target() equals = TexMobject("=").next_to(coords, LEFT) self.poly1.target.next_to(equals, LEFT) @@ -1677,8 +1677,8 @@ class IntroducePolynomialSpace(Scene): target[5].next_to(target[3], LEFT) target[2].next_to(target[0], LEFT) more_terms = [ - TexMobject("+0", "x^3").highlight_by_tex("x^3", MAROON_B), - TexMobject("+0", "x^4").highlight_by_tex("x^4", YELLOW), + TexMobject("+0", "x^3").set_color_by_tex("x^3", MAROON_B), + TexMobject("+0", "x^4").set_color_by_tex("x^4", YELLOW), TexMobject("\\vdots") ] for entry, term in zip(entries, terms+more_terms): @@ -1697,12 +1697,12 @@ class IntroducePolynomialSpace(Scene): self.play(*map(FadeOut, [self.poly1]+more_terms)) self.poly2.next_to(equals, LEFT) self.poly2.shift(MED_SMALL_BUFF*UP) - self.poly2.highlight(WHITE) - self.poly2[0].highlight(TEAL) - VGroup(*self.poly2[3:5]).highlight(Z_COLOR) + self.poly2.set_color(WHITE) + self.poly2[0].set_color(TEAL) + VGroup(*self.poly2[3:5]).set_color(Z_COLOR) new_coords = Matrix(["0", "0", "-5", "0", "0", "0", "0", "4", "\\vdots"]) - new_coords.get_entries()[2].highlight(Z_COLOR) - new_coords.get_entries()[7].highlight(TEAL) + new_coords.get_entries()[2].set_color(Z_COLOR) + new_coords.get_entries()[7].set_color(TEAL) new_coords.scale_to_fit_height(6) new_coords.move_to(coords, aligned_edge = LEFT) self.play( @@ -1742,7 +1742,7 @@ class IntroducePolynomialSpace(Scene): last_col.arrange_submobjects(DOWN, buff = 0.83) last_col.move_to(last_col_top, aligned_edge = UP+RIGHT) ##End horrible - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR, MAROON_B) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR, MAROON_B) deriv = TexMobject("\\dfrac{d}{dx}") equals = TexMobject("=") @@ -1755,7 +1755,7 @@ class IntroducePolynomialSpace(Scene): diag_entries.save_state() diag_entries.generate_target() diag_entries.target.scale_in_place(1.2) - diag_entries.target.highlight(YELLOW) + diag_entries.target.set_color(YELLOW) for anim in MoveToTarget(diag_entries), diag_entries.restore: self.play( anim, @@ -1784,10 +1784,10 @@ class IntroducePolynomialSpace(Scene): "5", ")" ) coefs = VGroup(*np.array(poly)[[10, 7, 4, 1]]) - VGroup(*poly[1:3]).highlight(MAROON_B) - VGroup(*poly[4:6]).highlight(Z_COLOR) - VGroup(*poly[7:9]).highlight(Y_COLOR) - VGroup(*poly[10:11]).highlight(X_COLOR) + VGroup(*poly[1:3]).set_color(MAROON_B) + VGroup(*poly[4:6]).set_color(Z_COLOR) + VGroup(*poly[7:9]).set_color(Y_COLOR) + VGroup(*poly[10:11]).set_color(X_COLOR) poly.next_to(deriv) self.play(FadeIn(poly)) @@ -1818,9 +1818,9 @@ class IntroducePolynomialSpace(Scene): self.play(*map(Write, [eq1, eq2, brace])) result_coefs = VGroup(*np.array(poly_result)[[6, 3, 0]]) - VGroup(*poly_result[0:2]).highlight(MAROON_B) - VGroup(*poly_result[3:5]).highlight(Z_COLOR) - VGroup(*poly_result[6:]).highlight(Y_COLOR) + VGroup(*poly_result[0:2]).set_color(MAROON_B) + VGroup(*poly_result[3:5]).set_color(Z_COLOR) + VGroup(*poly_result[6:]).set_color(Y_COLOR) result_terms = [ VGroup(*poly_result[6:]), VGroup(*poly_result[3:6]), @@ -1890,8 +1890,8 @@ class IntroducePolynomialSpace(Scene): class MatrixVectorMultiplicationAndDerivative(TeacherStudentsScene): def construct(self): mv_mult = VGroup( - Matrix([[3, 1], [0, 2]]).highlight_columns(X_COLOR, Y_COLOR), - Matrix(["x", "y"]).highlight_columns(YELLOW) + Matrix([[3, 1], [0, 2]]).set_color_columns(X_COLOR, Y_COLOR), + Matrix(["x", "y"]).set_color_columns(YELLOW) ) mv_mult.arrange_submobjects() mv_mult.scale(0.75) @@ -1899,7 +1899,7 @@ class MatrixVectorMultiplicationAndDerivative(TeacherStudentsScene): deriv = TexMobject("\\dfrac{df}{dx}") group = VGroup(mv_mult, arrow, deriv) group.arrange_submobjects(buff = MED_SMALL_BUFF) - arrow.highlight(BLACK) + arrow.set_color(BLACK) teacher = self.get_teacher() bubble = teacher.get_bubble(SpeechBubble, height = 4) @@ -1917,7 +1917,7 @@ class MatrixVectorMultiplicationAndDerivative(TeacherStudentsScene): h_line = Line(ORIGIN, RIGHT).scale(words.get_width()) h_line.next_to(words, DOWN) group.target.next_to(h_line, DOWN, buff = MED_SMALL_BUFF) - group.target[1].highlight(WHITE) + group.target[1].set_color(WHITE) new_group = VGroup(words, h_line, group.target) bubble.add_content(new_group) @@ -1942,7 +1942,7 @@ class CompareTermsInLinearAlgebraToFunction(Scene): VGroup(l_title, r_title).get_bottom()[1]*UP + SMALL_BUFF*DOWN ) v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) - VGroup(h_line, v_line).highlight(BLUE) + VGroup(h_line, v_line).set_color(BLUE) self.add(l_title, r_title) self.play(*map(ShowCreation, [h_line, v_line])) @@ -2036,8 +2036,8 @@ class YouAsAMathematician(Scene): arrow = TexMobject("\\Rightarrow") for tex in eigen_equation, v_ne_zero, det_equation: - tex.highlight_by_tex(v_tex, YELLOW) - tex.highlight_by_tex("\\lambda", MAROON_B) + tex.set_color_by_tex(v_tex, YELLOW) + tex.set_color_by_tex("\\lambda", MAROON_B) lhs = VGroup(eigen_equation, v_ne_zero) lhs.arrange_submobjects(DOWN) @@ -2140,7 +2140,7 @@ class MathematicianSpeakingToAll(Scene): def construct(self): mathy = Mathematician().to_corner(DOWN+LEFT) others = VGroup(*[ - Randolph().flip().highlight(color) + Randolph().flip().set_color(color) for color in BLUE_D, GREEN_E, GOLD_E, BLUE_C ]) others.arrange_submobjects() @@ -2239,7 +2239,7 @@ class ListAxioms(Scene): ] for axiom in axioms: for tex, color in tex_color_pairs: - axiom.highlight_by_tex(tex, color) + axiom.set_color_by_tex(tex, color) axioms.arrange_submobjects( DOWN, buff = MED_LARGE_BUFF, aligned_edge = LEFT @@ -2254,7 +2254,7 @@ class ListAxioms(Scene): )) self.wait() axioms_word = TextMobject("``Axioms''") - axioms_word.highlight(YELLOW) + axioms_word.set_color(YELLOW) axioms_word.scale(2) axioms_word.shift(FRAME_X_RADIUS*RIGHT/2, FRAME_Y_RADIUS*DOWN/2) self.play(Write(axioms_word, run_time = 3)) @@ -2265,7 +2265,7 @@ class AxiomsAreInterface(Scene): mathy = Mathematician().to_edge(LEFT) mathy.change_mode("pondering") others = [ - Randolph().flip().highlight(color) + Randolph().flip().set_color(color) for color in BLUE_D, GREEN_E, GOLD_E, BLUE_C ] others = VGroup( @@ -2284,7 +2284,7 @@ class AxiomsAreInterface(Scene): "Axioms", "are", "rules of nature" ) words.to_edge(UP) - axioms.highlight(YELLOW) + axioms.set_color(YELLOW) an_interface = TextMobject("an interface") an_interface.next_to(rules_of_nature, DOWN) red_line = Line( @@ -2338,7 +2338,7 @@ class VectorSpaceOfPiCreatures(Scene): pi.flip() pi.shift(0.5*(random.random()-0.5)*RIGHT) pi.shift(0.5*(random.random()-0.5)*UP) - pi.highlight(random.choice([ + pi.set_color(random.choice([ BLUE_B, BLUE_C, BLUE_D, BLUE_E, MAROON_B, MAROON_C, MAROON_D, MAROON_E, GREY_BROWN, GREY_BROWN, GREY, @@ -2546,8 +2546,8 @@ class AbstractionIsThePrice(Scene): "Abstractness", "is the price\\\\" "of", "generality" ) - words.highlight_by_tex("Abstractness", YELLOW) - words.highlight_by_tex("generality", BLUE) + words.set_color_by_tex("Abstractness", YELLOW) + words.set_color_by_tex("generality", BLUE) self.play(Write(words)) self.wait() diff --git a/old_projects/eola/chapter2.py b/old_projects/eola/chapter2.py index e803f4a5..ba9b122a 100644 --- a/old_projects/eola/chapter2.py +++ b/old_projects/eola/chapter2.py @@ -31,9 +31,9 @@ class OpeningQuote(Scene): """) words.to_edge(UP) for mob in words.submobjects[49:49+18]: - mob.highlight(GREEN) + mob.set_color(GREEN) author = TextMobject("-Angus K. Rodgers") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -75,9 +75,9 @@ class CoordinatesAsScalars(VectorScene): title.to_edge(UP) x, y = array.get_mob_matrix().flatten() - new_x = x.copy().scale(2).highlight(X_COLOR) + new_x = x.copy().scale(2).set_color(X_COLOR) new_x.move_to(3*LEFT+2*UP) - new_y = y.copy().scale(2).highlight(Y_COLOR) + new_y = y.copy().scale(2).set_color(Y_COLOR) new_y.move_to(3*RIGHT+2*UP) i_hat, j_hat = self.get_basis_vectors() @@ -181,8 +181,8 @@ class CoordinatesAsScalars(VectorScene): new_mob.move_to(new_array) new_mob.shift_onto_screen() i_hat, plus, j_hat = new_mob.split() - i_hat.highlight(X_COLOR) - j_hat.highlight(Y_COLOR) + i_hat.set_color(X_COLOR) + j_hat.set_color(Y_COLOR) self.play(Transform(new_array, new_mob)) self.wait() @@ -208,8 +208,8 @@ class CoordinatesAsScalarsExample2(CoordinatesAsScalars): """) text.scale_to_fit_width(FRAME_X_RADIUS-1) text.to_corner(UP+RIGHT) - VMobject(*text.split()[:2]).highlight(X_COLOR) - VMobject(*text.split()[5:7]).highlight(Y_COLOR) + VMobject(*text.split()[:2]).set_color(X_COLOR) + VMobject(*text.split()[5:7]).set_color(Y_COLOR) self.play(Write(text)) self.wait(2) self.remove(*basis_vectors + labels) @@ -365,7 +365,7 @@ class ShowVaryingLinearCombinations(VectorScene): everything = VMobject(*everything) alt_coords = [a.mobject for a in scalar_anims] array = Matrix([ - mob.copy().highlight(color) + mob.copy().set_color(color) for mob, color in zip( alt_coords, [self.vector1_color, self.vector2_color] @@ -400,8 +400,8 @@ class ShowVaryingLinearCombinations(VectorScene): self.add(ij_array, x_line, y_line) x, y = ij_array.get_mob_matrix().flatten() self.play( - ApplyMethod(x.highlight, X_COLOR), - ApplyMethod(y.highlight, Y_COLOR), + ApplyMethod(x.set_color, X_COLOR), + ApplyMethod(y.set_color, Y_COLOR), ) neq = TexMobject("\\neq") neq.next_to(array) @@ -458,8 +458,8 @@ class NameLinearCombinations(Scene): "and", "$\\vec{\\textbf{w}}$" ]) - words.split()[1].highlight(v_color) - words.split()[3].highlight(w_color) + words.split()[1].set_color(v_color) + words.split()[3].set_color(w_color) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(UP) @@ -467,8 +467,8 @@ class NameLinearCombinations(Scene): "a", "\\vec{\\textbf{v}}", "+", "b", "\\vec{\\textbf{w}}" ]) equation.arrange_submobjects(buff = 0.1, aligned_edge = DOWN) - equation.split()[1].highlight(v_color) - equation.split()[4].highlight(w_color) + equation.split()[1].set_color(v_color) + equation.split()[4].set_color(w_color) a, b = np.array(equation.split())[[0, 3]] equation.scale(2) equation.next_to(words, DOWN, buff = 1) @@ -604,17 +604,17 @@ class DefineSpan(Scene): definition.scale_to_fit_width(FRAME_WIDTH-1) definition.to_edge(UP) def_mobs = np.array(definition.split()) - VMobject(*def_mobs[4:4+4]).highlight(PINK) - VMobject(*def_mobs[11:11+2]).highlight(v_color) - VMobject(*def_mobs[16:16+2]).highlight(w_color) - VMobject(*def_mobs[-19:-1]).highlight(YELLOW) + VMobject(*def_mobs[4:4+4]).set_color(PINK) + VMobject(*def_mobs[11:11+2]).set_color(v_color) + VMobject(*def_mobs[16:16+2]).set_color(w_color) + VMobject(*def_mobs[-19:-1]).set_color(YELLOW) equation = TexMobject([ "a", "\\vec{\\textbf{v}}", "+", "b", "\\vec{\\textbf{w}}" ]) equation.arrange_submobjects(buff = 0.1, aligned_edge = DOWN) - equation.split()[1].highlight(v_color) - equation.split()[4].highlight(w_color) + equation.split()[1].set_color(v_color) + equation.split()[4].set_color(w_color) a, b = np.array(equation.split())[[0, 3]] equation.scale(2) equation.next_to(definition, DOWN, buff = 1) @@ -659,7 +659,7 @@ class VectorsToDotsScene(VectorScene): self.end_color, len(vectors) ) for vect, color in zip(vectors, colors): - vect.highlight(color) + vect.set_color(color) prototype_vector = vectors[3*len(vectors)/4] vector_group = VMobject(*vectors) @@ -830,10 +830,10 @@ class LinearCombinationOfThreeVectorsText(Scene): $\\vec{\\textbf{w}}$, and $\\vec{\\textbf{u}}$: """) - VMobject(*text.split()[-12:-10]).highlight(MAROON_C) - VMobject(*text.split()[-9:-7]).highlight(BLUE) - VMobject(*text.split()[-3:-1]).highlight(RED_C) - VMobject(*text.split()[:17]).highlight(GREEN) + VMobject(*text.split()[-12:-10]).set_color(MAROON_C) + VMobject(*text.split()[-9:-7]).set_color(BLUE) + VMobject(*text.split()[-3:-1]).set_color(RED_C) + VMobject(*text.split()[:17]).set_color(GREEN) text.scale_to_fit_width(FRAME_WIDTH - 1) text.to_edge(UP) @@ -842,9 +842,9 @@ class LinearCombinationOfThreeVectorsText(Scene): b\\vec{\\textbf{w}} + c\\vec{\\textbf{u}} $""") - VMobject(*equation.split()[-10:-8]).highlight(MAROON_C) - VMobject(*equation.split()[-6:-4]).highlight(BLUE) - VMobject(*equation.split()[-2:]).highlight(RED_C) + VMobject(*equation.split()[-10:-8]).set_color(MAROON_C) + VMobject(*equation.split()[-6:-4]).set_color(BLUE) + VMobject(*equation.split()[-2:]).set_color(RED_C) a, b, c = np.array(equation.split())[[0, 4, 8]] @@ -854,7 +854,7 @@ class LinearCombinationOfThreeVectorsText(Scene): span_comment = TextMobject("For span, let these constants vary") span_comment.scale(1.5) span_comment.next_to(equation, DOWN, buff = 2) - VMobject(*span_comment.split()[3:7]).highlight(YELLOW) + VMobject(*span_comment.split()[3:7]).set_color(YELLOW) arrows = VMobject(*[ Arrow(span_comment, var) for var in a, b, c @@ -882,18 +882,18 @@ class SpanCasesWords(Scene): Case 1: $\\vec{\\textbf{u}}$ is in the span of $\\vec{\\textbf{v}}$ and $\\vec{\\textbf{u}}$ """) - VMobject(*words1.split()[6:8]).highlight(RED_C) - VMobject(*words1.split()[-7:-5]).highlight(MAROON_C) - VMobject(*words1.split()[-2:]).highlight(BLUE) + VMobject(*words1.split()[6:8]).set_color(RED_C) + VMobject(*words1.split()[-7:-5]).set_color(MAROON_C) + VMobject(*words1.split()[-2:]).set_color(BLUE) words2 = TextMobject(""" Case 2: $\\vec{\\textbf{u}}$ is not in the span of $\\vec{\\textbf{v}}$ and $\\vec{\\textbf{u}}$ """) - VMobject(*words2.split()[6:8]).highlight(RED_C) - VMobject(*words2.split()[-7:-5]).highlight(MAROON_C) - VMobject(*words2.split()[-2:]).highlight(BLUE) - VMobject(*words2.split()[10:13]).highlight(RED) + VMobject(*words2.split()[6:8]).set_color(RED_C) + VMobject(*words2.split()[-7:-5]).set_color(MAROON_C) + VMobject(*words2.split()[-2:]).set_color(BLUE) + VMobject(*words2.split()[10:13]).set_color(RED) for words in words1, words2: words.scale_to_fit_width(FRAME_WIDTH - 1) @@ -914,9 +914,9 @@ class LinearDependentWords(Scene): "``Linearly dependent'' ", ]) v, _and, w, are, rest = words1.split() - v.highlight(MAROON_C) - w.highlight(BLUE) - rest.highlight(YELLOW) + v.set_color(MAROON_C) + w.set_color(BLUE) + rest.set_color(YELLOW) words2 = TextMobject([ "$\\vec{\\textbf{v}}$,", @@ -927,10 +927,10 @@ class LinearDependentWords(Scene): "``Linearly dependent'' ", ]) v, w, _and, u, are, rest = words2.split() - v.highlight(MAROON_C) - w.highlight(BLUE) - u.highlight(RED_C) - rest.highlight(YELLOW) + v.set_color(MAROON_C) + w.set_color(BLUE) + u.set_color(RED_C) + rest.set_color(YELLOW) for words in words1, words2: words.scale_to_fit_width(FRAME_WIDTH - 1) @@ -944,7 +944,7 @@ class LinearDependentWords(Scene): class LinearDependentEquations(Scene): def construct(self): title = TextMobject("``Linearly dependent'' ") - title.highlight(YELLOW) + title.set_color(YELLOW) title.scale(2) title.to_edge(UP) self.add(title) @@ -956,8 +956,8 @@ class LinearDependentEquations(Scene): "\\vec{\\textbf{v}}", ]) w, eq, a, v = equation1.split() - w.highlight(BLUE) - v.highlight(MAROON_C) + w.set_color(BLUE) + v.set_color(MAROON_C) equation1.scale(2) eq1_copy = equation1.copy() @@ -977,9 +977,9 @@ class LinearDependentEquations(Scene): "\\vec{\\textbf{w}}", ]) u, eq, a, v, plus, b, w = equation2.split() - u.highlight(RED) - w.highlight(BLUE) - v.highlight(MAROON_C) + u.set_color(RED) + w.set_color(BLUE) + v.set_color(MAROON_C) equation2.scale(2) eq2_copy = equation2.copy() @@ -1006,7 +1006,7 @@ class LinearDependentEquations(Scene): self.wait(2) new_title = TextMobject("``Linearly independent'' ") - new_title.highlight(GREEN) + new_title.set_color(GREEN) new_title.replace(title) for eq_copy in eq1_copy, eq2_copy: @@ -1017,7 +1017,7 @@ class LinearDependentEquations(Scene): new_low_words1 = TextMobject(["For", "all", "values of a"]) new_low_words2 = TextMobject(["For", "all", "values of a and b"]) for low_words in new_low_words1, new_low_words2: - low_words.split()[1].highlight(GREEN) + low_words.split()[1].set_color(GREEN) low_words.scale(2) low_words.to_edge(DOWN) @@ -1059,12 +1059,12 @@ class AlternateDefOfLinearlyDependent(Scene): ]) for title in title1, title2: v, w, _and, u, are, ld, _if = title.split() - v.highlight(MAROON_C) - w.highlight(BLUE) - u.highlight(RED_C) + v.set_color(MAROON_C) + w.set_color(BLUE) + u.set_color(RED_C) title.to_edge(UP) - title1.split()[-2].highlight(YELLOW) - title2.split()[-2].highlight(GREEN) + title1.split()[-2].set_color(YELLOW) + title2.split()[-2].set_color(GREEN) subtitle = TextMobject("the only solution to") subtitle.next_to(title2, DOWN, aligned_edge = LEFT) @@ -1190,7 +1190,7 @@ class AlternateDefOfLinearlyDependent(Scene): "+(-1)", "\\vec{\\textbf{u}}", ]) - equation5.split()[-2].highlight(YELLOW) + equation5.split()[-2].set_color(YELLOW) equation6 = TexMobject([ "\\vec{\\textbf{0}}", "=", @@ -1204,9 +1204,9 @@ class AlternateDefOfLinearlyDependent(Scene): ]) result = [equation1, equation2, equation3, equation4, equation5, equation6] for eq in result: - eq.split()[3].highlight(MAROON_C) - eq.split()[6].highlight(BLUE) - eq.split()[-1].highlight(RED_C) + eq.split()[3].set_color(MAROON_C) + eq.split()[6].set_color(BLUE) + eq.split()[-1].set_color(RED_C) eq.scale(1.5) eq.shift(UP) return result @@ -1250,9 +1250,9 @@ class TechnicalDefinitionOfBasis(Scene): "the full space", ]) t, b, oavsiaso, li, vt, s, tfs = definition.split() - b.highlight(BLUE) - li.highlight(GREEN) - s.highlight(YELLOW) + b.set_color(BLUE) + li.set_color(GREEN) + s.set_color(YELLOW) definition.scale_to_fit_width(FRAME_WIDTH-1) self.add(title) diff --git a/old_projects/eola/chapter3.py b/old_projects/eola/chapter3.py index b17fe7bb..9afc6032 100644 --- a/old_projects/eola/chapter3.py +++ b/old_projects/eola/chapter3.py @@ -35,10 +35,10 @@ class OpeningQuote(Scene): ]) words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) - words.split()[1].highlight(GREEN) - words.split()[3].highlight(BLUE) + words.split()[1].set_color(GREEN) + words.split()[3].set_color(BLUE) author = TextMobject("-Morpheus") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) comment = TextMobject(""" (Surprisingly apt words on the importance @@ -57,7 +57,7 @@ class Introduction(TeacherStudentsScene): def construct(self): title = TextMobject(["Matrices as", "Linear transformations"]) title.to_edge(UP) - title.highlight(YELLOW) + title.set_color(YELLOW) linear_transformations = title.split()[1] self.add(*title.split()) self.setup() @@ -105,7 +105,7 @@ class DescribeTransformation(Scene): linear, transformation = title.split() brace = Brace(transformation, DOWN) function = TextMobject("function").next_to(brace, DOWN) - function.highlight(YELLOW) + function.set_color(YELLOW) self.play(Write(title)) self.wait() @@ -136,10 +136,10 @@ class DescribeTransformation(Scene): output_vect.next_to(L_of_v, RIGHT, buff = 1) vector_input_words = TextMobject("Vector input") - vector_input_words.highlight(MAROON_C) + vector_input_words.set_color(MAROON_C) vector_input_words.next_to(input_vect, DOWN) vector_output_words = TextMobject("Vector output") - vector_output_words.highlight(BLUE) + vector_output_words.set_color(BLUE) vector_output_words.next_to(output_vect, DOWN) self.play(Write(f_of_x, run_time = 1)) @@ -186,8 +186,8 @@ class WhyConfuseWithTerminology(TeacherStudentsScene): "suggests \\\\ that you think using", "movement", ]) - statement.split()[1].highlight(BLUE) - statement.split()[-1].highlight(YELLOW) + statement.split()[1].set_color(BLUE) + statement.split()[-1].set_color(YELLOW) self.teacher_says(statement, width = 10) self.play(*[ ApplyMethod(student.change_mode, "happy") @@ -227,7 +227,7 @@ class ThinkinfOfFunctionsAsGraphs(VectorScene): ) self.clear() words = TextMobject(["Instead think about", "\\emph{movement}"]) - words.split()[-1].highlight(YELLOW) + words.split()[-1].set_color(YELLOW) self.play(Write(words)) self.wait() @@ -244,7 +244,7 @@ class TransformJustOneVector(VectorScene): for v, word in (v1, "Input"), (v2, "Output"): v.label = TextMobject("%s vector"%word) v.label.next_to(v.get_end(), UP) - v.label.highlight(v.get_color()) + v.label.set_color(v.get_color()) self.play(ShowCreation(v)) self.play(Write(v.label)) self.wait() @@ -391,10 +391,10 @@ class LookToWordLinear(Scene): linear_brace = Brace(linear, DOWN) transformation_brace = Brace(transformation, DOWN) function = TextMobject("function") - function.highlight(YELLOW) + function.set_color(YELLOW) function.next_to(transformation_brace, DOWN) new_sub_word = TextMobject("What does this mean?") - new_sub_word.highlight(BLUE) + new_sub_word.set_color(BLUE) new_sub_word.next_to(linear_brace, DOWN) self.add( @@ -453,7 +453,7 @@ class ToThePedants(Scene): I've said is equivalent to the formal definition (which I'll get to later in the series). """]) - words.split()[0].highlight(RED) + words.split()[0].set_color(RED) words.to_edge(UP) self.add(words) self.wait() @@ -480,7 +480,7 @@ class SimpleNonlinearTransformationScene(LinearTransformationScene): self.apply_nonlinear_transformation(self.func) words = TextMobject(self.words) words.to_corner(UP+RIGHT) - words.highlight(RED) + words.set_color(RED) words.add_background_rectangle() self.play(Write(words)) self.wait() @@ -523,7 +523,7 @@ class SneakyNonlinearTransformationExplained(SneakyNonlinearTransformation): ) diag.insert_n_anchor_points(20) diag.change_anchor_mode("smooth") - diag.highlight(YELLOW) + diag.set_color(YELLOW) self.play(ShowCreation(diag)) self.add_transformable_mobject(diag) @@ -543,8 +543,8 @@ class GridLinesRemainParallel(SimpleLinearTransformationScene): "evenly spaced", ]) glr, p, a, es = text.split() - p.highlight(YELLOW) - es.highlight(GREEN) + p.set_color(YELLOW) + es.set_color(GREEN) text.add_background_rectangle() text.shift(-text.get_bottom()) self.play(Write(text)) @@ -577,7 +577,7 @@ class YetAnotherLinearTransformation(SimpleLinearTransformationScene): ) words.add_background_rectangle() words.to_edge(UP) - words.highlight(GREEN) + words.set_color(GREEN) formula = TexMobject([ matrix_to_tex_string(["x_\\text{in}", "y_\\text{in}"]), "\\rightarrow ???? \\rightarrow", @@ -713,9 +713,9 @@ class TrackBasisVectorsExample(LinearTransformationScene): "\\hat{\\jmath}", ]) v, equals_neg_1, i_hat, plus_2, j_hat = v_def.split() - v.highlight(YELLOW) - i_hat.highlight(X_COLOR) - j_hat.highlight(Y_COLOR) + v.set_color(YELLOW) + i_hat.set_color(X_COLOR) + j_hat.set_color(Y_COLOR) v_def.add_background_rectangle() v_def.to_corner(UP + LEFT) self.v_def = v_def @@ -730,9 +730,9 @@ class TrackBasisVectorsExample(LinearTransformationScene): "(\\text{Transformed } \\hat{\\jmath})", ]) v, equals_neg_1, i_hat, plus_2, j_hat = rule.split() - v.highlight(YELLOW) - i_hat.highlight(X_COLOR) - j_hat.highlight(Y_COLOR) + v.set_color(YELLOW) + i_hat.set_color(X_COLOR) + j_hat.set_color(Y_COLOR) rule.scale(0.85) rule.next_to(self.v_def, DOWN, buff = 0.2) rule.to_edge(LEFT) @@ -746,8 +746,8 @@ class TrackBasisVectorsExample(LinearTransformationScene): def show_basis_vector_coords(self): i_coords = matrix_to_mobject(self.transposed_matrix[0]) j_coords = matrix_to_mobject(self.transposed_matrix[1]) - i_coords.highlight(X_COLOR) - j_coords.highlight(Y_COLOR) + i_coords.set_color(X_COLOR) + j_coords.set_color(Y_COLOR) for coords in i_coords, j_coords: coords.add_background_rectangle() coords.scale(0.7) @@ -761,8 +761,8 @@ class TrackBasisVectorsExample(LinearTransformationScene): matrix_to_tex_string(self.transposed_matrix[1]), ]) equals_neg_1, i_hat, plus_2, j_hat = calculation.split() - i_hat.highlight(X_COLOR) - j_hat.highlight(Y_COLOR) + i_hat.set_color(X_COLOR) + j_hat.set_color(Y_COLOR) calculation.scale(0.8) calculation.next_to(self.linear_map_rule, DOWN) calculation.to_edge(LEFT) @@ -832,14 +832,14 @@ class DeduceResultWithGeneralCoordinates(Scene): j_coords.next_to(j_hat_to, RIGHT, buff = 0.1) i_group = VMobject(i_hat_to, i_coords) j_group = VMobject(j_hat_to, j_coords) - i_group.highlight(X_COLOR) - j_group.highlight(Y_COLOR) + i_group.set_color(X_COLOR) + j_group.set_color(Y_COLOR) i_group.next_to(ORIGIN, LEFT, buff = 1).to_edge(UP) j_group.next_to(ORIGIN, RIGHT, buff = 1).to_edge(UP) vect = Matrix(["x", "y"]) x, y = vect.get_mob_matrix().flatten() - VMobject(x, y).highlight(YELLOW) + VMobject(x, y).set_color(YELLOW) rto = TexMobject("\\rightarrow") equals = TexMobject("=") plus = TexMobject("+") @@ -847,13 +847,13 @@ class DeduceResultWithGeneralCoordinates(Scene): row2 = TexMobject("-2x + 0y") VMobject( row1.split()[0], row2.split()[0], row2.split()[1] - ).highlight(X_COLOR) + ).set_color(X_COLOR) VMobject( row1.split()[1], row1.split()[4], row2.split()[2], row2.split()[5] - ).highlight(YELLOW) + ).set_color(YELLOW) VMobject( row1.split()[3], row2.split()[4] - ).highlight(Y_COLOR) + ).set_color(Y_COLOR) result = Matrix([row1, row2]) result.show() vect_group = VMobject( @@ -893,8 +893,8 @@ class MatrixVectorMultiplication(LinearTransformationScene): new_j_coords.move_to(j_coords) i_coords = new_i_coords j_coords = new_j_coords - i_coords.highlight(X_COLOR) - j_coords.highlight(Y_COLOR) + i_coords.set_color(X_COLOR) + j_coords.set_color(Y_COLOR) i_brackets = i_coords.get_brackets() j_brackets = j_coords.get_brackets() for coords in i_coords, j_coords: @@ -951,8 +951,8 @@ class MatrixVectorMultiplication(LinearTransformationScene): i_circle, j_circle = col_circles i_message = TextMobject("Where $\\hat{\\imath}$ lands") j_message = TextMobject("Where $\\hat{\\jmath}$ lands") - i_message.highlight(X_COLOR) - j_message.highlight(Y_COLOR) + i_message.set_color(X_COLOR) + j_message.set_color(Y_COLOR) i_message.next_to(i_circle, DOWN, buff = 2, aligned_edge = RIGHT) j_message.next_to(j_circle, DOWN, buff = 2, aligned_edge = LEFT) i_arrow = Arrow(i_message, i_circle) @@ -1036,10 +1036,10 @@ class MatrixVectorMultiplication(LinearTransformationScene): row.arrange_submobjects(RIGHT, buff = 0.1) final_sum = Matrix([row1, row2]) row1, row2 = final_sum.get_mob_matrix().flatten() - row1.split()[0].highlight(X_COLOR) - row2.split()[0].highlight(X_COLOR) - row1.split()[3].highlight(Y_COLOR) - row2.split()[3].highlight(Y_COLOR) + row1.split()[0].set_color(X_COLOR) + row2.split()[0].set_color(X_COLOR) + row1.split()[3].set_color(Y_COLOR) + row2.split()[3].set_color(Y_COLOR) equals = TexMobject("=") equals.next_to(formula, RIGHT) final_sum.next_to(equals, RIGHT) @@ -1061,7 +1061,7 @@ class MatrixVectorMultiplication(LinearTransformationScene): brace = Brace(formula, DOWN) brace_words = TextMobject("Where all the intuition is") brace_words.next_to(brace, DOWN) - brace_words.highlight(YELLOW) + brace_words.set_color(YELLOW) self.play( Transform( @@ -1101,16 +1101,16 @@ class ColumnsToBasisVectors(LinearTransformationScene): matrix_mob.to_corner(UP+LEFT) matrix_mob.add_background_to_entries() col1 = VMobject(*matrix_mob.get_mob_matrix()[:,0]) - col1.highlight(X_COLOR) + col1.set_color(X_COLOR) col2 = VMobject(*matrix_mob.get_mob_matrix()[:,1]) - col2.highlight(Y_COLOR) + col2.set_color(Y_COLOR) matrix_brackets = matrix_mob.get_brackets() matrix_background = BackgroundRectangle(matrix_mob) self.add_foreground_mobject(matrix_background, matrix_mob) if vector_coords is not None: vector = Matrix(vector_coords) - VMobject(*vector.get_mob_matrix().flatten()).highlight(YELLOW) + VMobject(*vector.get_mob_matrix().flatten()).set_color(YELLOW) vector.scale_to_fit_height(matrix_mob.get_height()) vector.next_to(matrix_mob, RIGHT) vector_background = BackgroundRectangle(vector) @@ -1118,8 +1118,8 @@ class ColumnsToBasisVectors(LinearTransformationScene): new_i = Vector(matrix[:,0]) new_j = Vector(matrix[:,1]) - i_label = vector_coordinate_label(new_i).highlight(X_COLOR) - j_label = vector_coordinate_label(new_j).highlight(Y_COLOR) + i_label = vector_coordinate_label(new_i).set_color(X_COLOR) + j_label = vector_coordinate_label(new_j).set_color(Y_COLOR) i_coords = VMobject(*i_label.get_mob_matrix().flatten()) j_coords = VMobject(*j_label.get_mob_matrix().flatten()) i_brackets = i_label.get_brackets() @@ -1214,8 +1214,8 @@ class Describe90DegreeRotation(LinearTransformationScene): matrix_background = BackgroundRectangle(matrix) col1 = VMobject(*matrix.get_mob_matrix()[:,0]) col2 = VMobject(*matrix.get_mob_matrix()[:,1]) - col1.highlight(X_COLOR) - col2.highlight(Y_COLOR) + col1.set_color(X_COLOR) + col2.set_color(Y_COLOR) self.add_foreground_mobject(matrix_background, matrix.get_brackets()) self.wait() @@ -1226,7 +1226,7 @@ class Describe90DegreeRotation(LinearTransformationScene): for vect, color, col in [(self.i_hat, X_COLOR, col1), (self.j_hat, Y_COLOR, col2)]: label = vector_coordinate_label(vect) - label.highlight(color) + label.set_color(color) background = BackgroundRectangle(label) coords = VMobject(*label.get_mob_matrix().flatten()) brackets = label.get_brackets() @@ -1245,7 +1245,7 @@ class Describe90DegreeRotation(LinearTransformationScene): def show_vector(self, matrix): vector = Matrix(["x", "y"]) - VMobject(*vector.get_mob_matrix().flatten()).highlight(YELLOW) + VMobject(*vector.get_mob_matrix().flatten()).set_color(YELLOW) vector.scale_to_fit_height(matrix.get_height()) vector.next_to(matrix, RIGHT) v_background = BackgroundRectangle(vector) @@ -1285,7 +1285,7 @@ class LinearlyDependentColumns(ColumnsToBasisVectors): subtitle.next_to(title, DOWN) title.add(subtitle) title.shift(UP).to_edge(LEFT) - title.highlight(YELLOW) + title.set_color(YELLOW) self.add_foreground_mobject(title) self.move_matrix_columns([[2, 1], [-2, -1]]) @@ -1359,7 +1359,7 @@ class TransformationsAreFunctions(Scene): "function" ]) title_start, function = title.split() - function.highlight(YELLOW) + function.set_color(YELLOW) title.to_edge(UP) equation = TexMobject([ @@ -1370,18 +1370,18 @@ class TransformationsAreFunctions(Scene): "\\vec{\\textbf{w}}", ]) L, lp, _input, equals, _output = equation.split() - L.highlight(YELLOW) - _input.highlight(MAROON_C) - _output.highlight(BLUE) + L.set_color(YELLOW) + _input.set_color(MAROON_C) + _output.set_color(BLUE) equation.scale(2) equation.next_to(title, DOWN, buff = 1) starting_vector = TextMobject("Starting vector") starting_vector.shift(DOWN+3*LEFT) - starting_vector.highlight(MAROON_C) + starting_vector.set_color(MAROON_C) ending_vector = TextMobject("The vector where it lands") ending_vector.shift(DOWN).to_edge(RIGHT) - ending_vector.highlight(BLUE) + ending_vector.set_color(BLUE) func_arrow = Arrow(function.get_bottom(), L.get_top(), color = YELLOW) start_arrow = Arrow(starting_vector.get_top(), _input.get_bottom(), color = MAROON_C) @@ -1479,18 +1479,18 @@ class TryingToVisualizeFourDimensions(Scene): \\right] """) formula.next_to(randy, RIGHT) - formula.split()[3].highlight(X_COLOR) - formula.split()[4].highlight(Y_COLOR) - VMobject(*formula.split()[9:9+4]).highlight(MAROON_C) - VMobject(*formula.split()[13:13+4]).highlight(BLUE) + formula.split()[3].set_color(X_COLOR) + formula.split()[4].set_color(Y_COLOR) + VMobject(*formula.split()[9:9+4]).set_color(MAROON_C) + VMobject(*formula.split()[13:13+4]).set_color(BLUE) thought = TextMobject(""" Do I imagine plotting $(x, y, 2x+y, x+2y)$??? """) - thought.split()[-17].highlight(X_COLOR) - thought.split()[-15].highlight(Y_COLOR) - VMobject(*thought.split()[-13:-13+4]).highlight(MAROON_C) - VMobject(*thought.split()[-8:-8+4]).highlight(BLUE) + thought.split()[-17].set_color(X_COLOR) + thought.split()[-15].set_color(Y_COLOR) + VMobject(*thought.split()[-13:-13+4]).set_color(MAROON_C) + VMobject(*thought.split()[-8:-8+4]).set_color(BLUE) bubble.position_mobject_inside(thought) thought.shift(0.2*UP) @@ -1563,7 +1563,7 @@ class AdditivityProperty(LinearTransformationScene): linear transformations """) title.to_edge(UP) - title.highlight(YELLOW) + title.set_color(YELLOW) title.add_background_rectangle() self.play(Write(title)) added_anims.append(Animation(title)) @@ -1670,7 +1670,7 @@ class MoveAroundAllVectors(LinearTransformationScene): if v is not vector ]) self.wait() - self.add(vector.copy().highlight(DARK_GREY)) + self.add(vector.copy().set_color(DARK_GREY)) else: for vector in vectors.split(): self.add_vector(vector, animate = False) diff --git a/old_projects/eola/chapter4.py b/old_projects/eola/chapter4.py index c4289a4f..99645475 100644 --- a/old_projects/eola/chapter4.py +++ b/old_projects/eola/chapter4.py @@ -33,10 +33,10 @@ class OpeningQuote(Scene): ]) words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) - words.split()[1].highlight(GREEN) - words.split()[3].highlight(BLUE) + words.split()[1].set_color(GREEN) + words.split()[3].set_color(BLUE) author = TextMobject("-Emil Artin") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -129,12 +129,12 @@ class FollowLinearCombination(LinearTransformationScene): vect = self.add_vector(vect_coords) vect_array = Matrix(["x", "y"], add_background_rectangles = True) v_equals = TexMobject(["\\vec{\\textbf{v}}", "="]) - v_equals.split()[0].highlight(YELLOW) + v_equals.split()[0].set_color(YELLOW) v_equals.next_to(vect_array, LEFT) vect_array.add(v_equals) vect_array.to_edge(UP, buff = 0.2) background_rect = BackgroundRectangle(vect_array) - vect_array.get_entries().highlight(YELLOW) + vect_array.get_entries().set_color(YELLOW) self.play(ShowCreation(background_rect), Write(vect_array)) self.add_foreground_mobject(background_rect, vect_array) @@ -194,9 +194,9 @@ class FollowLinearCombination(LinearTransformationScene): def record_basis_coordinates(self, vect_array, vect): i_label = vector_coordinate_label(self.i_hat) - i_label.highlight(X_COLOR) + i_label.set_color(X_COLOR) j_label = vector_coordinate_label(self.j_hat) - j_label.highlight(Y_COLOR) + j_label.set_color(Y_COLOR) for mob in i_label, j_label: mob.scale_in_place(0.8) background = BackgroundRectangle(mob) @@ -258,8 +258,8 @@ class RotationThenShear(LinearTransformationScene): self.setup() rot_words = TextMobject("$90^\\circ$ rotation counterclockwise") shear_words = TextMobject("followed by a shear") - rot_words.highlight(YELLOW) - shear_words.highlight(PINK) + rot_words.set_color(YELLOW) + shear_words.set_color(PINK) VMobject(rot_words, shear_words).arrange_submobjects(DOWN).to_edge(UP) for words in rot_words, shear_words: words.add_background_rectangle() @@ -289,8 +289,8 @@ class IntroduceIdeaOfComposition(RotationThenShear): "shear" ]) words.split()[0].submobject_gradient_highlight(YELLOW, PINK, use_color_range_to = False) - words.split()[2].highlight(YELLOW) - words.split()[4].highlight(PINK) + words.split()[2].set_color(YELLOW) + words.split()[4].set_color(PINK) words.add_background_rectangle() words.to_edge(UP) @@ -314,15 +314,15 @@ class IntroduceIdeaOfComposition(RotationThenShear): "land:" ]) rw, i_hat, a, j_hat, l = words.split() - i_hat.highlight(X_COLOR) - j_hat.highlight(Y_COLOR) + i_hat.set_color(X_COLOR) + j_hat.set_color(Y_COLOR) words.add_background_rectangle() words.next_to(last_words, DOWN) i_coords = vector_coordinate_label(self.i_hat) j_coords = vector_coordinate_label(self.j_hat) - i_coords.highlight(X_COLOR) - j_coords.highlight(Y_COLOR) + i_coords.set_color(X_COLOR) + j_coords.set_color(Y_COLOR) i_background = BackgroundRectangle(i_coords) j_background = BackgroundRectangle(j_coords) @@ -397,12 +397,12 @@ class PumpVectorThroughRotationThenShear(RotationThenShear): class ExplainWhyItsMatrixMultiplication(Scene): def construct(self): vect = Matrix(["x", "y"]) - vect.get_entries().highlight(YELLOW) + vect.get_entries().set_color(YELLOW) rot_matrix = Matrix([[0, -1], [1, 0]]) - rot_matrix.highlight(TEAL) + rot_matrix.set_color(TEAL) shear_matrix = Matrix([[1, 1], [0, 1]]) - shear_matrix.highlight(PINK) + shear_matrix.set_color(PINK) l_paren, r_paren = map(TexMobject, ["\\Big(", "\\Big)"]) for p in l_paren, r_paren: p.scale_to_fit_height(1.4*vect.get_height()) @@ -415,7 +415,7 @@ class ExplainWhyItsMatrixMultiplication(Scene): equals = TexMobject("=").next_to(long_way, RIGHT) comp_matrix = Matrix([[1, -1], [1, 0]]) - comp_matrix.highlight_columns(X_COLOR, Y_COLOR) + comp_matrix.set_color_columns(X_COLOR, Y_COLOR) vect_copy = vect.copy() short_way = VMobject(comp_matrix, vect_copy) short_way.arrange_submobjects(buff = 0.1) @@ -429,8 +429,8 @@ class ExplainWhyItsMatrixMultiplication(Scene): for matrix, word in pairs: brace = Brace(matrix) text = TextMobject(word).next_to(brace, DOWN) - brace.highlight(matrix.get_color()) - text.highlight(matrix.get_color()) + brace.set_color(matrix.get_color()) + text.set_color(matrix.get_color()) matrix.add(brace, text) comp_matrix.split()[-1].submobject_gradient_highlight(TEAL, PINK) @@ -522,8 +522,8 @@ class MoreComplicatedExampleVisually(LinearTransformationScene): m1_mob = Matrix(np.array(self.t_matrix1).transpose()) m2_mob = Matrix(np.array(self.t_matrix2).transpose()) comp_matrix = Matrix([["?", "?"], ["?", "?"]]) - m1_mob.highlight(YELLOW) - m2_mob.highlight(PINK) + m1_mob.set_color(YELLOW) + m2_mob.set_color(PINK) comp_matrix.get_entries().submobject_gradient_highlight(YELLOW, PINK) equals = TexMobject("=") @@ -565,7 +565,7 @@ class MoreComplicatedExampleNumerically(MoreComplicatedExampleVisually): circle = Circle() circle.stretch_to_fit_height(m1_mob.get_height()) circle.stretch_to_fit_width(m1_mob.get_width()/2.5) - circle.highlight(col.target_color) + circle.set_color(col.target_color) circle.move_to(col) col.circle = circle @@ -579,25 +579,25 @@ class MoreComplicatedExampleNumerically(MoreComplicatedExampleVisually): question = TextMobject( "Where does $\\hat{\\%smath}$ go?"%char ) - question.split()[-4].highlight(color) - question.split()[-5].highlight(color) + question.split()[-4].set_color(color) + question.split()[-5].set_color(color) question.scale(1.2) question.shift(DOWN) first = TextMobject("First here") - first.highlight(color) + first.set_color(color) first.shift(DOWN+LEFT) first_arrow = Arrow( first, col.circle.get_bottom(), color = color ) second = TextMobject("Then to whatever this is") - second.highlight(color) + second.set_color(color) second.to_edge(RIGHT).shift(DOWN) m2_copy = m2_mob.copy() m2_target = m2_mob.copy() m2_target.next_to(m2_mob, DOWN, buff = 1) col_vect = Matrix(col.copy().split()) - col_vect.highlight(color) + col_vect.set_color(color) col_vect.next_to(m2_target, RIGHT, buff = 0.1) second_arrow = Arrow(second, col_vect, color = color) @@ -625,7 +625,7 @@ class MoreComplicatedExampleNumerically(MoreComplicatedExampleVisually): Transform(question, first), ShowCreation(first_arrow), ShowCreation(col.circle), - ApplyMethod(col.highlight, col.target_color) + ApplyMethod(col.set_color, col.target_color) ) self.wait() self.play( @@ -643,7 +643,7 @@ class MoreComplicatedExampleNumerically(MoreComplicatedExampleVisually): self.wait() product_entries = product.get_entries() self.play( - ApplyMethod(comp_col.highlight, BLACK), + ApplyMethod(comp_col.set_color, BLACK), ApplyMethod(product_entries.move_to, comp_col) ) self.wait() @@ -664,14 +664,14 @@ class GeneralMultiplication(MoreComplicatedExampleNumerically): "ae+bg", "af+bh", "ce+dg", "cf+dh" ]) for mob in entries: - mob.split()[0].highlight(PINK) - mob.split()[3].highlight(PINK) + mob.split()[0].set_color(PINK) + mob.split()[3].set_color(PINK) for mob in entries[0], entries[2]: - mob.split()[1].highlight(X_COLOR) - mob.split()[4].highlight(X_COLOR) + mob.split()[1].set_color(X_COLOR) + mob.split()[4].set_color(X_COLOR) for mob in entries[1], entries[3]: - mob.split()[1].highlight(Y_COLOR) - mob.split()[4].highlight(Y_COLOR) + mob.split()[1].set_color(Y_COLOR) + mob.split()[4].set_color(Y_COLOR) return np.array(entries).reshape((2, 2)) def get_matrices(self): @@ -680,11 +680,11 @@ class GeneralMultiplication(MoreComplicatedExampleNumerically): m1_entries = m1.split()[1].get_entries() m2_entries = m2.split()[1].get_entries() m2_entries_target = VMobject(*[ - TexMobject(char).move_to(entry).highlight(entry.get_color()) + TexMobject(char).move_to(entry).set_color(entry.get_color()) for entry, char in zip(m2_entries.split(), "abcd") ]) m1_entries_target = VMobject(*[ - TexMobject(char).move_to(entry).highlight(entry.get_color()) + TexMobject(char).move_to(entry).set_color(entry.get_color()) for entry, char in zip(m1_entries.split(), "efgh") ]) @@ -702,7 +702,7 @@ class GeneralMultiplication(MoreComplicatedExampleNumerically): new_comp = Matrix(self.get_result()) new_comp.next_to(comp.split()[1].submobjects[-1], RIGHT) - new_comp.get_entries().highlight(BLACK) + new_comp.get_entries().set_color(BLACK) self.play( Transform(comp.split()[1].get_brackets(), new_comp.get_brackets()), *[ @@ -762,10 +762,10 @@ class AskAboutCommutativity(Scene): l_m1, l_m2, eq, r_m2, r_m1 = TexMobject([ "M_1", "M_2", "=", "M_2", "M_1" ]).scale(1.5).split() - VMobject(l_m1, r_m1).highlight(YELLOW) - VMobject(l_m2, r_m2).highlight(PINK) + VMobject(l_m1, r_m1).set_color(YELLOW) + VMobject(l_m2, r_m2).set_color(PINK) q_marks = TextMobject("???") - q_marks.highlight(TEAL) + q_marks.set_color(TEAL) q_marks.next_to(eq, UP) neq = TexMobject("\\neq") neq.move_to(eq) @@ -796,7 +796,7 @@ class ShowShear(LinearTransformationScene): self.setup() title = TextMobject(self.title) title.scale(1.5).to_edge(UP) - title.highlight(self.title_color) + title.set_color(self.title_color) title.add_background_rectangle() self.add_foreground_mobject(title) @@ -828,9 +828,9 @@ class FirstShearThenRotation(LinearTransformationScene): title = TextMobject(title_parts) for i, part in enumerate(title_parts): if part == "rotation": - title.split()[i].highlight(YELLOW) + title.split()[i].set_color(YELLOW) elif part == "shear": - title.split()[i].highlight(PINK) + title.split()[i].set_color(PINK) title.scale(1.5) self.add_title(title) @@ -1009,8 +1009,8 @@ class ThreeSuccessiveTransformations(LinearTransformationScene): for t_matrix, sym in zip(self.t_matrices, [c, b, a]): self.play( brace.next_to, sym, DOWN, - sym.highlight, YELLOW, - last.highlight, WHITE + sym.set_color, YELLOW, + last.set_color, WHITE ) self.apply_transposed_matrix(t_matrix, run_time = 1) last = sym @@ -1031,9 +1031,9 @@ class ExplanationTrumpsProof(Scene): greater = TexMobject(">") greater.shift(RIGHT) explanation = TextMobject("Good explanation") - explanation.highlight(BLUE) + explanation.set_color(BLUE) proof = TextMobject("Symbolic proof") - proof.highlight(LIGHT_BROWN) + proof.set_color(LIGHT_BROWN) explanation.next_to(greater, LEFT) proof.next_to(greater, RIGHT) explanation.get_center = lambda : explanation.get_right() diff --git a/old_projects/eola/chapter5.py b/old_projects/eola/chapter5.py index a2a8c2fa..872a0d0c 100644 --- a/old_projects/eola/chapter5.py +++ b/old_projects/eola/chapter5.py @@ -90,10 +90,10 @@ class OpeningQuote(Scene): ], arg_separator = "") # words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) - words.split()[1].highlight(BLUE) - words.split()[3].highlight(GREEN) + words.split()[1].set_color(BLUE) + words.split()[3].set_color(GREEN) author = TextMobject("-Richard Hamming") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -151,7 +151,7 @@ class AskAboutStretching(LinearTransformationScene): """) words.add_background_rectangle() words.to_corner(UP+RIGHT) - words.highlight(YELLOW) + words.set_color(YELLOW) self.apply_transposed_matrix( [[2, 1], [-1, 3]], added_anims = [Write(words)] @@ -163,15 +163,15 @@ class AskAboutStretchingSpecifically(LinearTransformationScene): self.setup() self.add_title(["How much are", "areas", "scaled?"]) hma, areas, scaled = self.title.split()[1].split() - areas.highlight(YELLOW) + areas.set_color(YELLOW) blob = Blob().shift(UP+RIGHT) label = TextMobject("Area") - label.highlight(YELLOW) + label.set_color(YELLOW) label = VMobject(VectorizedPoint(label.get_left()), label) label.move_to(blob) target_label = TexMobject(["c \\cdot", "\\text{Area}"]) - target_label.split()[1].highlight(YELLOW) + target_label.split()[1].set_color(YELLOW) self.add_transformable_mobject(blob) self.add_moving_mobject(label, target_label) @@ -196,7 +196,7 @@ class DiagonalExample(LinearTransformationScene): def construct(self): self.setup() matrix = Matrix(np.array(self.transposed_matrix).transpose()) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(ORIGIN, LEFT).to_edge(UP) matrix_background = BackgroundRectangle(matrix) self.play(ShowCreation(matrix_background), Write(matrix)) @@ -270,7 +270,7 @@ class ThisSquareTellsEverything(LinearTransformationScene): everything you need. """) words.to_corner(UP+RIGHT) - words.highlight(YELLOW) + words.set_color(YELLOW) words.add_background_rectangle() arrow = Arrow( words.get_bottom(), self.square.get_right(), @@ -372,7 +372,7 @@ class NameDeterminant(LinearTransformationScene): ["The", "``determinant''", "of a transformation"], scale_factor = 1 ) - self.title.split()[1].split()[1].highlight(YELLOW) + self.title.split()[1].split()[1].set_color(YELLOW) matrix_background, matrix, det_text = self.get_matrix() self.add_foreground_mobject(matrix_background, matrix) @@ -408,7 +408,7 @@ class NameDeterminant(LinearTransformationScene): def get_matrix(self): matrix = Matrix(np.array(self.t_matrix).transpose()) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(self.title, DOWN, buff = 0.5) matrix.shift(2*LEFT) matrix_background = BackgroundRectangle(matrix) @@ -488,13 +488,13 @@ class NegativeDeterminant(Scene): def construct(self): numerical_matrix = [[1, 2], [3, 4]] matrix = Matrix(numerical_matrix) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) det_text = get_det_text(matrix, np.linalg.det(numerical_matrix)) words = TextMobject(""" How can you scale area by a negative number? """) - words.highlight(YELLOW) + words.set_color(YELLOW) words.to_corner(UP+RIGHT) det_num = det_text.split()[-1] arrow = Arrow(words.get_bottom(), det_num) @@ -506,7 +506,7 @@ class NegativeDeterminant(Scene): Write(words, run_time = 2), ShowCreation(arrow) ) - self.play(det_num.highlight, YELLOW) + self.play(det_num.set_color, YELLOW) self.wait() class FlipSpaceOver(Scene): @@ -598,9 +598,9 @@ class IHatJHatOrientation(NegativeDeterminantTransformation): "of", "$\\hat{\\imath}$", ]) - words1.split()[0].highlight(Y_COLOR) - words1.split()[2].highlight(YELLOW) - words1.split()[-1].highlight(X_COLOR) + words1.split()[0].set_color(Y_COLOR) + words1.split()[2].set_color(YELLOW) + words1.split()[-1].set_color(X_COLOR) words1.add_background_rectangle() words1.next_to(arc, UP+RIGHT) @@ -611,9 +611,9 @@ class IHatJHatOrientation(NegativeDeterminantTransformation): "of", "$L(\\hat{\\imath})$", ]) - words2.split()[0].highlight(Y_COLOR) - words2.split()[2].highlight(YELLOW) - words2.split()[-1].highlight(X_COLOR) + words2.split()[0].set_color(Y_COLOR) + words2.split()[2].set_color(YELLOW) + words2.split()[-1].set_color(X_COLOR) words2.add_background_rectangle() @@ -644,7 +644,7 @@ class WriteNegativeDeterminant(NegativeDeterminantTransformation): matrix = Matrix(np.array(self.t_matrix).transpose()) matrix.next_to(ORIGIN, LEFT) matrix.to_edge(UP) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) det_text = get_det_text( matrix, determinant = np.linalg.det(self.t_matrix) @@ -718,7 +718,7 @@ class DeterminantGraphForRotatingIHat(Scene): axes = VMobject(det_axis, t_axis) graph = FunctionGraph(np.cos, x_min = 0, x_max = np.pi) graph.next_to(det_axis, RIGHT, buff = 0) - graph.highlight(YELLOW) + graph.set_color(YELLOW) det_word = TextMobject("Det") det_word.next_to(det_axis, RIGHT, aligned_edge = UP) time_word = TextMobject("time") @@ -762,7 +762,7 @@ class DeterminantIsVolumeOfParallelepiped(Scene): def construct(self): matrix = Matrix([[1, 0, 0.5], [0.5, 1, 0], [1, 0, 1]]) matrix.shift(3*LEFT) - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) det_text = get_det_text(matrix) eq = TexMobject("=") eq.next_to(det_text, RIGHT) @@ -791,14 +791,14 @@ class WriteZeroDeterminant(Scene): def construct(self): matrix = Matrix([[1, 0, 1], [0.5, 1, 1.5], [1, 0, 1]]) matrix.shift(2*LEFT) - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) det_text = get_det_text(matrix, 0) brace = Brace(matrix, DOWN) words = TextMobject(""" Columns must be linearly dependent """) - words.highlight(YELLOW) + words.set_color(YELLOW) words.next_to(brace, DOWN) self.play(Write(matrix)) @@ -858,8 +858,8 @@ class RightHandRule(Scene): ) self.wait() for vect, label, color in zip(vects, labels, self.colors): - vect.highlight(color) - label.highlight(color) + vect.set_color(color) + label.set_color(color) vect.set_stroke(width = 8) self.play(ShowCreation(vect)) self.play(Write(label)) @@ -884,7 +884,7 @@ class TwoDDeterminantFormula(Scene): def construct(self): eq = TextMobject("=") matrix = Matrix([["a", "b"], ["c", "d"]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) ma, mb, mc, md = matrix.get_entries().split() ma.shift(0.1*DOWN) mc.shift(0.7*mc.get_height()*DOWN) @@ -895,8 +895,8 @@ class TwoDDeterminantFormula(Scene): formula.shift(0.1*UP) a, d, minus, b, c = formula.split() - VMobject(a, c).highlight(X_COLOR) - VMobject(b, d).highlight(Y_COLOR) + VMobject(a, c).set_color(X_COLOR) + VMobject(b, d).set_color(Y_COLOR) for mob in mb, mc, b, c: if mob is c: @@ -904,7 +904,7 @@ class TwoDDeterminantFormula(Scene): else: mob.zero = TexMobject("0") mob.zero.move_to(mob, aligned_edge = DOWN+LEFT) - mob.zero.highlight(mob.get_color()) + mob.zero.set_color(mob.get_color()) mob.original = mob.copy() c.zero.shift(0.1*RIGHT) @@ -935,7 +935,7 @@ class TwoDDeterminantFormulaIntuition(LinearTransformationScene): i_brace = Brace(self.i_hat, DOWN) width = TexMobject("a").scale(1.5) i_brace.put_at_tip(width) - width.highlight(X_COLOR) + width.set_color(X_COLOR) width.add_background_rectangle() self.play(GrowFromCenter(i_brace), Write(width)) self.wait() @@ -944,7 +944,7 @@ class TwoDDeterminantFormulaIntuition(LinearTransformationScene): side_brace = Brace(self.square, RIGHT) height = TexMobject("d").scale(1.5) side_brace.put_at_tip(height) - height.highlight(Y_COLOR) + height.set_color(Y_COLOR) height.add_background_rectangle() self.play(GrowFromCenter(side_brace), Write(height)) self.wait() @@ -982,7 +982,7 @@ class FullFormulaExplanation(LinearTransformationScene): def get_matrix(self): matrix = Matrix([["a", "b"], ["c", "d"]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) ma, mb, mc, md = matrix.get_entries().split() ma.shift(0.1*DOWN) mc.shift(0.7*mc.get_height()*DOWN) @@ -1042,9 +1042,9 @@ class FullFormulaExplanation(LinearTransformationScene): text = brace.get_text(char) text.add_background_rectangle() if char in ["a", "c"]: - text.highlight(X_COLOR) + text.set_color(X_COLOR) else: - text.highlight(Y_COLOR) + text.set_color(Y_COLOR) everyone.add(brace, text) self.play(Write(everyone), run_time = 1) @@ -1069,13 +1069,13 @@ class FullFormulaExplanation(LinearTransformationScene): class ThreeDDetFormula(Scene): def construct(self): matrix = Matrix([list("abc"), list("def"), list("ghi")]) - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) m1 = Matrix([["e", "f"], ["h", "i"]]) - m1.highlight_columns(Y_COLOR, Z_COLOR) + m1.set_color_columns(Y_COLOR, Z_COLOR) m2 = Matrix([["d", "f"], ["g", "i"]]) - m2.highlight_columns(X_COLOR, Z_COLOR) + m2.set_color_columns(X_COLOR, Z_COLOR) m3 = Matrix([["d", "e"], ["g", "h"]]) - m3.highlight_columns(X_COLOR, Y_COLOR) + m3.set_color_columns(X_COLOR, Y_COLOR) for m in matrix, m1, m2, m3: m.add(get_det_text(m)) @@ -1115,8 +1115,8 @@ class ProductProperty(Scene): ")" ]) det, m1, m2, rp = lhs.split() - m1.highlight(TEAL) - m2.highlight(PINK) + m1.set_color(TEAL) + m2.set_color(PINK) rhs = TexMobject([ "=\\text{det}(", @@ -1125,15 +1125,15 @@ class ProductProperty(Scene): "M_2", ")" ]) - rhs.split()[1].highlight(TEAL) - rhs.split()[3].highlight(PINK) + rhs.split()[1].set_color(TEAL) + rhs.split()[3].set_color(PINK) rhs.next_to(lhs, RIGHT) formula = VMobject(lhs, rhs) formula.center() title = TextMobject("Explain in one sentence") - title.highlight(YELLOW) + title.set_color(YELLOW) title.next_to(formula, UP, buff = 0.5) self.play(Write(m1)) diff --git a/old_projects/eola/chapter6.py b/old_projects/eola/chapter6.py index 109aed60..4ccb7508 100644 --- a/old_projects/eola/chapter6.py +++ b/old_projects/eola/chapter6.py @@ -31,9 +31,9 @@ class OpeningQuote(Scene): "is harder than to answer it." ) words.to_edge(UP) - words[1].highlight(BLUE) + words[1].set_color(BLUE) author = TextMobject("-Georg Cantor") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -44,7 +44,7 @@ class OpeningQuote(Scene): class ListTerms(Scene): def construct(self): title = TextMobject("Under the light of linear transformations") - title.highlight(YELLOW) + title.set_color(YELLOW) title.to_edge(UP) randy = Randolph().to_corner() words = VMobject(*map(TextMobject, [ @@ -95,8 +95,8 @@ class NoComputations(TeacherStudentsScene): "``Row echelon form''", ]) ) - new_words.split()[1].highlight(YELLOW) - new_words.split()[3].highlight(GREEN) + new_words.split()[1].set_color(YELLOW) + new_words.split()[3].set_color(GREEN) self.play( Transform(self.teacher.bubble.content, new_words), self.teacher.change_mode, "speaking" @@ -114,7 +114,7 @@ class PuntToSoftware(Scene): class UsefulnessOfMatrices(Scene): def construct(self): title = TextMobject("Usefulness of matrices") - title.highlight(YELLOW) + title.set_color(YELLOW) title.to_edge(UP) self.add(title) self.wait(3) #Play some 3d linear transform over this @@ -127,7 +127,7 @@ class UsefulnessOfMatrices(Scene): equations.to_edge(RIGHT, buff = 2) syms = VMobject(*np.array(equations.split())[[1, 4, 7]]) new_syms = VMobject(*[ - m.copy().highlight(c) + m.copy().set_color(c) for m, c in zip(syms.split(), [X_COLOR, Y_COLOR, Z_COLOR]) ]) new_syms.arrange_submobjects(RIGHT, buff = 0.5) @@ -164,7 +164,7 @@ class CircuitDiagram(Scene): v2 = TexMobject("v_2").next_to(r2, RIGHT) v3 = TexMobject("v_3").next_to(r3, UP) unknowns = VMobject(v1, v2, v3) - unknowns.highlight(BLUE) + unknowns.set_color(BLUE) self.play(ShowCreation(circuit)) self.wait() @@ -268,7 +268,7 @@ class SystemOfEquations(Scene): rhs = map(TexMobject, map(str, [-3, 0, 2])) variables = map(TexMobject, list("xyz")) for v, color in zip(variables, [X_COLOR, Y_COLOR, Z_COLOR]): - v.highlight(color) + v.set_color(color) equations = VMobject() for row in mob_matrix: equation = VMobject(*it.chain(*zip( @@ -309,7 +309,7 @@ class SystemOfEquations(Scene): self.play(other_equations.fade, 0.7) self.play(Transform(scaled_vars, isolated_scaled_vars)) - self.play(scalars.highlight, YELLOW, submobject_mode = "lagged_start") + self.play(scalars.set_color, YELLOW, submobject_mode = "lagged_start") self.play(*[ ApplyMethod(m.scale_in_place, 1.2, rate_func = there_and_back) for m in scalars.split() @@ -327,16 +327,16 @@ class SystemOfEquations(Scene): def show_nonlinearity_examples(self): squared = TexMobject("x^2") - squared.split()[0].highlight(X_COLOR) + squared.split()[0].set_color(X_COLOR) sine = TexMobject("\\sin(x)") - sine.split()[-2].highlight(X_COLOR) + sine.split()[-2].set_color(X_COLOR) product = TexMobject("xy") - product.split()[0].highlight(X_COLOR) - product.split()[1].highlight(Y_COLOR) + product.split()[0].set_color(X_COLOR) + product.split()[1].set_color(Y_COLOR) words = TextMobject("Not allowed!") - words.highlight(RED) + words.set_color(RED) words.to_corner(UP+LEFT, buff = 1) arrow = Vector(RIGHT, color = RED) arrow.next_to(words, RIGHT) @@ -394,7 +394,7 @@ class SystemOfEquations(Scene): mob.square.scale_in_place(1.1) if hasattr(mob, "words"): mob.words = TextMobject(mob.words) - mob.words.highlight(color) + mob.words.set_color(color) mob.words.next_to(mob.square, UP) ys.square.add(xs.square, zs.square) zero_circles = VMobject(*[ @@ -404,9 +404,9 @@ class SystemOfEquations(Scene): for i, j in (1, 3), (2, 6) ] ]) - zero_circles.highlight(PINK) + zero_circles.set_color(PINK) zero_circles.words = TextMobject("Add zeros as needed") - zero_circles.words.highlight(zero_circles.get_color()) + zero_circles.words.set_color(zero_circles.get_color()) zero_circles.words.next_to(equations, UP) for mob in variables, constants, ys: @@ -505,8 +505,8 @@ class SystemOfEquations(Scene): x_array.words.submobject_gradient_highlight( X_COLOR, Y_COLOR, Z_COLOR ) - x_array.symbol.highlight(PINK) - v_array.symbol.highlight(YELLOW) + x_array.symbol.set_color(PINK) + v_array.symbol.set_color(YELLOW) for mob in parts: self.play( GrowFromCenter(mob.brace), @@ -551,8 +551,8 @@ class LinearSystemTransformationScene(LinearTransformationScene): self.add_foreground_mobject(equation) self.equation = equation self.A, self.x, eq, self.v = equation.split()[1].split() - self.x.highlight(PINK) - self.v.highlight(YELLOW) + self.x.set_color(PINK) + self.v.set_color(YELLOW) class MentionThatItsATransformation(LinearSystemTransformationScene): CONFIG = { @@ -619,7 +619,7 @@ class ThinkAboutWhatsHappening(Scene): lambda m : m.shift(2*DOWN).scale(5), everything ), - bubble.content.highlight, BLACK, + bubble.content.set_color, BLACK, run_time = 2 ) @@ -632,7 +632,7 @@ class SystemOfTwoEquationsTwoUnknowns(Scene): system.to_edge(UP) for indices, color in ((1, 9), X_COLOR), ((4, 12), Y_COLOR): for i in indices: - system.split()[i].highlight(color) + system.split()[i].set_color(color) matrix = Matrix([[2, 2], [1, 3]]) v = Matrix([-4, -1]) x = Matrix(["x", "y"]) @@ -651,7 +651,7 @@ class SystemOfTwoEquationsTwoUnknowns(Scene): for mob in matrix, x, v: brace = Brace(mob) label = brace.get_text("$%s$"%mob.label) - label.highlight(mob.label_color) + label.set_color(mob.label_color) brace.add(label) mob.brace = brace @@ -766,7 +766,7 @@ class StartWithNonzeroDetCase(TeacherStudentsScene): "Let's start with \\\\", "the", "$\\det(A) \\ne 0$", "case" ) - words[2].highlight(TEAL) + words[2].set_color(TEAL) self.teacher_says(words) self.random_blink() self.play( @@ -781,7 +781,7 @@ class DeclareNewTransformation(TeacherStudentsScene): "Playing a transformation in\\\\", "reverse gives a", "new transformation" ) - words[-1].highlight(GREEN) + words[-1].set_color(GREEN) self.teacher_says(words) self.change_student_modes("pondering", "sassy") self.random_blink() @@ -796,7 +796,7 @@ class PlayInReverse(FullRankExmapleDet): v_label = self.label_vector(v, "v", color = YELLOW) self.add(v.copy()) self.apply_inverse_transpose(self.t_matrix) - self.play(v.highlight, PINK) + self.play(v.set_color, PINK) self.label_vector(v, "x", color = PINK) self.wait() @@ -836,8 +836,8 @@ class DescribeInverse(LinearTransformationScene): if text.get_width() > FRAME_WIDTH-1: text.scale_to_fit_width(FRAME_WIDTH-1) text.center().to_corner(UP+RIGHT) - matrix.highlight(PINK) - inv_matrix.highlight(YELLOW) + matrix.set_color(PINK) + inv_matrix.set_color(YELLOW) self.add_foreground_mobject(title) self.apply_transposed_matrix(self.t_matrix) @@ -869,7 +869,7 @@ class MultiplyToIdentity(LinearTransformationScene): lhs.scale(1.5) A_inv, A, eq = lhs.split() identity = Matrix([[1, 0], [0, 1]]) - identity.highlight_columns(X_COLOR, Y_COLOR) + identity.set_color_columns(X_COLOR, Y_COLOR) identity.next_to(eq, RIGHT) VMobject(lhs, identity).center().to_corner(UP+RIGHT) for mob in A, A_inv, eq: @@ -931,7 +931,7 @@ class ThereAreComputationMethods(TeacherStudentsScene): class TwoDInverseFormula(Scene): def construct(self): title = TextMobject("If you're curious...") - title.highlight(YELLOW) + title.set_color(YELLOW) title.to_edge(UP) morty = Mortimer().to_corner(DOWN+RIGHT) self.add(title, morty) @@ -954,7 +954,7 @@ class SymbolicInversion(Scene): words = TextMobject("Once you have this:") words.to_edge(UP, buff = 2) inv = TexMobject("A^{-1}") - inv.highlight(GREEN) + inv.set_color(GREEN) inv.next_to(words.split()[-1], RIGHT, aligned_edge = DOWN) inv2 = inv.copy() @@ -963,8 +963,8 @@ class SymbolicInversion(Scene): end = TexMobject(vec("x"), "=", "A^{-1}", vec("v")) A, x, eq, v = start.split() - x.highlight(PINK) - v.highlight(YELLOW) + x.set_color(PINK) + v.set_color(YELLOW) interim_mobs = [inv, A, x, eq, inv2, v] for i, mob in enumerate(interim_mobs): mob.interim = mob.copy().move_to(interim.split()[i]) @@ -983,15 +983,15 @@ class SymbolicInversion(Scene): product.words = product.brace.get_text( "The ``do nothing'' matrix" ) - product.words.highlight(BLUE) + product.words.set_color(BLUE) self.play( GrowFromCenter(product.brace), Write(product.words, run_time = 1), - product.highlight, BLUE + product.set_color, BLUE ) self.wait() self.play(*[ - ApplyMethod(m.highlight, BLACK) + ApplyMethod(m.set_color, BLACK) for m in product, product.brace, product.words ]) self.wait() @@ -1018,9 +1018,9 @@ class PlayInReverseWithSolution(PlayInReverse): self.add_foreground_mobject(equation) self.equation = equation self.x, eq, self.inv, self.v = equation.split()[1].split() - self.x.highlight(PINK) - self.v.highlight(YELLOW) - self.inv.highlight(GREEN) + self.x.set_color(PINK) + self.v.set_color(YELLOW) + self.inv.set_color(GREEN) class OneUniqueSolution(Scene): def construct(self): @@ -1030,13 +1030,13 @@ class OneUniqueSolution(Scene): bx + dy &= f \\end{align*} """) - VMobject(*np.array(system.split())[[1, 8]]).highlight(X_COLOR) - VMobject(*np.array(system.split())[[4, 11]]).highlight(Y_COLOR) + VMobject(*np.array(system.split())[[1, 8]]).set_color(X_COLOR) + VMobject(*np.array(system.split())[[4, 11]]).set_color(Y_COLOR) brace = Brace(system, UP) - brace.highlight(YELLOW) + brace.set_color(YELLOW) words = brace.get_text("One unique solution \\dots", "probably") - words.highlight(YELLOW) - words.split()[1].highlight(GREEN) + words.set_color(YELLOW) + words.split()[1].set_color(GREEN) self.add(system) self.wait() @@ -1073,7 +1073,7 @@ class ThreeDInverseRule(Scene): form = TexMobject("A^{-1} A = ") form.scale(2) matrix = Matrix(np.identity(3, 'int')) - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) matrix.next_to(form, RIGHT) self.add(form) self.play(Write(matrix)) @@ -1104,7 +1104,7 @@ class InvertNonInvertable(LinearTransformationScene): def construct(self): no_func = TextMobject("No function does this") no_func.shift(2*UP) - no_func.highlight(RED) + no_func.set_color(RED) no_func.add_background_rectangle() grid = VMobject(self.plane, self.i_hat, self.j_hat) grid.save_state() @@ -1135,7 +1135,7 @@ class OneInputMultipleOutputs(InvertNonInvertable): single_input = TextMobject("Single vector") single_input.add_background_rectangle() single_input.next_to(output_vector.get_end(), UP) - single_input.highlight(YELLOW) + single_input.set_color(YELLOW) self.play(Write(single_input)) self.wait() self.remove(single_input, output_vector) @@ -1163,7 +1163,7 @@ class SolutionsCanStillExist(TeacherStudentsScene): Solutions can still exist when""", "$\\det(A) = 0$" ) - words[1].highlight(TEAL) + words[1].set_color(TEAL) self.teacher_says(words) self.random_blink(2) @@ -1185,7 +1185,7 @@ class ShowVInAndOutOfColumnSpace(LinearSystemTransformationScene): for v in v_in, v_out: self.add_vector(v, animate = True) words = TextMobject(v.words) - words.highlight(v.words_color) + words.set_color(v.words_color) words.next_to(v.get_end(), DOWN+RIGHT) words.add_background_rectangle() self.play(Write(words), run_time = 2) @@ -1205,20 +1205,20 @@ class PrepareForRank(Scene): "New terminology: ", "rank" ) - rank.highlight(TEAL) + rank.set_color(TEAL) self.play(Write(words)) self.wait() class DefineRank(Scene): def construct(self): rank = TextMobject("``Rank''") - rank.highlight(TEAL) + rank.set_color(TEAL) arrow = DoubleArrow(LEFT, RIGHT) dims = TextMobject( "Number of\\\\", "dimensions \\\\", "in the output" ) - dims[1].highlight(rank.get_color()) + dims[1].set_color(rank.get_color()) rank.next_to(arrow, LEFT) dims.next_to(arrow, RIGHT) @@ -1237,11 +1237,11 @@ class DefineColumnSpace(Scene): "outputs", "$A\\vec{\\textbf{v}}$", ) - left_words[1].highlight(TEAL) - VMobject(*left_words[-1][1:]).highlight(YELLOW) + left_words[1].set_color(TEAL) + VMobject(*left_words[-1][1:]).set_color(YELLOW) arrow = DoubleArrow(LEFT, RIGHT).to_edge(UP) right_words = TextMobject("``Column space''", "of $A$") - right_words[0].highlight(left_words[1].get_color()) + right_words[0].set_color(left_words[1].get_color()) everyone = VMobject(left_words, arrow, right_words) everyone.arrange_submobjects(RIGHT) @@ -1263,9 +1263,9 @@ class ColumnsRepresentBasisVectors(Scene): TextMobject("Where $\\hat{\\%smath}$ lands"%char) for char in "i", "j" ] - i_hat_words.highlight(X_COLOR) + i_hat_words.set_color(X_COLOR) i_hat_words.next_to(ORIGIN, LEFT).to_edge(UP) - j_hat_words.highlight(Y_COLOR) + j_hat_words.set_color(Y_COLOR) j_hat_words.next_to(ORIGIN, RIGHT).to_edge(UP) self.add(matrix) @@ -1281,7 +1281,7 @@ class ColumnsRepresentBasisVectors(Scene): Write(words, run_time = 1), ShowCreation(arrow), *[ - ApplyMethod(m.highlight, words.get_color()) + ApplyMethod(m.set_color, words.get_color()) for m in matrix.get_mob_matrix()[:,i] ] ) @@ -1302,7 +1302,7 @@ class TowDColumnsDontSpan(LinearTransformationScene): } def construct(self): matrix = Matrix(self.t_matrix.T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.add_to_back(BackgroundRectangle(matrix)) self.add_foreground_mobject(matrix) brace = Brace(matrix) @@ -1313,8 +1313,8 @@ class TowDColumnsDontSpan(LinearTransformationScene): ) words.arrange_submobjects(DOWN, buff = 0.1) words.next_to(brace, DOWN) - words[0][0].highlight(PINK) - words[2].highlight(TEAL) + words[0][0].set_color(PINK) + words[2].set_color(TEAL) words[0].add_background_rectangle() words[2].add_background_rectangle() VMobject(matrix, brace, words).to_corner(UP+LEFT) @@ -1360,14 +1360,14 @@ class ThreeDColumnsDontSpan(Scene): [0, 1, 1], [-1, -2, -1], ]).T) - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) brace = Brace(matrix) words = brace.get_text( "Columns don't", "span \\\\", "full output space" ) - words[1].highlight(PINK) + words[1].set_color(PINK) self.add(matrix) self.play( @@ -1383,7 +1383,7 @@ class NameColumnSpace(Scene): [0, 1, 1], [-1, -2, -1], ]).T) - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) matrix.to_corner(UP+LEFT) cols = list(matrix.copy().get_mob_matrix().T) col_arrays = map(Matrix, cols) @@ -1412,7 +1412,7 @@ class NameColumnSpace(Scene): arrow = DoubleArrow(LEFT, RIGHT) column_space = TextMobject("``Column space''") for mob in column_space, arrow: - mob.highlight(TEAL) + mob.set_color(TEAL) text = VMobject(span_text, arrow, column_space) text.arrange_submobjects(RIGHT) text.next_to(matrix, DOWN, buff = 1, aligned_edge = LEFT) @@ -1446,10 +1446,10 @@ class NameColumnSpace(Scene): "must be in \\\\ the", "column space." ) - VMobject(*words[1][1:3]).highlight(PINK) - VMobject(*words[1][4:6]).highlight(YELLOW) - words[2].highlight(YELLOW) - words[4].highlight(TEAL) + VMobject(*words[1][1:3]).set_color(PINK) + VMobject(*words[1][4:6]).set_color(YELLOW) + words[2].set_color(YELLOW) + words[4].set_color(TEAL) words.to_corner(UP+LEFT) self.play(Write(words)) @@ -1461,7 +1461,7 @@ class NameColumnSpace(Scene): "Number of dimensions \\\\ is called", "``rank''" ) - rank_words[1].highlight(MAROON) + rank_words[1].set_color(MAROON) self.play( GrowFromCenter(brace), Write(rank_words) @@ -1476,7 +1476,7 @@ class NameColumnSpace(Scene): col = Matrix(arr) col.replace(two_d_span[index]) two_d_span.submobjects[index] = col - col.get_entries().highlight(c) + col.get_entries().set_color(c) for index in 5, 6: two_d_span[index].scale(0) two_d_span.arrange_submobjects(RIGHT, buff = 0.2) @@ -1521,7 +1521,7 @@ class NameColumnSpace(Scene): targets = map(TexMobject, map(str, np.array(new_numbers).flatten())) for start, target in zip(starters, targets): target.move_to(start) - target.highlight(start.get_color()) + target.set_color(start.get_color()) self.play(*[ Transform(*pair, path_arc = np.pi) for pair in zip(starters, targets) @@ -1560,7 +1560,7 @@ class RankNumber(Scene): } def construct(self): words = TextMobject("Rank", "%d"%self.number) - words[1].highlight(self.color) + words[1].set_color(self.color) self.add(words) class RankNumber2(RankNumber): @@ -1584,17 +1584,17 @@ class RankNumber0(RankNumber): class NameFullRank(Scene): def construct(self): matrix = Matrix([[2, 5, 1], [3, 1, 4], [-4, 0, 0]]) - matrix.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) matrix.to_edge(UP) brace = Brace(matrix) top_words = brace.get_text( "When", "rank", "$=$", "number of columns", ) - top_words[1].highlight(MAROON) + top_words[1].set_color(MAROON) low_words = TextMobject( "matrix is", "``full rank''" ) - low_words[1].highlight(MAROON) + low_words[1].set_color(MAROON) low_words.next_to(top_words, DOWN) VMobject(matrix, brace, top_words, low_words).to_corner(UP+LEFT) self.add(matrix) @@ -1608,9 +1608,9 @@ class NameFullRank(Scene): class OriginIsAlwaysInColumnSpace(LinearTransformationScene): def construct(self): - vector = Matrix([0, 0]).highlight(YELLOW) + vector = Matrix([0, 0]).set_color(YELLOW) words = TextMobject("is always in the", "column space") - words[1].highlight(TEAL) + words[1].set_color(TEAL) words.next_to(vector, RIGHT) vector.add_to_back(BackgroundRectangle(vector)) words.add_background_rectangle() @@ -1641,7 +1641,7 @@ class FullRankCase(LinearTransformationScene): [[2, 1], [-3, 2]], [[1./2, 1], [1./3, -1./2]] ] - vector = Matrix([0, 0]).highlight(YELLOW) + vector = Matrix([0, 0]).set_color(YELLOW) title = VMobject( TextMobject("Only"), vector, TextMobject("lands on"), vector.copy() @@ -1674,13 +1674,13 @@ class NameNullSpace(LinearTransformationScene): vectors = self.get_vectors() dot = Dot(ORIGIN, color = YELLOW) line = Line(vectors[0].get_end(), vectors[-1].get_end()) - line.highlight(YELLOW) + line.set_color(YELLOW) null_space_label = TextMobject("``Null space''") kernel_label = TextMobject("``Kernel''") null_space_label.move_to(vectors[13].get_end(), aligned_edge = UP+LEFT) kernel_label.next_to(null_space_label, DOWN) for mob in null_space_label, kernel_label: - mob.highlight(YELLOW) + mob.set_color(YELLOW) mob.add_background_rectangle() self.play(ShowCreation(vectors, run_time = 3)) @@ -1739,10 +1739,10 @@ class NullSpaceSolveForVEqualsZero(NameNullSpace): vec = lambda s : "\\vec{\\textbf{%s}}"%s equation = TexMobject("A", vec("x"), "=", vec("v")) A, x, eq, v = equation - x.highlight(PINK) - v.highlight(YELLOW) + x.set_color(PINK) + v.set_color(YELLOW) zero_vector = Matrix([0, 0]) - zero_vector.highlight(YELLOW) + zero_vector.set_color(YELLOW) zero_vector.scale(0.7) zero_vector.move_to(v, aligned_edge = LEFT) VMobject(equation, zero_vector).next_to(ORIGIN, LEFT).to_edge(UP) @@ -1778,7 +1778,7 @@ class OffsetNullSpace(NameNullSpace): All vectors still land on the same spot """) - words.highlight(YELLOW) + words.set_color(YELLOW) words.add_background_rectangle() words.next_to(circle) x_copies = VMobject(*[ @@ -1823,8 +1823,8 @@ class ShowAdditivityProperty(LinearTransformationScene): def construct(self): v = Vector([2, -1]) w = Vector([1, 2]) - v.highlight(YELLOW) - w.highlight(MAROON_B) + v.set_color(YELLOW) + w.set_color(MAROON_B) sum_vect = Vector(v.get_end()+w.get_end(), color = PINK) form = TexMobject( "A(", @@ -1838,8 +1838,8 @@ class ShowAdditivityProperty(LinearTransformationScene): "\\vec{\\textbf{w}}", ) form.to_corner(UP+RIGHT) - VMobject(form[1], form[6]).highlight(YELLOW) - VMobject(form[3], form[8]).highlight(MAROON_B) + VMobject(form[1], form[6]).set_color(YELLOW) + VMobject(form[3], form[8]).set_color(MAROON_B) initial_sum = VMobject(*form[1:4]) transformer = VMobject(form[0], form[4]) final_sum = VMobject(*form[5:]) @@ -1880,7 +1880,7 @@ class AddJustOneNullSpaceVector(NameNullSpace): ) for v in x, null_vector: v.label = TextMobject(v.label) - v.label.highlight(v.get_color()) + v.label.set_color(v.get_color()) v.label.next_to(v.get_end(), UP) v.label.add_background_rectangle() dot = Dot(ORIGIN, color = null_vector.get_color()) @@ -1897,8 +1897,8 @@ class AddJustOneNullSpaceVector(NameNullSpace): "\\vec{\\textbf{n}}", ) form.to_corner(UP+RIGHT) - VMobject(form[1], form[6]).highlight(x.get_color()) - VMobject(form[3], form[8]).highlight(null_vector.get_color()) + VMobject(form[1], form[6]).set_color(x.get_color()) + VMobject(form[3], form[8]).set_color(null_vector.get_color()) initial_sum = VMobject(*form[1:4]) transformer = VMobject(form[0], form[4]) final_sum = VMobject(*form[5:]) @@ -1948,9 +1948,9 @@ class AddJustOneNullSpaceVector(NameNullSpace): "$\\vec{\\textbf{x}} + \\vec{\\textbf{n}}$\\\\", "land on the same spot" ) - words[0].highlight(x.get_color()) - VMobject(*words[2][:2]).highlight(x.get_color()) - VMobject(*words[2][3:]).highlight(null_vector.get_color()) + words[0].set_color(x.get_color()) + VMobject(*words[2][:2]).set_color(x.get_color()) + VMobject(*words[2][3:]).set_color(null_vector.get_color()) words.next_to(brace, DOWN) words.to_edge(RIGHT) self.play(Write(words)) @@ -1961,12 +1961,12 @@ class NullSpaceOffsetRule(Scene): vec = lambda s : "\\vec{\\textbf{%s}}"%s equation = TexMobject("A", vec("x"), "=", vec("v")) A, x, equals, v = equation - x.highlight(PINK) - v.highlight(YELLOW) + x.set_color(PINK) + v.set_color(YELLOW) A_text = TextMobject( "When $A$ is not", "full rank" ) - A_text[1].highlight(MAROON_C) + A_text[1].set_color(MAROON_C) A_text.next_to(A, UP+LEFT, buff = 1) A_text.shift_onto_screen() A_arrow = Arrow(A_text.get_bottom(), A, color = WHITE) @@ -1974,8 +1974,8 @@ class NullSpaceOffsetRule(Scene): "If", "$%s$"%vec("v"), "is in the", "column space", "of $A$" ) - v_text[1].highlight(YELLOW) - v_text[3].highlight(TEAL) + v_text[1].set_color(YELLOW) + v_text[3].set_color(TEAL) v_text.next_to(v, DOWN+RIGHT, buff = 1) v_text.shift_onto_screen() v_arrow = Arrow(v_text.get_top(), v, color = YELLOW) diff --git a/old_projects/eola/chapter7.py b/old_projects/eola/chapter7.py index 3ad89aa5..ccd64a43 100644 --- a/old_projects/eola/chapter7.py +++ b/old_projects/eola/chapter7.py @@ -57,9 +57,9 @@ class OpeningQuote(Scene): ) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(UP) - words[0].highlight(YELLOW) - words[2].highlight("#fd9c2b") - words[4].highlight(YELLOW) + words[0].set_color(YELLOW) + words[2].set_color("#fd9c2b") + words[4].set_color(YELLOW) for i in range(3): speaker, quote = words[2*i:2*i+2] @@ -75,7 +75,7 @@ class OpeningQuote(Scene): class TraditionalOrdering(RandolphScene): def construct(self): title = TextMobject("Traditional ordering:") - title.highlight(YELLOW) + title.set_color(YELLOW) title.scale(1.2) title.to_corner(UP+LEFT) topics = VMobject(*map(TextMobject, [ @@ -96,14 +96,14 @@ class TraditionalOrdering(RandolphScene): submobject_mode = "lagged_start" ), ) - self.play(topics[1].highlight, PINK) + self.play(topics[1].set_color, PINK) self.wait() class ThisSeriesOrdering(RandolphScene): def construct(self): title = TextMobject("Essence of linear algebra") self.randy.rotate(np.pi, UP) - title.scale(1.2).highlight(BLUE) + title.scale(1.2).set_color(BLUE) title.to_corner(UP+LEFT) line = Line(FRAME_X_RADIUS*LEFT, FRAME_X_RADIUS*RIGHT, color = WHITE) line.next_to(title, DOWN, buff = SMALL_BUFF) @@ -145,7 +145,7 @@ class ThisSeriesOrdering(RandolphScene): self.randy.change_mode, "sassy" ) self.play(self.randy.look, UP+LEFT) - self.play(chapters[6].highlight, PINK) + self.play(chapters[6].set_color, PINK) self.wait(6) class OneMustViewThroughTransformations(TeacherStudentsScene): @@ -154,7 +154,7 @@ class OneMustViewThroughTransformations(TeacherStudentsScene): "Only with" , "transformations", "\n can we truly understand", ) - words.highlight_by_tex("transformations", BLUE) + words.set_color_by_tex("transformations", BLUE) self.teacher_says(words) self.change_student_modes( "pondering", @@ -186,7 +186,7 @@ class ShowNumericalDotProduct(Scene): pairs = zip(v1.get_entries(), v2.get_entries()) for pair, color in zip(pairs, [X_COLOR, Y_COLOR, Z_COLOR, PINK]): - VGroup(*pair).highlight(color) + VGroup(*pair).set_color(color) dot = TexMobject("\\cdot") products = VGroup(*[ @@ -213,7 +213,7 @@ class ShowNumericalDotProduct(Scene): arrow = Arrow(DOWN, UP).next_to(inter_array_dot, DOWN) dot_product_words = TextMobject("Dot product") - dot_product_words.highlight(YELLOW) + dot_product_words.set_color(YELLOW) dot_product_words.next_to(arrow, DOWN) dot_product_words.shift_onto_screen() @@ -226,7 +226,7 @@ class ShowNumericalDotProduct(Scene): self.wait() if self.write_dot_product_words: self.play( - inter_array_dot.highlight, YELLOW, + inter_array_dot.set_color, YELLOW, ShowCreation(arrow), Write(dot_product_words, run_time = 2) ) @@ -279,8 +279,8 @@ class GeometricInterpretation(VectorScene): def add_symbols(self): - v = matrix_to_mobject(self.v_coords).highlight(self.v_color) - w = matrix_to_mobject(self.w_coords).highlight(self.w_color) + v = matrix_to_mobject(self.v_coords).set_color(self.v_color) + w = matrix_to_mobject(self.w_coords).set_color(self.w_color) v.add_background_rectangle() w.add_background_rectangle() dot = TexMobject("\\cdot") @@ -291,7 +291,7 @@ class GeometricInterpretation(VectorScene): for array, char in zip([v, w], ["v", "w"]): brace = Brace(array, DOWN) label = brace.get_text("$\\vec{\\textbf{%s}}$"%char) - label.highlight(array.get_color()) + label.set_color(array.get_color()) self.play( GrowFromCenter(brace), Write(label), @@ -310,7 +310,7 @@ class GeometricInterpretation(VectorScene): ): label = TexMobject("\\vec{\\textbf{%s}}"%char) label.next_to(vect.get_end(), direction) - label.highlight(vect.get_color()) + label.set_color(vect.get_color()) self.play(Write(label, run_time = 1)) self.stable_vect = self.v if self.project_onto_v else self.w self.proj_vect = self.w if self.project_onto_v else self.v @@ -359,9 +359,9 @@ class GeometricInterpretation(VectorScene): product.scale(0.9) product.next_to(self.dot_product, RIGHT) proj_words = product[2] - proj_words.highlight(self.proj_vect.get_color()) + proj_words.set_color(self.proj_vect.get_color()) stable_words = product[5] - stable_words.highlight(self.stable_vect.get_color()) + stable_words.set_color(self.stable_vect.get_color()) product.remove(proj_words, stable_words) for words in stable_words, proj_words: words.add_to_back(BackgroundRectangle(words)) @@ -407,10 +407,10 @@ class GeometricInterpretation(VectorScene): def handle_possible_negative(self): if np.dot(self.w.get_end(), self.v.get_end()) > 0: return - neg = TexMobject("-").highlight(RED) + neg = TexMobject("-").set_color(RED) neg.next_to(self.product[0], RIGHT) words = TextMobject("Should be negative") - words.highlight(RED) + words.set_color(RED) words.next_to( VMobject(*self.product[2:]), DOWN, @@ -448,11 +448,11 @@ class ShowQualitativeDotProductValues(VectorScene): ) ineq.to_edge(UP) ineq.add_background_rectangle() - comp.highlight(GREEN) - equals = TexMobject("=").highlight(PINK).move_to(comp) - less_than = TexMobject("<").highlight(RED).move_to(comp) - v_sym.highlight(V_COLOR) - w_sym.highlight(W_COLOR) + comp.set_color(GREEN) + equals = TexMobject("=").set_color(PINK).move_to(comp) + less_than = TexMobject("<").set_color(RED).move_to(comp) + v_sym.set_color(V_COLOR) + w_sym.set_color(W_COLOR) words = map(TextMobject, [ "Similar directions", "Perpendicular", @@ -461,7 +461,7 @@ class ShowQualitativeDotProductValues(VectorScene): for word, sym in zip(words, [comp, equals, less_than]): word.add_background_rectangle() word.next_to(sym, DOWN, aligned_edge = LEFT, buff = MED_SMALL_BUFF) - word.highlight(sym.get_color()) + word.set_color(sym.get_color()) v = Vector([1.5, 1.5], color = V_COLOR) w = Vector([2, 2], color = W_COLOR) @@ -520,8 +520,8 @@ class AskAboutSymmetry(TeacherStudentsScene): v, "\\cdot", w, "=", w, "\\cdot", v, "\\text{?}" ) - VMobject(question[1], question[7]).highlight(V_COLOR) - VMobject(question[3], question[5]).highlight(W_COLOR) + VMobject(question[1], question[7]).set_color(V_COLOR) + VMobject(question[3], question[5]).set_color(W_COLOR) self.student_says( question, target_mode = "raise_left_hand" @@ -544,7 +544,7 @@ class SymmetricVAndW(VectorScene): w = Vector([1, 3], color = W_COLOR) for vect, char in zip([v, w], ["v", "w"]): vect.label = TexMobject("\\vec{\\textbf{%s}}"%char) - vect.label.highlight(vect.get_color()) + vect.label.set_color(vect.get_color()) vect.label.next_to(vect.get_end(), DOWN+RIGHT) for v1, v2 in (v, w), (w, v): v1.proj = get_vect_mob_projection(v1, v2) @@ -608,8 +608,8 @@ class SymmetricVAndW(VectorScene): "=", "2(", v_tex, "\\cdot", w_tex, ")" ) - equation.highlight_by_tex(v_tex, V_COLOR) - equation.highlight_by_tex(w_tex, W_COLOR) + equation.set_color_by_tex(v_tex, V_COLOR) + equation.set_color_by_tex(w_tex, W_COLOR) equation.next_to(ORIGIN, DOWN).to_edge(RIGHT) words = TextMobject("Symmetry is broken") @@ -730,11 +730,11 @@ class Symbolic2To1DTransform(Scene): def construct(self): func = TexMobject("L(", "\\vec{\\textbf{v}}", ")") input_array = Matrix([2, 7]) - input_array.highlight(YELLOW) + input_array.set_color(YELLOW) in_arrow = Arrow(LEFT, RIGHT, color = input_array.get_color()) - func[1].highlight(input_array.get_color()) + func[1].set_color(input_array.get_color()) output_array = Matrix([1.8]) - output_array.highlight(PINK) + output_array.set_color(PINK) out_arrow = Arrow(LEFT, RIGHT, color = output_array.get_color()) VMobject( input_array, in_arrow, func, out_arrow, output_array @@ -744,11 +744,11 @@ class Symbolic2To1DTransform(Scene): input_words = input_brace.get_text("2d input") output_brace = Brace(output_array, UP) output_words = output_brace.get_text("1d output") - input_words.highlight(input_array.get_color()) - output_words.highlight(output_array.get_color()) + input_words.set_color(input_array.get_color()) + output_words.set_color(output_array.get_color()) special_words = TextMobject("Linear", "functions are quite special") - special_words.highlight_by_tex("Linear", BLUE) + special_words.set_color_by_tex("Linear", BLUE) special_words.to_edge(UP) @@ -808,13 +808,13 @@ class OkayToIgnoreFormalProperties(Scene): "L(", "c", v_tex, ") =", "c", "L(", v_tex, ")", ) for tex_mob in additivity, scaling: - tex_mob.highlight_by_tex(v_tex, V_COLOR) - tex_mob.highlight_by_tex(w_tex, W_COLOR) - tex_mob.highlight_by_tex("c", GREEN) + tex_mob.set_color_by_tex(v_tex, V_COLOR) + tex_mob.set_color_by_tex(w_tex, W_COLOR) + tex_mob.set_color_by_tex("c", GREEN) additivity.next_to(h_line, DOWN, buff = MED_SMALL_BUFF) scaling.next_to(additivity, DOWN, buff = MED_SMALL_BUFF) words = TextMobject("We'll ignore these") - words.highlight(RED) + words.set_color(RED) arrow = Arrow(DOWN, UP, color = RED) arrow.next_to(scaling, DOWN) words.next_to(arrow, DOWN) @@ -839,7 +839,7 @@ class OkayToIgnoreFormalProperties(Scene): class FormalVsVisual(Scene): def construct(self): title = TextMobject("Linearity") - title.highlight(BLUE) + title.set_color(BLUE) title.to_edge(UP) line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS) line.next_to(title, DOWN) @@ -855,13 +855,13 @@ class FormalVsVisual(Scene): "L(", v_tex, "+", w_tex, ") = ", "L(", v_tex, ")+", "L(", w_tex, ")" ) - additivity.highlight_by_tex(v_tex, V_COLOR) - additivity.highlight_by_tex(w_tex, W_COLOR) + additivity.set_color_by_tex(v_tex, V_COLOR) + additivity.set_color_by_tex(w_tex, W_COLOR) scaling = TexMobject( "L(", "c", v_tex, ")=", "c", "L(", v_tex, ")" ) - scaling.highlight_by_tex(v_tex, V_COLOR) - scaling.highlight_by_tex("c", GREEN) + scaling.set_color_by_tex(v_tex, V_COLOR) + scaling.set_color_by_tex("c", GREEN) visual_statement = TextMobject(""" Line of dots evenly spaced @@ -906,7 +906,7 @@ class AdditivityProperty(TwoDToOneDScene): if not self.sum_before: sum_vect = self.play_sum(v, w) symbols.target = symbols.copy().next_to(sum_vect, UP) - VGroup(L, r_paren).highlight(BLACK) + VGroup(L, r_paren).set_color(BLACK) self.play(Transform(symbols, symbols.target)) self.wait() @@ -946,8 +946,8 @@ class AdditivityProperty(TwoDToOneDScene): tex_mob, VectorizedPoint(tex_mob.get_right()), ) - tex_mob.highlight_by_tex(v_tex, V_COLOR) - tex_mob.highlight_by_tex(w_tex, W_COLOR) + tex_mob.set_color_by_tex(v_tex, V_COLOR) + tex_mob.set_color_by_tex(w_tex, W_COLOR) result[1].add_to_back(BackgroundRectangle(result[1])) return result @@ -992,8 +992,8 @@ class ScalingProperty(TwoDToOneDScene): "c", "L(", v_tex, ")", ) tex_mob.next_to(scaled_vect, DOWN) - tex_mob.highlight_by_tex(v_tex, V_COLOR) - tex_mob.highlight_by_tex("c", GREEN) + tex_mob.set_color_by_tex(v_tex, V_COLOR) + tex_mob.set_color_by_tex("c", GREEN) self.play(Write(tex_mob)) self.wait() @@ -1029,7 +1029,7 @@ class NonLinearFailsDotTest(TwoDTo1DTransformWithDots): words = TextMobject( "Line of dots", "do not", "remain evenly spaced" ) - words.highlight_by_tex("do not", RED) + words.set_color_by_tex("do not", RED) words.next_to(line, UP, buff = MED_SMALL_BUFF) array_tex = matrix_to_tex_string(["x", "y"]) equation = TexMobject( @@ -1054,8 +1054,8 @@ class AlwaysfollowIHatJHat(TeacherStudentsScene): words = TextMobject( "Always follow", i_tex, "and", j_tex ) - words.highlight_by_tex(i_tex, X_COLOR) - words.highlight_by_tex(j_tex, Y_COLOR) + words.set_color_by_tex(i_tex, X_COLOR) + words.set_color_by_tex(j_tex, Y_COLOR) self.teacher_says(words) students = VMobject(*self.get_students()) ponderers = VMobject(*[ @@ -1083,7 +1083,7 @@ class ShowMatrix(TwoDToOneDScene): ) direction = UP if vect is self.i_hat else DOWN vect.words.next_to(vect.get_end(), direction, buff = LARGE_BUFF) - vect.words.highlight(vect.get_color()) + vect.words.set_color(vect.get_color()) matrix = Matrix([[1, 2]]) matrix_words = TextMobject("Transformation matrix: ") matrix_group = VMobject(matrix_words, matrix) @@ -1118,7 +1118,7 @@ class FollowVectorViaCoordinates(TwoDToOneDScene): array.get_entries().gradient_highlight(X_COLOR, Y_COLOR) array.add_to_back(BackgroundRectangle(array)) v_label = TexMobject("\\vec{\\textbf{v}}", "=") - v_label[0].highlight(YELLOW) + v_label[0].set_color(YELLOW) v_label.next_to(v.get_end(), RIGHT) v_label.add_background_rectangle() array.next_to(v_label, RIGHT) @@ -1173,11 +1173,11 @@ class FollowVectorViaCoordinates(TwoDToOneDScene): for char in "i", "j" ] - new_labels[0].highlight(X_COLOR) - new_labels[1].highlight(Y_COLOR) + new_labels[0].set_color(X_COLOR) + new_labels[1].set_color(Y_COLOR) new_labels.append( - TexMobject("L(\\vec{\\textbf{v}})").highlight(YELLOW) + TexMobject("L(\\vec{\\textbf{v}})").set_color(YELLOW) ) for label, vect, direction in zip(new_labels, list(bases) + [v], [UP, DOWN, UP]): label.next_to(vect, direction) @@ -1196,7 +1196,7 @@ class FollowVectorViaCoordinates(TwoDToOneDScene): if self.concrete: final_label = TexMobject(str(int(v.get_end()[0]))) final_label.move_to(new_labels[-1]) - final_label.highlight(new_labels[-1].get_color()) + final_label.set_color(new_labels[-1].get_color()) self.play(Transform(new_labels[-1], final_label)) self.wait() @@ -1249,8 +1249,8 @@ class TwoDOneDMatrixMultiplication(Scene): for m, vect in zip([matrix, vector], [UP, DOWN]): m.brace = Brace(m, vect) m.label = m.brace.get_text(m.label) - matrix.label.highlight(BLUE) - vector.label.highlight(MAROON_B) + matrix.label.set_color(BLUE) + vector.label.set_color(MAROON_B) for m in vector, matrix: self.play(Write(m)) @@ -1289,8 +1289,8 @@ class TwoDOneDMatrixMultiplication(Scene): def color_matrix_and_vector(self, matrix, vector): for m in matrix, vector: x, y = m.get_entries() - x.highlight(X_COLOR) - y.highlight(Y_COLOR) + x.set_color(X_COLOR) + y.set_color(Y_COLOR) class AssociationBetweenMatricesAndVectors(Scene): CONFIG = { @@ -1301,9 +1301,9 @@ class AssociationBetweenMatricesAndVectors(Scene): } def construct(self): matrices_words = TextMobject("$1\\times 2$ matrices") - matrices_words.highlight(BLUE) + matrices_words.set_color(BLUE) vectors_words = TextMobject("2d vectors") - vectors_words.highlight(YELLOW) + vectors_words.set_color(YELLOW) arrow = DoubleArrow(LEFT, RIGHT, color = WHITE) VGroup( matrices_words, arrow, vectors_words @@ -1313,8 +1313,8 @@ class AssociationBetweenMatricesAndVectors(Scene): vectors = VGroup(*map(Matrix, [m[0] for m in self.matrices])) for m in list(matrices) + list(vectors): x, y = m.get_entries() - x.highlight(X_COLOR) - y.highlight(Y_COLOR) + x.set_color(X_COLOR) + y.set_color(Y_COLOR) matrices.words = matrices_words vectors.words = vectors_words for group in matrices, vectors: @@ -1383,14 +1383,14 @@ class SomeKindOfConnection(Scene): numbers = number_line.get_numbers(*range(-6, 8, 2)) v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) - v_line.highlight(GREY) + v_line.set_color(GREY) v_line.set_stroke(width = 10) matrix = Matrix([self.v_coords]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(number_line, UP, buff = LARGE_BUFF) v_coords = Matrix(self.v_coords) - v_coords.highlight_columns(YELLOW) + v_coords.set_color_columns(YELLOW) v_coords.scale(0.75) v_coords.next_to(vect.get_end(), RIGHT) for array in matrix, v_coords: @@ -1425,7 +1425,7 @@ class AnExampleWillClarify(TeacherStudentsScene): class ImagineYouDontKnowThis(Scene): def construct(self): words = TextMobject("Imagine you don't know this") - words.highlight(RED) + words.set_color(RED) words.scale(1.5) self.play(Write(words)) self.wait() @@ -1446,7 +1446,7 @@ class ProjectOntoUnitVectorNumberline(VectorScene): u_brace = Brace(u_hat, UP) u_hat.rotate(self.tilt_angle) u_hat.label = TexMobject("\\hat{\\textbf{u}}") - u_hat.label.highlight(u_hat.get_color()) + u_hat.label.set_color(u_hat.get_color()) u_hat.label.next_to(u_hat.get_end(), UP+LEFT) one = TexMobject("1") u_brace.put_at_tip(one) @@ -1558,12 +1558,12 @@ class ProjectionFunctionSymbol(Scene): "P(", v_tex, ")=", "\\text{number }", v_tex, "\\text{ lands on}" ) - equation.highlight_by_tex(v_tex, YELLOW) + equation.set_color_by_tex(v_tex, YELLOW) equation.shift(2*UP) words = TextMobject( "This projection function is", "linear" ) - words.highlight_by_tex("linear", BLUE) + words.set_color_by_tex("linear", BLUE) arrow = Arrow( words.get_top(), equation[0].get_bottom(), color = BLUE @@ -1589,15 +1589,15 @@ class ProjectSingleVectorOnUHat(ProjectOntoUnitVectorNumberline): v = Vector([-3, 1], color = PINK) v.proj = get_vect_mob_projection(v, self.u_hat) v.proj_line = DashedLine(v.get_end(), v.proj.get_end()) - v.proj_line.highlight(v.get_color()) + v.proj_line.set_color(v.get_color()) v_tex = "\\vec{\\textbf{v}}" u_tex = self.u_hat.label.get_tex_string() v.label = TexMobject(v_tex) - v.label.highlight(v.get_color()) + v.label.set_color(v.get_color()) v.label.next_to(v.get_end(), LEFT) dot_product = TexMobject(v_tex, "\\cdot", u_tex) - dot_product.highlight_by_tex(v_tex, v.get_color()) - dot_product.highlight_by_tex(u_tex, self.u_hat.get_color()) + dot_product.set_color_by_tex(v_tex, v.get_color()) + dot_product.set_color_by_tex(u_tex, self.u_hat.get_color()) dot_product.next_to(ORIGIN, UP, buff = MED_SMALL_BUFF) dot_product.rotate(self.tilt_angle) dot_product.shift(v.proj.get_end()) @@ -1625,7 +1625,7 @@ class ProjectSingleVectorOnUHat(ProjectOntoUnitVectorNumberline): class AskAboutProjectionMatrix(Scene): def construct(self): matrix = Matrix([["?", "?"]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) words = TextMobject("Projection matrix:") VMobject(words, matrix).arrange_submobjects(buff = MED_SMALL_BUFF).shift(UP) basis_words = [ @@ -1635,7 +1635,7 @@ class AskAboutProjectionMatrix(Scene): for b_words, q_mark, direction in zip(basis_words, matrix.get_entries(), [UP, DOWN]): b_words.next_to(q_mark, direction, buff = 1.5) b_words.arrow = Arrow(b_words, q_mark, color = q_mark.get_color()) - b_words.highlight(q_mark.get_color()) + b_words.set_color(q_mark.get_color()) self.play( Write(words), @@ -1675,8 +1675,8 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline): question = TextMobject( "Where do", i_tex, "and", j_tex, "land?" ) - question.highlight_by_tex(i_tex, X_COLOR) - question.highlight_by_tex(j_tex, Y_COLOR) + question.set_color_by_tex(i_tex, X_COLOR) + question.set_color_by_tex(j_tex, Y_COLOR) question.add_background_rectangle() matrix = Matrix([["u_x", "u_y"]]) VGroup(question, matrix).arrange_submobjects(DOWN).to_corner( @@ -1694,7 +1694,7 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline): (DOWN+RIGHT, UP+LEFT, UP), ) for label, vect, direction in trips: - label.highlight(vect.get_color()) + label.set_color(vect.get_color()) label.scale(1.2) label.next_to(vect.get_end(), direction, buff = MED_SMALL_BUFF/2) @@ -1718,7 +1718,7 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline): # self.show_u_coords(u_label) u_x, u_y = [ - TexMobject("u_%s"%c).highlight(self.u_hat.get_color()) + TexMobject("u_%s"%c).set_color(self.u_hat.get_color()) for c in "x", "y" ] matrix_x, matrix_y = matrix.get_entries() @@ -1731,8 +1731,8 @@ class ProjectBasisVectors(ProjectOntoUnitVectorNumberline): # def show_u_coords(self, u_label): # coords = Matrix(["u_x", "u_y"]) # x, y = coords.get_entries() - # x.highlight(X_COLOR) - # y.highlight(Y_COLOR) + # x.set_color(X_COLOR) + # y.set_color(Y_COLOR) # coords.add_to_back(BackgroundRectangle(coords)) # eq = TexMobject("=") # eq.next_to(u_label, RIGHT) @@ -1806,7 +1806,7 @@ class ShowSingleProjection(ProjectBasisVectors): color = vector.get_color() ) coords = Matrix(["x", "y"]) - coords.get_entries().highlight(vector.get_color()) + coords.get_entries().set_color(vector.get_color()) coords.add_to_back(BackgroundRectangle(coords)) coords.next_to(vector.get_end(), RIGHT) @@ -1850,8 +1850,8 @@ class GeneralTwoDOneDMatrixMultiplication(TwoDOneDMatrixMultiplication): TexMobject("\\Updownarrow"), TextMobject("Dot product") ) - words[0].highlight(BLUE) - words[2].highlight(GREEN) + words[0].set_color(BLUE) + words[2].set_color(GREEN) words.arrange_submobjects(DOWN) words.to_edge(LEFT) @@ -1874,9 +1874,9 @@ class GeneralTwoDOneDMatrixMultiplication(TwoDOneDMatrixMultiplication): def color_matrix_and_vector(self, matrix, vector): colors = [X_COLOR, Y_COLOR] for coord, color in zip(matrix.get_entries(), colors): - coord[0].highlight(YELLOW) - coord[1].highlight(color) - vector.get_entries().highlight(MAROON_B) + coord[0].set_color(YELLOW) + coord[1].set_color(color) + vector.get_entries().set_color(MAROON_B) class UHatIsTransformInDisguise(Scene): def construct(self): @@ -1887,8 +1887,8 @@ class UHatIsTransformInDisguise(Scene): "transform", "in disguise", ) - words.highlight_by_tex(u_tex, YELLOW) - words.highlight_by_tex("transform", BLUE) + words.set_color_by_tex(u_tex, YELLOW) + words.set_color_by_tex("transform", BLUE) words.scale(2) self.play(Write(words)) @@ -1923,7 +1923,7 @@ class ScaleUpUHat(ProjectOntoUnitVectorNumberline) : "%du_y"%self.scalar, ]) for v in self.u_hat, new_u: - v.coords.get_entries().highlight(YELLOW) + v.coords.get_entries().set_color(YELLOW) v.coords.add_to_back(BackgroundRectangle(v.coords)) v.coords.next_to(v.get_end(), UP+LEFT) @@ -1936,14 +1936,14 @@ class ScaleUpUHat(ProjectOntoUnitVectorNumberline) : def show_matrix(self): matrix = Matrix([list(self.u_hat.coords.get_entries().copy())]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.add_to_back(BackgroundRectangle(matrix)) brace = Brace(matrix) words = TextMobject( "\\centering Associated\\\\", "transformation" ) - words.highlight_by_tex("transformation", BLUE) + words.set_color_by_tex("transformation", BLUE) words.add_background_rectangle() brace.put_at_tip(words) VGroup(matrix, brace, words).to_corner(UP+LEFT) @@ -1968,10 +1968,10 @@ class ScaleUpUHat(ProjectOntoUnitVectorNumberline) : dashed_segment_length = 0.05 ) b.proj.label = TexMobject("u_%s"%char) - b.proj.label.highlight(b.get_color()) + b.proj.label.set_color(b.get_color()) b.scaled_proj = b.proj.copy().scale(self.scalar) b.scaled_proj.label = TexMobject("3u_%s"%char) - b.scaled_proj.label.highlight(b.get_color()) + b.scaled_proj.label.set_color(b.get_color()) for v, direction in zip([b.proj, b.scaled_proj], [UP, UP+LEFT]): v.label.add_background_rectangle() v.label.next_to(v.get_end(), direction) @@ -2016,12 +2016,12 @@ class ScaleUpUHat(ProjectOntoUnitVectorNumberline) : self.play(ShowCreation(proj_line)) self.play( Transform(mover, proj), - project.highlight, YELLOW + project.set_color, YELLOW ) self.wait() self.play( mover.scale, self.scalar, - then_scale.highlight, YELLOW + then_scale.set_color, YELLOW ) self.wait() @@ -2071,14 +2071,14 @@ class TwoDOneDTransformationSeparateSpace(Scene): numbers = number_line.get_numbers(*range(-6, 8, 2)) v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) - v_line.highlight(GREY) + v_line.set_color(GREY) v_line.set_stroke(width = 10) matrix = Matrix([self.v_coords]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(number_line, UP, buff = LARGE_BUFF) v_coords = Matrix(self.v_coords) - v_coords.highlight_columns(YELLOW) + v_coords.set_color_columns(YELLOW) v_coords.scale(0.75) v_coords.next_to(vect.get_end(), RIGHT) for array in matrix, v_coords: @@ -2183,12 +2183,12 @@ class TranslateToTheWorldOfTransformations(TwoDOneDMatrixMultiplication): Matrix(["x_%d"%n, "y_%d"%n]) for n in 1, 2 ] - v1.highlight_columns(V_COLOR) - v2.highlight_columns(W_COLOR) + v1.set_color_columns(V_COLOR) + v2.set_color_columns(W_COLOR) dot = TexMobject("\\cdot") matrix = Matrix([["x_1", "y_1"]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) dot_product = VGroup(v1, dot, v2) dot_product.arrange_submobjects(RIGHT) @@ -2198,7 +2198,7 @@ class TranslateToTheWorldOfTransformations(TwoDOneDMatrixMultiplication): word = TextMobject("Transform") word.scale_to_fit_width(brace.get_width()) brace.put_at_tip(word) - word.highlight(BLUE) + word.set_color(BLUE) self.play(Write(dot_product)) self.wait() @@ -2259,14 +2259,14 @@ class WhatTheVectorWantsToBe(Scene): numbers = number_line.get_numbers(*range(-6, 8, 2)) v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) - v_line.highlight(GREY) + v_line.set_color(GREY) v_line.set_stroke(width = 10) matrix = Matrix([self.v_coords]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(number_line, UP, buff = LARGE_BUFF) v_coords = Matrix(self.v_coords) - v_coords.highlight_columns(YELLOW) + v_coords.set_color_columns(YELLOW) v_coords.scale(0.75) v_coords.next_to(vect.get_end(), RIGHT) for array in matrix, v_coords: @@ -2277,7 +2277,7 @@ class WhatTheVectorWantsToBe(Scene): "\\\\ wants", "to be" ) - words[1].highlight(BLUE) + words[1].set_color(BLUE) words.next_to(matrix, UP, buff = MED_SMALL_BUFF) self.add(plane, v_line, number_line, numbers) diff --git a/old_projects/eola/chapter8.py b/old_projects/eola/chapter8.py index 5b662cc2..64bc294a 100644 --- a/old_projects/eola/chapter8.py +++ b/old_projects/eola/chapter8.py @@ -44,7 +44,7 @@ class OpeningQuote(Scene): words = TextMobject("``Every dimension is special.''") words.to_edge(UP) author = TextMobject("-Jeff Lagarias") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -69,7 +69,7 @@ class LastVideo(Scene): class DoTheSameForCross(TeacherStudentsScene): def construct(self): words = TextMobject("Let's do the same \\\\ for", "cross products") - words.highlight_by_tex("cross products", YELLOW) + words.set_color_by_tex("cross products", YELLOW) self.teacher_says(words, target_mode = "surprised") self.random_blink(2) self.change_student_modes("pondering") @@ -89,7 +89,7 @@ class ListSteps(Scene): step_1 = TextMobject("This video: Standard introduction") step_2 = TextMobject("Next video: Deeper understanding with ", "linear transformations") - step_2.highlight_by_tex("linear transformations", BLUE) + step_2.set_color_by_tex("linear transformations", BLUE) steps = VGroup(step_1, step_2) steps.arrange_submobjects(DOWN, aligned_edge = LEFT, buff = LARGE_BUFF) steps.next_to(randy, UP) @@ -103,8 +103,8 @@ class ListSteps(Scene): for step in steps: target = step.copy() target.scale_in_place(1.1) - target.highlight(YELLOW) - target.highlight_by_tex("linear transformations", BLUE) + target.set_color(YELLOW) + target.set_color_by_tex("linear transformations", BLUE) step.target = target step.save_state() self.play(FadeIn(randy)) @@ -209,7 +209,7 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene): ) self.wait() self.play(ApplyFunction( - lambda m : m.scale_in_place(1.2).highlight(RED), + lambda m : m.scale_in_place(1.2).set_color(RED), times, rate_func = there_and_back )) @@ -242,8 +242,8 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene): square.target = self.square self.square = square - positive = TextMobject("Positive").highlight(GREEN) - negative = TextMobject("Negative").highlight(RED) + positive = TextMobject("Positive").set_color(GREEN) + negative = TextMobject("Negative").set_color(RED) for word in positive, negative: word.add_background_rectangle() word.arrow = Arrow( @@ -256,14 +256,14 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene): buff = SMALL_BUFF ) minus_sign = TexMobject("-") - minus_sign.highlight(RED) + minus_sign.set_color(RED) minus_sign.move_to(self.area_words, aligned_edge = LEFT) self.area_words.target = self.area_words.copy() self.area_words.target.next_to(minus_sign, RIGHT) self.play(*map(MoveToTarget, [square, self.v, self.w])) arc = self.get_arc(self.v, self.w, radius = 1.5) - arc.highlight(GREEN) + arc.set_color(GREEN) self.play(ShowCreation(arc)) self.wait() self.play(Write(positive), ShowCreation(positive.arrow)) @@ -274,7 +274,7 @@ class SimpleDefine2dCrossProduct(LinearTransformationScene): *[mob.restore for mob in square, self.v, self.w] ) arc = self.get_arc(self.v, self.w, radius = 1.5) - arc.highlight(RED) + arc.set_color(RED) self.play(ShowCreation(arc)) self.play( Write(negative), @@ -365,7 +365,7 @@ class CrossBasisVectors(LinearTransformationScene): self.play(Write(eq)) self.wait() arc = self.get_arc(self.i_hat, self.j_hat, radius = 1) - # arc.highlight(GREEN) + # arc.set_color(GREEN) self.play(ShowCreation(arc)) self.wait() @@ -398,8 +398,8 @@ class VisualExample(SimpleDefine2dCrossProduct): val = TexMobject(str(int(abs(result)))).scale(2) val.move_to(self.square.get_center()) arc = self.get_arc(self.v, self.w, radius = 1) - arc.highlight(RED) - minus = TexMobject("-").highlight(RED) + arc.set_color(RED) + minus = TexMobject("-").set_color(RED) minus.scale(1.5) minus.move_to(self.area_words, aligned_edge = LEFT) @@ -447,7 +447,7 @@ class ContrastDotAndCross(Scene): title = TextMobject("%s product"%word) title.shift(vect*FRAME_X_RADIUS/2) title.to_edge(UP) - title.highlight(color) + title.set_color(color) self.add(title) v_line = Line(UP, DOWN).scale(FRAME_Y_RADIUS) l_h_line = Line(LEFT, ORIGIN).scale(FRAME_X_RADIUS) @@ -469,7 +469,7 @@ class ContrastDotAndCross(Scene): m1, m2 = map(Matrix, arrays) for matrix in m1, m2: for entry, color in zip(matrix.get_entries(), colors): - entry.highlight(color) + entry.set_color(color) entry.target = entry.copy() syms = VGroup(*map(TexMobject, ["="] + ["+"]*(dim-1))) def get_dot(): @@ -524,7 +524,7 @@ class ContrastDotAndCross(Scene): matrices = map(Matrix, arrays) for matrix in matrices: for entry, color in zip(matrix.get_entries(), colors): - entry.highlight(color) + entry.set_color(color) m1, m2 = matrices cross_product = VGroup(m1, TexMobject("\\times"), m2) cross_product.arrange_submobjects() @@ -600,7 +600,7 @@ class ContrastDotAndCross(Scene): m1, m2 = matrices = map(Matrix, arrays) for m in matrices: for e, color in zip(m.get_entries(), [X_COLOR, Y_COLOR]): - e.highlight(color) + e.set_color(color) cross_product = VGroup(m1, TexMobject("\\times"), m2) cross_product.arrange_submobjects() (x1, x2), (x3, x4) = tuple(m1.get_entries()), tuple(m2.get_entries()) @@ -723,7 +723,7 @@ class Define2dCrossProduct(LinearTransformationScene): disclaimer = TextMobject("$^*$ See ``Note on conventions'' in description") disclaimer.scale(0.7) - disclaimer.highlight(RED) + disclaimer.set_color(RED) disclaimer.next_to( det_text.get_corner(UP+RIGHT), RIGHT, buff = 0 ) @@ -797,7 +797,7 @@ class Define2dCrossProduct(LinearTransformationScene): both_words = [] for char, color, col in ("i", X_COLOR, col1), ("j", Y_COLOR, col2): words = TextMobject("Where $\\hat\\%smath$ lands"%char) - words.highlight(color) + words.set_color(color) words.add_background_rectangle() words.next_to(col, DOWN, buff = LARGE_BUFF) words.arrow = Arrow(words.get_top(), col.get_bottom(), color = color) @@ -811,13 +811,13 @@ class Define2dCrossProduct(LinearTransformationScene): self.play( Write(i_words), ShowCreation(i_words.arrow), - col1.highlight, X_COLOR + col1.set_color, X_COLOR ) self.wait() self.play( Transform(i_words, j_words), Transform(i_words.arrow, j_words.arrow), - col2.highlight, Y_COLOR + col2.set_color, Y_COLOR ) self.wait() self.play(*map(FadeOut, [i_words, i_words.arrow, basis_labels])) @@ -844,7 +844,7 @@ class Define2dCrossProduct(LinearTransformationScene): FadeIn(self.w.label), FadeIn(self.v.coord_array), FadeIn(self.w.coord_array), - matrix.highlight_columns, V_COLOR, W_COLOR + matrix.set_color_columns, V_COLOR, W_COLOR ) self.wait() self.i_hat, self.j_hat = i_hat, j_hat @@ -944,14 +944,14 @@ class Define2dCrossProduct(LinearTransformationScene): for word in "\\text{positive}", "\\text{negative}" ] for words in words_list: - words.highlight_by_tex(v_tex, V_COLOR) - words.highlight_by_tex(w_tex, W_COLOR) - words.highlight_by_tex("\\text{positive}", GREEN) - words.highlight_by_tex("\\text{negative}", RED) + words.set_color_by_tex(v_tex, V_COLOR) + words.set_color_by_tex(w_tex, W_COLOR) + words.set_color_by_tex("\\text{positive}", GREEN) + words.set_color_by_tex("\\text{negative}", RED) words.add_background_rectangle() words.next_to(self.square, UP) arc = self.get_arc(self.v, self.w) - arc.highlight(GREEN) + arc.set_color(GREEN) self.play( Write(positive_words), ShowCreation(arc) @@ -960,7 +960,7 @@ class Define2dCrossProduct(LinearTransformationScene): self.remove(arc) self.play(movers.restore) arc = self.get_arc(self.v, self.w) - arc.highlight(RED) + arc.set_color(RED) self.play( Transform(positive_words, negative_words), ShowCreation(arc) @@ -972,8 +972,8 @@ class Define2dCrossProduct(LinearTransformationScene): ) anticommute.shift(FRAME_X_RADIUS*RIGHT/2) anticommute.to_edge(UP) - anticommute.highlight_by_tex(v_tex, V_COLOR) - anticommute.highlight_by_tex(w_tex, W_COLOR) + anticommute.set_color_by_tex(v_tex, V_COLOR) + anticommute.set_color_by_tex(w_tex, W_COLOR) anticommute.add_background_rectangle() for v1, v2 in (self.v, self.w), (self.w, self.v): v1.label[0].set_fill(opacity = 0) @@ -1021,8 +1021,8 @@ class TwoDCrossProductExample(Define2dCrossProduct): w.coords = Matrix(self.w_coords) v.coords.next_to(v.get_end(), LEFT) w.coords.next_to(w.get_end(), RIGHT) - v.coords.highlight(v.get_color()) - w.coords.highlight(w.get_color()) + v.coords.set_color(v.get_color()) + w.coords.set_color(w.get_color()) for coords in v.coords, w.coords: coords.background_rectangle = BackgroundRectangle(coords) coords.add_to_back(coords.background_rectangle) @@ -1040,8 +1040,8 @@ class TwoDCrossProductExample(Define2dCrossProduct): det_text = get_det_text(matrix) v_tex, w_tex = get_vect_tex("v", "w") cross_product = TexMobject(v_tex, "\\times", w_tex, "=") - cross_product.highlight_by_tex(v_tex, V_COLOR) - cross_product.highlight_by_tex(w_tex, W_COLOR) + cross_product.set_color_by_tex(v_tex, V_COLOR) + cross_product.set_color_by_tex(w_tex, W_COLOR) cross_product.add_background_rectangle() equation_start = VGroup( cross_product, @@ -1114,7 +1114,7 @@ class TwoDCrossProductExample(Define2dCrossProduct): det_sym.scale(1.5) det_sym.next_to(v.get_end()+w.get_end(), DOWN+RIGHT, buff = MED_SMALL_BUFF/2) arc = self.get_arc(v, w, radius = 1) - arc.highlight(RED) + arc.set_color(RED) self.play(Write(det_sym)) self.play(ShowCreation(arc)) self.wait() @@ -1158,14 +1158,14 @@ class BiggerWhenPerpendicular(LinearTransformationScene): arrow = TextMobject("\\Rightarrow") v_tex, w_tex = get_vect_tex("v", "w") cross_is = TexMobject(v_tex, "\\times", w_tex, "\\text{ is }") - cross_is.highlight_by_tex(v_tex, V_COLOR) - cross_is.highlight_by_tex(w_tex, W_COLOR) + cross_is.set_color_by_tex(v_tex, V_COLOR) + cross_is.set_color_by_tex(w_tex, W_COLOR) bigger = TextMobject("bigger") smaller = TextMobject("smaller") bigger.scale(1.5) smaller.scale(0.75) - bigger.highlight(PINK) - smaller.highlight(TEAL) + bigger.set_color(PINK) + smaller.set_color(TEAL) group = VGroup(start_words, arrow, cross_is, bigger) group.arrange_submobjects() group.to_edge(UP) @@ -1245,8 +1245,8 @@ class ScalingRule(LinearTransformationScene): rhs = TexMobject("=3(", v_tex, "\\times", w_tex, ")") three_v = TexMobject("(3", v_tex, ")") for tex_mob in cross_product, rhs, three_v: - tex_mob.highlight_by_tex(v_tex, V_COLOR) - tex_mob.highlight_by_tex(w_tex, W_COLOR) + tex_mob.set_color_by_tex(v_tex, V_COLOR) + tex_mob.set_color_by_tex(w_tex, W_COLOR) equation = VGroup(cross_product, rhs) equation.arrange_submobjects() equation.to_edge(UP) @@ -1297,8 +1297,8 @@ class WriteAreaOfParallelogram(Scene): "Area of ", "parallelogram", " $=$ ", "$2.5$", arg_separator = "" ) - words.highlight_by_tex("parallelogram", BLUE) - words.highlight_by_tex("$2.5$", BLUE) + words.set_color_by_tex("parallelogram", BLUE) + words.set_color_by_tex("$2.5$", BLUE) result = words[-1] words.remove(result) @@ -1312,30 +1312,30 @@ class WriteCrossProductProperties(Scene): v_tex, w_tex, p_tex = texs = get_vect_tex(*"vwp") v_cash, w_cash, p_cash = ["$%s$"%tex for tex in texs] cross_product = TexMobject(v_tex, "\\times", w_tex, "=", p_tex) - cross_product.highlight_by_tex(v_tex, V_COLOR) - cross_product.highlight_by_tex(w_tex, W_COLOR) - cross_product.highlight_by_tex(p_tex, P_COLOR) + cross_product.set_color_by_tex(v_tex, V_COLOR) + cross_product.set_color_by_tex(w_tex, W_COLOR) + cross_product.set_color_by_tex(p_tex, P_COLOR) cross_product.to_edge(UP, buff = LARGE_BUFF) p_mob = cross_product[-1] brace = Brace(p_mob) brace.do_in_place(brace.stretch, 2, 0) vector = brace.get_text("vector") - vector.highlight(P_COLOR) + vector.set_color(P_COLOR) length_words = TextMobject( "Length of ", p_cash, "\\\\ = ", "(parallelogram's area)" ) - length_words.highlight_by_tex(p_cash, P_COLOR) + length_words.set_color_by_tex(p_cash, P_COLOR) length_words.scale_to_fit_width(FRAME_X_RADIUS - 1) - length_words.highlight_by_tex("(parallelogram's area)", BLUE) + length_words.set_color_by_tex("(parallelogram's area)", BLUE) length_words.next_to(VGroup(cross_product, vector), DOWN, buff = LARGE_BUFF) perpendicular = TextMobject( "\\centering Perpendicular to", v_cash, "and", w_cash ) perpendicular.scale_to_fit_width(FRAME_X_RADIUS - 1) - perpendicular.highlight_by_tex(v_cash, V_COLOR) - perpendicular.highlight_by_tex(w_cash, W_COLOR) + perpendicular.set_color_by_tex(v_cash, V_COLOR) + perpendicular.set_color_by_tex(w_cash, W_COLOR) perpendicular.next_to(length_words, DOWN, buff = LARGE_BUFF) @@ -1377,11 +1377,11 @@ class LabelingExampleVectors(Scene): ), ] for eq, color in zip(equations, colors): - eq.highlight(color) + eq.set_color(color) eq.scale(2) area_words = TextMobject("Area", "=4") - area_words[0].highlight(BLUE) + area_words[0].set_color(BLUE) area_words.scale(2) for mob in equations[:2] + [area_words, equations[2]]: self.fade_in_out(mob) @@ -1408,7 +1408,7 @@ class ShowCrossProductFormula(Scene): matrices = map(Matrix, arrays) for matrix in matrices: for entry, color in zip(matrix.get_entries(), colors): - entry.highlight(color) + entry.set_color(color) m1, m2 = matrices cross_product = VGroup(m1, TexMobject("\\times"), m2) cross_product.arrange_submobjects() @@ -1491,8 +1491,8 @@ class DeterminantTrick(Scene): ] v = Matrix(v_terms) w = Matrix(w_terms) - v.highlight(V_COLOR) - w.highlight(W_COLOR) + v.set_color(V_COLOR) + w.set_color(W_COLOR) matrix = Matrix(np.array([ [ TexMobject("\\hat{%s}"%s) @@ -1514,7 +1514,7 @@ class DeterminantTrick(Scene): ## for color, entry in zip(colors, col1): - entry.highlight(color) + entry.set_color(color) det_text = get_det_text(matrix) equals = TexMobject("=") equation = VGroup( @@ -1541,7 +1541,7 @@ class DeterminantTrick(Scene): disclaimer = TextMobject("$^*$ See ``Note on conventions'' in description") disclaimer.scale(0.7) - disclaimer.highlight(RED) + disclaimer.set_color(RED) disclaimer.next_to(equation, DOWN) self.play(FadeIn(disclaimer)) self.wait() @@ -1639,7 +1639,7 @@ class ThereIsAReason(TeacherStudentsScene): "\\centering but there is a\\\\", "reason", "for doing it" ) - words.highlight_by_tex("reason", YELLOW) + words.set_color_by_tex("reason", YELLOW) self.teacher_says(words, target_mode = "surprised") self.change_student_modes( "raise_right_hand", "confused", "raise_left_hand" @@ -1679,7 +1679,7 @@ class CrossAndDualWords(Scene): p_tex, "=", v_tex, "\\times", w_tex ) for tex, color in zip([v_tex, w_tex, p_tex], [U_COLOR, W_COLOR, P_COLOR]): - cross.highlight_by_tex(tex, color) + cross.set_color_by_tex(tex, color) input_array_tex = matrix_to_tex_string(["x", "y", "z"]) func = TexMobject("L\\left(%s\\right) = "%input_array_tex) matrix = Matrix(np.array([ @@ -1687,15 +1687,15 @@ class CrossAndDualWords(Scene): ["v_1", "v_2", "v_3"], ["w_1", "w_2", "w_3"], ]).T) - matrix.highlight_columns(WHITE, U_COLOR, W_COLOR) + matrix.set_color_columns(WHITE, U_COLOR, W_COLOR) det_text = get_det_text(matrix, background_rect = False) det_text.add(matrix) dot_with_cross = TexMobject( "%s \\cdot ( "%input_array_tex, v_tex, "\\times", w_tex, ")" ) - dot_with_cross.highlight_by_tex(v_tex, U_COLOR) - dot_with_cross.highlight_by_tex(w_tex, W_COLOR) + dot_with_cross.set_color_by_tex(v_tex, U_COLOR) + dot_with_cross.set_color_by_tex(w_tex, W_COLOR) transform = VGroup(func, det_text) transform.arrange_submobjects() diff --git a/old_projects/eola/chapter8p2.py b/old_projects/eola/chapter8p2.py index 1b5f7a78..6ba59852 100644 --- a/old_projects/eola/chapter8p2.py +++ b/old_projects/eola/chapter8p2.py @@ -36,12 +36,12 @@ class OpeningQuote(Scene): "in which the proof is obvious.", arg_separator = " " ) - words.highlight_by_tex("difficulty of a proof:", RED) - words.highlight_by_tex("paint a landscape", GREEN) + words.set_color_by_tex("difficulty of a proof:", RED) + words.set_color_by_tex("paint a landscape", GREEN) words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) author = TextMobject("-Pierre Deligne") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -55,13 +55,13 @@ class CrossProductSymbols(Scene): equation = TexMobject( v_tex, "\\times", w_tex, "=", p_tex ) - equation.highlight_by_tex(v_tex, V_COLOR) - equation.highlight_by_tex(w_tex, W_COLOR) - equation.highlight_by_tex(p_tex, P_COLOR) + equation.set_color_by_tex(v_tex, V_COLOR) + equation.set_color_by_tex(w_tex, W_COLOR) + equation.set_color_by_tex(p_tex, P_COLOR) brace = Brace(equation[-1]) brace.stretch_to_fit_width(0.7) vector_text = brace.get_text("Vector") - vector_text.highlight(RED) + vector_text.set_color(RED) self.add(equation) self.play(*map(Write, [brace, vector_text])) self.wait() @@ -75,8 +75,8 @@ class BruteForceVerification(Scene): w = Matrix(["w_1", "w_2", "w_3"]) v1, v2, v3 = v.get_entries() w1, w2, w3 = w.get_entries() - v.highlight(V_COLOR) - w.highlight(W_COLOR) + v.set_color(V_COLOR) + w.set_color(W_COLOR) def get_term(e1, e2, e3, e4): group = VGroup( e1.copy(), e2.copy(), @@ -144,9 +144,9 @@ class BruteForceVerification(Scene): last_point = h_line.get_center()+FRAME_X_RADIUS*RIGHT/2 max_width = FRAME_X_RADIUS-1 for mob in v_dot, w_dot, theta_def, length_check: - mob.highlight_by_tex(v_tex, V_COLOR) - mob.highlight_by_tex(w_tex, W_COLOR) - mob.highlight_by_tex("\\theta", GREEN) + mob.set_color_by_tex(v_tex, V_COLOR) + mob.set_color_by_tex(w_tex, W_COLOR) + mob.set_color_by_tex("\\theta", GREEN) mob.next_to(last_point, DOWN, buff = MED_SMALL_BUFF) if mob.get_width() > max_width: mob.scale_to_fit_width(max_width) @@ -164,7 +164,7 @@ class Prerequisites(Scene): def construct(self): title = TextMobject("Prerequisites") title.to_edge(UP) - title.highlight(YELLOW) + title.set_color(YELLOW) rect = Rectangle(width = 16, height = 9, color = BLUE) rect.scale_to_fit_width(FRAME_X_RADIUS - 1) @@ -212,12 +212,12 @@ class DotProductToTransformSymbol(Scene): } def construct(self): v_mob = TexMobject(get_vect_tex("v")) - v_mob.highlight(V_COLOR) + v_mob.set_color(V_COLOR) matrix = Matrix([self.vect_coords]) vector = Matrix(self.vect_coords) - matrix.highlight_columns(X_COLOR, Y_COLOR) - vector.highlight_columns(YELLOW) + matrix.set_color_columns(X_COLOR, Y_COLOR) + vector.set_color_columns(YELLOW) _input = Matrix(["x", "y"]) _input.get_entries().gradient_highlight(X_COLOR, Y_COLOR) left_input, right_input = [_input.copy() for x in range(2)] @@ -276,7 +276,7 @@ class MathematicalWild(Scene): transformation to the number line """) - bubble.content.highlight(BLUE) + bubble.content.set_color(BLUE) bubble.content.shift(MED_SMALL_BUFF*UP/2) bubble.remove(*bubble[:-1]) bubble.add(bubble.content) @@ -306,7 +306,7 @@ class MathematicalWild(Scene): class ThreeStepPlan(Scene): def construct(self): title = TextMobject("The plan") - title.highlight(YELLOW) + title.set_color(YELLOW) title.to_edge(UP) h_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS) h_line.next_to(title, DOWN) @@ -329,10 +329,10 @@ class ThreeStepPlan(Scene): ) ] linear, transformation = steps[0][1:1+2] - steps[0].highlight_by_tex(v_text, V_COLOR) - steps[0].highlight_by_tex(w_text, W_COLOR) + steps[0].set_color_by_tex(v_text, V_COLOR) + steps[0].set_color_by_tex(w_text, W_COLOR) steps[1][1].gradient_highlight(BLUE, YELLOW) - steps[2].highlight_by_tex(cross_text, P_COLOR) + steps[2].set_color_by_tex(cross_text, P_COLOR) VGroup(*steps).arrange_submobjects( DOWN, aligned_edge = LEFT, buff = LARGE_BUFF ).next_to(h_line, DOWN, buff = MED_SMALL_BUFF) @@ -373,9 +373,9 @@ class ThreeStepPlan(Scene): ["v_%d"%d for d in range(1, 4)], ["w_%d"%d for d in range(1, 4)], ]).T) - matrix.highlight_columns(X_COLOR, V_COLOR, W_COLOR) - matrix.get_mob_matrix()[1, 0].highlight(Y_COLOR) - matrix.get_mob_matrix()[2, 0].highlight(Z_COLOR) + matrix.set_color_columns(X_COLOR, V_COLOR, W_COLOR) + matrix.get_mob_matrix()[1, 0].set_color(Y_COLOR) + matrix.get_mob_matrix()[2, 0].set_color(Z_COLOR) VGroup(*matrix.get_mob_matrix()[1, 1:]).shift(0.15*DOWN) VGroup(*matrix.get_mob_matrix()[2, 1:]).shift(0.35*DOWN) det_text = get_det_text(matrix) @@ -396,7 +396,7 @@ class DefineDualTransform(Scene): title.not_real = TextMobject("Not the real cross product") for mob in title, title.not_real: mob.scale_to_fit_width(FRAME_X_RADIUS - 1) - mob.highlight(RED) + mob.set_color(RED) mob.to_edge(UP) self.add(title) self.title = title @@ -412,8 +412,8 @@ class DefineDualTransform(Scene): defs_equals = VGroup() definitions = VGroup() for array, tex_mob, color in zip(arrays, tex_mobs, colors): - array.highlight_columns(color) - tex_mob.highlight(color) + array.set_color_columns(color) + tex_mob.set_color(color) equals = TexMobject("=") definition = VGroup(tex_mob, equals, array) definition.arrange_submobjects(RIGHT) @@ -566,7 +566,7 @@ class DefineDualTransform(Scene): q_marks.gradient_highlight(*colors) title = VGroup(TextMobject("This function is linear")) - title.highlight(GREEN) + title.set_color(GREEN) title.to_edge(UP) matrix = Matrix([list(q_marks.copy())]) matrix.scale_to_fit_height(self.func_tex.get_height()/2) @@ -627,13 +627,13 @@ class DefineDualTransform(Scene): p_coords = VGroup(*map(TexMobject, [ "p_%d"%d for d in range(1, 4) ])) - p_coords.highlight(RED) + p_coords.set_color(RED) p_array = Matrix(list(p_coords)) p_array.scale_to_fit_height(dual_vector.get_height()) p_array.move_to(dual_vector, aligned_edge = RIGHT) p_brace = Brace(p_array, UP) p_tex = TexMobject(get_vect_tex("p")) - p_tex.highlight(P_COLOR) + p_tex.set_color(P_COLOR) p_brace.put_at_tip(p_tex) self.play( @@ -725,7 +725,7 @@ class DefineDualTransform(Scene): cross_components.next_to(dot_components, RIGHT) for quint in quints: self.play(*[ - ApplyMethod(mob.highlight, YELLOW) + ApplyMethod(mob.set_color, YELLOW) for mob in quint ]) self.wait(0.5) @@ -770,8 +770,8 @@ class DefineDualTransform(Scene): "has \\\\ the property that" ) question.to_edge(UP) - question.highlight(YELLOW) - question.highlight_by_tex(p_tex, P_COLOR) + question.set_color(YELLOW) + question.set_color_by_tex(p_tex, P_COLOR) everything.target = everything.copy() everything.target.next_to( question, DOWN, buff = MED_SMALL_BUFF @@ -827,7 +827,7 @@ class DotProductWords(Scene): p_tex = "$%s$"%get_vect_tex("p") p_mob = TextMobject(p_tex) p_mob.scale(1.5) - p_mob.highlight(P_COLOR) + p_mob.set_color(P_COLOR) input_array = Matrix(list("xyz")) dot_product = VGroup(p_mob, Dot(radius = 0.07), input_array) dot_product.arrange_submobjects(buff = MED_SMALL_BUFF/2) @@ -838,7 +838,7 @@ class DotProductWords(Scene): ("(Length of ", p_tex, ")",) ])) times = TexMobject("\\times") - words[1].highlight_by_tex(p_tex, P_COLOR) + words[1].set_color_by_tex(p_tex, P_COLOR) words[0].next_to(equals, RIGHT) words[1].next_to(words[0], DOWN, aligned_edge = LEFT) times.next_to(words[0], RIGHT) @@ -872,9 +872,9 @@ class GeometricVolumeWords(Scene): "perpendicular to", v_tex, "and", w_tex, ")" ) ) - words[0].highlight_by_tex("parallelogram", BLUE) - words[1].highlight_by_tex(v_tex, ORANGE) - words[1].highlight_by_tex(w_tex, W_COLOR) + words[0].set_color_by_tex("parallelogram", BLUE) + words[1].set_color_by_tex(v_tex, ORANGE) + words[1].set_color_by_tex(w_tex, W_COLOR) words.arrange_submobjects(RIGHT) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(DOWN, buff = SMALL_BUFF) @@ -898,9 +898,9 @@ class CrossVectorEmphasisWords(Scene): TextMobject("Length = (Area of ", "parallelogram", ")") ] for word in words: - word.highlight_by_tex(v_tex, ORANGE) - word.highlight_by_tex(w_tex, W_COLOR) - word.highlight_by_tex("parallelogram", BLUE) + word.set_color_by_tex(v_tex, ORANGE) + word.set_color_by_tex(w_tex, W_COLOR) + word.set_color_by_tex("parallelogram", BLUE) self.play(Write(word)) self.wait() self.play(FadeOut(word)) @@ -968,8 +968,8 @@ class ChangeOfBasisPreview(LinearTransformationScene): ) self.play( randy.change_mode, "erm", - self.i_hat.highlight, self.i_target_color, - self.j_hat.highlight, self.j_target_color, + self.i_hat.set_color, self.i_target_color, + self.j_hat.set_color, self.j_target_color, ) self.i_hat.color = self.i_target_color self.j_hat.color = self.j_target_color diff --git a/old_projects/eola/chapter9.py b/old_projects/eola/chapter9.py index 6b8af7cc..b4ff06e6 100644 --- a/old_projects/eola/chapter9.py +++ b/old_projects/eola/chapter9.py @@ -65,12 +65,12 @@ class OpeningQuote(Scene): ".''", arg_separator = " " ) - words.highlight_by_tex("same name ", BLUE) - words.highlight_by_tex("different things", MAROON_B) + words.set_color_by_tex("same name ", BLUE) + words.set_color_by_tex("different things", MAROON_B) # words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) author = TextMobject("-Henri Poincar\\'e.") - author.highlight(YELLOW) + author.set_color(YELLOW) author.next_to(words, DOWN, buff = 0.5) self.play(FadeIn(words)) @@ -179,7 +179,7 @@ class RemindOfCoordinates(LinearCombinationScene): y_line.shift(x_line.get_end()) for line, coord, direction in (x_line, x_coord, DOWN), (y_line, y_coord, LEFT): self.play( - coord.highlight, line.get_color(), + coord.set_color, line.get_color(), coord.next_to, line.get_center(), direction, ShowCreation(line), ) @@ -195,7 +195,7 @@ class RemindOfCoordinates(LinearCombinationScene): mob.save_state() everything = VGroup(*self.get_mobjects()) words = TextMobject("Think of coordinates \\\\ as", "scalars") - words.highlight_by_tex("scalars", YELLOW) + words.set_color_by_tex("scalars", YELLOW) words.to_edge(UP) x, y = self.vector_coords @@ -236,7 +236,7 @@ class RemindOfCoordinates(LinearCombinationScene): everything = VGroup(*self.get_mobjects()) title = TextMobject("Implicit assumptions") h_line = Line(title.get_left(), title.get_right()) - h_line.highlight(YELLOW) + h_line.set_color(YELLOW) h_line.next_to(title, DOWN) title.add(h_line) @@ -262,7 +262,7 @@ class RemindOfCoordinates(LinearCombinationScene): self.play( Write(ass1), ApplyFunction( - lambda m : m.rotate_in_place(np.pi/6).highlight(X_COLOR), + lambda m : m.rotate_in_place(np.pi/6).set_color(X_COLOR), x_coord, rate_func = wiggle ) @@ -271,7 +271,7 @@ class RemindOfCoordinates(LinearCombinationScene): self.play( Write(ass2), ApplyFunction( - lambda m : m.rotate_in_place(np.pi/6).highlight(Y_COLOR), + lambda m : m.rotate_in_place(np.pi/6).set_color(Y_COLOR), y_coord, rate_func = wiggle ) @@ -303,13 +303,13 @@ class NameCoordinateSystem(Scene): coordinate_system.next_to(arrow, UP, buff = LARGE_BUFF) i_hat, j_hat = Vector([1, 0]), Vector([0, 1]) - i_hat.highlight(X_COLOR) - j_hat.highlight(Y_COLOR) + i_hat.set_color(X_COLOR) + j_hat.set_color(Y_COLOR) i_label = TexMobject("\\hat{\\imath}") - i_label.highlight(X_COLOR) + i_label.set_color(X_COLOR) i_label.next_to(i_hat, DOWN) j_label = TexMobject("\\hat{\\jmath}") - j_label.highlight(Y_COLOR) + j_label.set_color(Y_COLOR) j_label.next_to(j_hat, LEFT) basis_group = VGroup(i_hat, j_hat, i_label, j_label) basis_group.shift(DOWN) @@ -355,7 +355,7 @@ class JenniferScene(LinearCombinationScene): vect.label = TexMobject("\\vec{\\textbf{b}}_%d"%(i+1)) vect.label.scale(0.7) vect.label.add_background_rectangle() - vect.label.highlight(vect.get_color()) + vect.label.set_color(vect.get_color()) self.b1.label.next_to( self.b1.get_end()*0.4, UP+LEFT, SMALL_BUFF/2 ) @@ -555,8 +555,8 @@ class IntroduceJennifer(JenniferScene): new_label2.target = new_label2.copy().next_to(b2.target, LEFT) i_sym = TexMobject("\\hat{\\imath}").add_background_rectangle() j_sym = TexMobject("\\hat{\\jmath}").add_background_rectangle() - i_sym.highlight(X_COLOR).move_to(new_label1.target[1], aligned_edge = LEFT) - j_sym.highlight(Y_COLOR).move_to(new_label2.target[1], aligned_edge = LEFT) + i_sym.set_color(X_COLOR).move_to(new_label1.target[1], aligned_edge = LEFT) + j_sym.set_color(Y_COLOR).move_to(new_label2.target[1], aligned_edge = LEFT) Transform(new_label1.target[1], i_sym).update(1) Transform(new_label2.target[1], j_sym).update(1) sum_vect.target = Vector(numerical_coords) @@ -605,20 +605,20 @@ class IntroduceJennifer(JenniferScene): ) self.play( b1_coords.mover.next_to, self.b1.get_end(), RIGHT, - b1_coords.mover.highlight, X_COLOR + b1_coords.mover.set_color, X_COLOR ) self.play(Blink(you)) self.wait() self.play(Transform(b1_coords, b2_coords)) self.play( b2_coords.mover.next_to, self.b2.get_end(), LEFT, - b2_coords.mover.highlight, Y_COLOR + b2_coords.mover.set_color, Y_COLOR ) self.play(Blink(jenny)) for coords, array in (b1_coords, [1, 0]), (b2_coords, [0, 1]): mover = coords.mover array_mob = Matrix(array) - array_mob.highlight(mover.get_color()) + array_mob.set_color(mover.get_color()) array_mob.scale_to_fit_height(mover.get_height()) array_mob.move_to(mover) array_mob.add_to_back(BackgroundRectangle(array_mob)) @@ -879,8 +879,8 @@ class TranslateFromJenny(JenniferScene): def establish_coordinates(self): b1, b2 = self.basis_vectors_copy[:2] - b1_coords = Matrix(self.b1_coords).highlight(X_COLOR) - b2_coords = Matrix(self.b2_coords).highlight(Y_COLOR) + b1_coords = Matrix(self.b1_coords).set_color(X_COLOR) + b2_coords = Matrix(self.b2_coords).set_color(Y_COLOR) for coords in b1_coords, b2_coords: coords.scale(0.7) coords.add_to_back(BackgroundRectangle(coords)) @@ -941,7 +941,7 @@ class TranslateFromJenny(JenniferScene): self.wait() matrix = Matrix(np.array([self.b1_coords, self.b2_coords]).T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) self.jenny.coords.target = self.jenny.coords.copy() self.jenny.coords.target.next_to(equals, LEFT) matrix.scale_to_fit_height(self.jenny.coords.get_height()) @@ -980,22 +980,22 @@ class TalkThroughChangeOfBasisMatrix(JenniferScene): pi.bubble = get_small_bubble(pi) matrix = Matrix(np.array([self.b1_coords, self.b2_coords]).T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.next_to(ORIGIN, RIGHT, buff = MED_SMALL_BUFF).to_edge(UP) b1_coords = Matrix(self.b1_coords) - b1_coords.highlight(X_COLOR) + b1_coords.set_color(X_COLOR) b1_coords.next_to(self.b1.get_end(), RIGHT) b2_coords = Matrix(self.b2_coords) - b2_coords.highlight(Y_COLOR) + b2_coords.set_color(Y_COLOR) b2_coords.next_to(self.b2.get_end(), UP) for coords in b1_coords, b2_coords: coords.scale_in_place(0.7) basis_coords_pair = VGroup( - Matrix([1, 0]).highlight(X_COLOR).scale(0.7), + Matrix([1, 0]).set_color(X_COLOR).scale(0.7), TexMobject(","), - Matrix([0, 1]).highlight(Y_COLOR).scale(0.7), + Matrix([0, 1]).set_color(Y_COLOR).scale(0.7), ) basis_coords_pair.arrange_submobjects(aligned_edge = DOWN) self.you.bubble.add_content(basis_coords_pair) @@ -1145,16 +1145,16 @@ class FeelsBackwards(Scene): JenniferScene.CONFIG["b1_coords"], JenniferScene.CONFIG["b2_coords"], ]).T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.shift(UP) top_arrow = Arrow(matrix.get_left(), matrix.get_right()) bottom_arrow = top_arrow.copy().rotate(np.pi) top_arrow.next_to(matrix, UP, buff = LARGE_BUFF) bottom_arrow.next_to(matrix, DOWN, buff = LARGE_BUFF) - top_arrow.highlight(BLUE) + top_arrow.set_color(BLUE) - jenny_grid = TextMobject("Jennifer's grid").highlight(BLUE) - our_grid = TextMobject("Our grid").highlight(BLUE) + jenny_grid = TextMobject("Jennifer's grid").set_color(BLUE) + our_grid = TextMobject("Our grid").set_color(BLUE) jenny_language = TextMobject("Jennifer's language") our_language = TextMobject("Our language") @@ -1187,7 +1187,7 @@ class FeelsBackwards(Scene): Swap(jenny_grid, our_grid), top_arrow.scale_in_place, 0.8, top_arrow.shift, 0.8*RIGHT, - top_arrow.highlight, BLUE, + top_arrow.set_color, BLUE, ) self.play( Swap(jenny_language, our_language), @@ -1209,7 +1209,7 @@ class RecallInverse(JenniferScene): numerical_t_matrix = np.array([self.b1_coords, self.b2_coords]) matrix = Matrix(numerical_t_matrix.T) matrix.add_to_back(BackgroundRectangle(matrix)) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.to_corner(UP+LEFT, buff = MED_LARGE_BUFF) # matrix.shift(MED_SMALL_BUFF*DOWN) inverse_exponent = TexMobject("-1") @@ -1254,7 +1254,7 @@ class RecallInverse(JenniferScene): self.play(FadeIn(self.jenny)) self.play(self.jenny.change_mode, "speaking") #Little hacky now - inv_matrix.highlight_columns(X_COLOR) + inv_matrix.set_color_columns(X_COLOR) self.play(*[ ApplyMethod( mob.scale_in_place, 1.2, @@ -1263,7 +1263,7 @@ class RecallInverse(JenniferScene): for mob in inv_matrix.get_mob_matrix()[:,0] ]) self.wait() - inv_matrix.highlight_columns(X_COLOR, Y_COLOR) + inv_matrix.set_color_columns(X_COLOR, Y_COLOR) self.play(*[ ApplyMethod( mob.scale_in_place, 1.2, @@ -1278,8 +1278,8 @@ class WorkOutInverseComputation(Scene): our_vector = Matrix([3, 2]) her_vector = Matrix(["5/3", "1/3"]) matrix = Matrix([["1/3", "1/3"], ["-1/3", "2/3"]]) - our_vector.highlight(BLUE_D) - her_vector.highlight(MAROON_B) + our_vector.set_color(BLUE_D) + her_vector.set_color(MAROON_B) equals = TexMobject("=") equation = VGroup( matrix, our_vector, equals, her_vector @@ -1303,13 +1303,13 @@ class WorkOutInverseComputation(Scene): Written in our language """) - our_text.highlight(our_vector.get_color()) + our_text.set_color(our_vector.get_color()) her_text = her_vector_brace.get_text(""" \\centering Same vector in her language """) - her_text.highlight(her_vector.get_color()) + her_text.set_color(her_vector.get_color()) for text in our_text, her_text: text.scale_in_place(0.7) @@ -1347,7 +1347,7 @@ class SummarizeTranslationProcess(Scene): def define_matrix(self): matrix = Matrix([[2, -1], [1, 1]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) A, equals = map(TexMobject, list("A=")) equation = VGroup(A, equals, matrix) equation.arrange_submobjects() @@ -1374,7 +1374,7 @@ class SummarizeTranslationProcess(Scene): her_vector = Matrix(["x_j", "y_j"]) for vector, color in (our_vector, BLUE_D), (her_vector, MAROON_B): # vector.scale_to_fit_height(1.5) - vector.highlight(color) + vector.set_color(color) A = TexMobject("A") A_inv = TexMobject("A^{-1}") equals = TexMobject("=") @@ -1386,14 +1386,14 @@ class SummarizeTranslationProcess(Scene): A_inv.next_to(our_vector, LEFT) her_words = TextMobject("Vector in her coordinates") - her_words.highlight(her_vector.get_color()) + her_words.set_color(her_vector.get_color()) her_words.scale(0.8).to_corner(UP+RIGHT) her_arrow = Arrow( her_words, her_vector, color = her_vector.get_color() ) our_words = TextMobject("Same vector in\\\\ our coordinates") - our_words.highlight(our_vector.get_color()) + our_words.set_color(our_vector.get_color()) our_words.scale(0.8).to_edge(RIGHT).shift(2*DOWN) our_words.shift_onto_screen() our_arrow = Arrow( @@ -1449,7 +1449,7 @@ class Prerequisites(Scene): rect = Rectangle(height = 9, width = 16) rect.scale_to_fit_height(3.5) rect.next_to(ORIGIN, direction, buff = MED_SMALL_BUFF) - rect.highlight(BLUE) + rect.set_color(BLUE) words.next_to(rect, UP, buff = MED_SMALL_BUFF) self.play( Write(words), @@ -1468,7 +1468,7 @@ class RotationExample(LinearTransformationScene): words.to_edge(UP) matrix = Matrix(self.t_matrix.T) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.rect = BackgroundRectangle(matrix) matrix.add_to_back(matrix.rect) matrix.next_to(words, DOWN) @@ -1492,7 +1492,7 @@ class RotationExample(LinearTransformationScene): coords.scale(0.7) coords.rect = BackgroundRectangle(coords) coords.add_to_back(coords.rect) - coords.highlight(vect.get_color()) + coords.set_color(vect.get_color()) direction = UP if vect is self.j_hat else RIGHT coords.next_to(vect.get_end(), direction, buff = MED_SMALL_BUFF) self.play(Write(coords)) @@ -1522,7 +1522,7 @@ class RotationExample(LinearTransformationScene): "Follow", "our choice", "\\\\ of basis vectors" ) - follow_basis.highlight_by_tex("our choice", YELLOW) + follow_basis.set_color_by_tex("our choice", YELLOW) follow_basis.add_background_rectangle() follow_basis.next_to( matrix, LEFT, @@ -1533,7 +1533,7 @@ class RotationExample(LinearTransformationScene): "Record using \\\\", "our coordinates" ) - record.highlight_by_tex("our coordinates", YELLOW) + record.set_color_by_tex("our coordinates", YELLOW) record.add_background_rectangle() record.next_to( matrix, DOWN, @@ -1580,7 +1580,7 @@ class JennyWatchesRotation(JenniferScene): class AksAboutTranslatingColumns(TeacherStudentsScene): def construct(self): matrix = Matrix([[0, -1], [1, 0]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.scale(0.7) words = TextMobject("Translate columns of") matrix.next_to(words, DOWN) @@ -1609,8 +1609,8 @@ class AksAboutTranslatingColumns(TeacherStudentsScene): "our basis", ", not ", "hers", arg_separator = "" ) - words.highlight_by_tex("our basis", BLUE) - words.highlight_by_tex("hers", MAROON_B) + words.set_color_by_tex("our basis", BLUE) + words.set_color_by_tex("hers", MAROON_B) self.teacher_says(words) self.change_student_modes("erm", "pondering", "pondering") self.random_blink() @@ -1639,13 +1639,13 @@ class HowToTranslateAMatrix(Scene): submobs = array.split() submobs.sort(lambda m1, m2: cmp(m1.get_center()[0], m2.get_center()[0])) array.submobjects = submobs - her_vector.highlight(MAROON_B) + her_vector.set_color(MAROON_B) cob_matrix.gradient_highlight(BLUE, MAROON_B) - transform.highlight_columns(X_COLOR, Y_COLOR) - transform.get_brackets().highlight(BLUE) + transform.set_color_columns(X_COLOR, Y_COLOR) + transform.get_brackets().set_color(BLUE) inv_cob.gradient_highlight(MAROON_B, BLUE) - result.highlight_columns(X_COLOR, Y_COLOR) - result.get_brackets().highlight(MAROON_B) + result.set_color_columns(X_COLOR, Y_COLOR) + result.get_brackets().set_color(MAROON_B) final_top_brace = Brace(VGroup(cob_matrix, inv_cob), UP) @@ -1664,8 +1664,8 @@ class HowToTranslateAMatrix(Scene): text_args = list(text_args) text_args[0] = "\\centering " + text_args[0] text = TextMobject(*text_args) - text.highlight_by_tex("our", BLUE) - text.highlight_by_tex("her", MAROON_B) + text.set_color_by_tex("our", BLUE) + text.set_color_by_tex("her", MAROON_B) brace.put_at_tip(text) brace.text = text @@ -1706,7 +1706,7 @@ class HowToTranslateAMatrix(Scene): #Genearlize to single matrix v = TexMobject("\\vec{\\textbf{v}}") - v.highlight(her_vector.get_color()) + v.set_color(her_vector.get_color()) v.move_to(her_vector, aligned_edge = LEFT) self.play( Transform(her_vector, v), @@ -1753,12 +1753,12 @@ class JennyWatchesRotationWithMatrixAndVector(JenniferScene): self.add(self.jenny_plane, self.jenny, self.b1, self.b2) matrix = Matrix([["1/3", "-2/3"], ["5/3", "-1/3"]]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) matrix.to_corner(UP+LEFT) vector_coords = [1, 2] vector_array = Matrix(vector_coords) - vector_array.highlight(YELLOW) + vector_array.set_color(YELLOW) vector_array.next_to(matrix, RIGHT) result = Matrix([-1, 1]) @@ -1800,12 +1800,12 @@ class MathematicalEmpathy(TeacherStudentsScene): ) A1, neg, one, M, A2 = words[1] As = VGroup(A1, neg, one, A2) - VGroup(As, M).highlight(YELLOW) + VGroup(As, M).set_color(YELLOW) self.teacher_says(words) self.random_blink() for mob, color in (M, BLUE), (As, MAROON_B): - self.play(mob.highlight, color) + self.play(mob.set_color, color) self.play(mob.scale_in_place, 1.2, rate_func = there_and_back) self.random_blink(2) diff --git a/old_projects/eola/footnote.py b/old_projects/eola/footnote.py index f440ad66..2a6fc425 100644 --- a/old_projects/eola/footnote.py +++ b/old_projects/eola/footnote.py @@ -35,11 +35,11 @@ class OpeningQuote(Scene): ]) words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) - words.split()[0].highlight(YELLOW) - words.split()[2].highlight(YELLOW) + words.split()[0].set_color(YELLOW) + words.split()[2].set_color(YELLOW) three_d = words.submobjects.pop() - three_d.highlight(BLUE) + three_d.set_color(BLUE) self.play(FadeIn(words)) self.play(Write(three_d)) self.wait(2) @@ -73,18 +73,18 @@ class SymbolicThreeDTransform(Scene): def construct(self): in_vect = Matrix(self.input_coords) out_vect = Matrix(self.output_coords) - in_vect.highlight(BLUE) - out_vect.highlight(GREEN) + in_vect.set_color(BLUE) + out_vect.set_color(GREEN) func = TexMobject("L(\\vec{\\textbf{v}})") point = VectorizedPoint(func.get_center()) in_vect.next_to(func, LEFT, buff = 1) out_vect.next_to(func, RIGHT, buff = 1) in_words = TextMobject("Input") in_words.next_to(in_vect, DOWN) - in_words.highlight(BLUE_C) + in_words.set_color(BLUE_C) out_words = TextMobject("Output") out_words.next_to(out_vect, DOWN) - out_words.highlight(GREEN_C) + out_words.set_color(GREEN_C) title = TextMobject(self.title) @@ -122,7 +122,7 @@ class IHatJHatKHatWritten(Scene): for char, color in zip(["\\imath", "\\jmath", "k"], [X_COLOR, Y_COLOR, Z_COLOR]): sym = TexMobject("{\\hat{%s}}"%char) sym.scale(3) - sym.highlight(color) + sym.set_color(color) self.play(Write(sym)) self.wait() self.clear() @@ -134,24 +134,24 @@ class PutTogether3x3Matrix(Scene): "col3" : [1, 0, 1], } def construct(self): - i_to = TexMobject("\\hat{\\imath} \\to").highlight(X_COLOR) - j_to = TexMobject("\\hat{\\jmath} \\to").highlight(Y_COLOR) - k_to = TexMobject("\\hat{k} \\to").highlight(Z_COLOR) + i_to = TexMobject("\\hat{\\imath} \\to").set_color(X_COLOR) + j_to = TexMobject("\\hat{\\jmath} \\to").set_color(Y_COLOR) + k_to = TexMobject("\\hat{k} \\to").set_color(Z_COLOR) i_array = Matrix(self.col1) j_array = Matrix(self.col2) k_array = Matrix(self.col3) everything = VMobject( - i_to, i_array, TexMobject("=").highlight(BLACK), - j_to, j_array, TexMobject("=").highlight(BLACK), - k_to, k_array, TexMobject("=").highlight(BLACK), + i_to, i_array, TexMobject("=").set_color(BLACK), + j_to, j_array, TexMobject("=").set_color(BLACK), + k_to, k_array, TexMobject("=").set_color(BLACK), ) everything.arrange_submobjects(RIGHT, buff = 0.1) everything.scale_to_fit_width(FRAME_WIDTH-1) everything.to_edge(DOWN) - i_array.highlight(X_COLOR) - j_array.highlight(Y_COLOR) - k_array.highlight(Z_COLOR) + i_array.set_color(X_COLOR) + j_array.set_color(Y_COLOR) + k_array.set_color(Z_COLOR) arrays = [i_array, j_array, k_array] matrix = Matrix(reduce( lambda a1, a2 : np.append(a1, a2, axis = 1), @@ -205,7 +205,7 @@ class ShowVCoordinateMeaning(Scene): } def construct(self): v = TexMobject(self.v_str) - v.highlight(YELLOW) + v.set_color(YELLOW) eq = TexMobject("=") coords = Matrix(["x", "y", "z"]) eq2 = eq.copy() @@ -232,9 +232,9 @@ class ShowVCoordinateMeaning(Scene): new_x, new_y, new_z = lin_comb_parts[[0, 3, 6]] i, j, k = lin_comb_parts[[1, 4, 7]] plusses = lin_comb_parts[[2, 5]] - i.highlight(X_COLOR) - j.highlight(Y_COLOR) - k.highlight(Z_COLOR) + i.set_color(X_COLOR) + j.set_color(Y_COLOR) + k.set_color(Z_COLOR) everything = VMobject(v, eq, coords, eq2, lin_comb) everything.arrange_submobjects(buff = 0.2) @@ -319,11 +319,11 @@ class ShowMatrixVectorMultiplication(Scene): for o_col, col, start_coord, coord, sym, color in sexts: o_col = VMobject(*o_col) self.play( - start_coord.highlight, YELLOW, - o_col.highlight, color + start_coord.set_color, YELLOW, + o_col.set_color, color ) - coord.highlight(YELLOW) - col.highlight(color) + coord.set_color(YELLOW) + col.set_color(color) self.play( Write(col.get_brackets()), Transform( @@ -345,8 +345,8 @@ class ShowMatrixMultiplication(Scene): right = Matrix(np.arange(9).reshape((3, 3))) left = Matrix(np.random.random_integers(-5, 5, (3, 3))) VMobject(left, right).arrange_submobjects(buff = 0.1) - right.highlight_columns(X_COLOR, Y_COLOR, Z_COLOR) - left.highlight(PINK) + right.set_color_columns(X_COLOR, Y_COLOR, Z_COLOR) + left.set_color(PINK) trips = [ (right, DOWN, "First transformation"), @@ -404,7 +404,7 @@ class SymbolicThreeDToTwoDTransform(SymbolicThreeDTransform): class QuestionsToPonder(Scene): def construct(self): title = TextMobject("Questions to ponder") - title.highlight(YELLOW).to_edge(UP) + title.set_color(YELLOW).to_edge(UP) self.add(title) questions = VMobject(*map(TextMobject, [ "1. Can you visualize these transformations?", diff --git a/old_projects/eola/footnote2.py b/old_projects/eola/footnote2.py index 04d5197f..64e1afd9 100644 --- a/old_projects/eola/footnote2.py +++ b/old_projects/eola/footnote2.py @@ -32,9 +32,9 @@ class OpeningQuote(Scene): ) words.scale_to_fit_width(FRAME_WIDTH - 2) words.to_edge(UP) - words[1].highlight(GREEN) + words[1].set_color(GREEN) author = TextMobject("-(Via mathprofessorquotes.com, no name listed)") - author.highlight(YELLOW) + author.set_color(YELLOW) author.scale(0.7) author.next_to(words, DOWN, buff = 0.5) @@ -60,13 +60,13 @@ class ColumnsRepresentBasisVectors(Scene): TextMobject("Where $\\hat{\\%smath}$ lands"%char) for char in "i", "j" ] - i_hat_words.highlight(X_COLOR) + i_hat_words.set_color(X_COLOR) i_hat_words.next_to(ORIGIN, LEFT).to_edge(UP) - j_hat_words.highlight(Y_COLOR) + j_hat_words.set_color(Y_COLOR) j_hat_words.next_to(ORIGIN, RIGHT).to_edge(UP) question = TextMobject("How to interpret?") question.next_to(matrix, UP) - question.highlight(YELLOW) + question.set_color(YELLOW) self.add(matrix) self.play(Write(question, run_time = 2)) @@ -82,7 +82,7 @@ class ColumnsRepresentBasisVectors(Scene): Write(words, run_time = 1), ShowCreation(arrow), *[ - ApplyMethod(m.highlight, words.get_color()) + ApplyMethod(m.set_color, words.get_color()) for m in matrix.get_mob_matrix()[:,i] ] ) @@ -114,11 +114,11 @@ class Symbolic2To3DTransform(Scene): def construct(self): func = TexMobject("L(", "\\vec{\\textbf{v}}", ")") input_array = Matrix([2, 7]) - input_array.highlight(YELLOW) + input_array.set_color(YELLOW) in_arrow = Arrow(LEFT, RIGHT, color = input_array.get_color()) - func[1].highlight(input_array.get_color()) + func[1].set_color(input_array.get_color()) output_array = Matrix([1, 8, 2]) - output_array.highlight(PINK) + output_array.set_color(PINK) out_arrow = Arrow(LEFT, RIGHT, color = output_array.get_color()) VMobject( input_array, in_arrow, func, out_arrow, output_array @@ -128,8 +128,8 @@ class Symbolic2To3DTransform(Scene): input_words = input_brace.get_text("2d input") output_brace = Brace(output_array, UP) output_words = output_brace.get_text("3d output") - input_words.highlight(input_array.get_color()) - output_words.highlight(output_array.get_color()) + input_words.set_color(input_array.get_color()) + output_words.set_color(output_array.get_color()) self.add(func, input_array) @@ -185,14 +185,14 @@ class DescribeColumnsInSpecificTransformation(Scene): [-1, 1], [-2, 1], ]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) mob_matrix = matrix.get_mob_matrix() i_col, j_col = [VMobject(*mob_matrix[:,i]) for i in 0, 1] for col, char, vect in zip([i_col, j_col], ["i", "j"], [UP, DOWN]): color = col[0].get_color() col.words = TextMobject("Where $\\hat\\%smath$ lands"%char) col.words.next_to(matrix, vect, buff = LARGE_BUFF) - col.words.highlight(color) + col.words.set_color(color) col.arrow = Arrow( col.words.get_edge_center(-vect), col.get_edge_center(vect), @@ -216,13 +216,13 @@ class CountRowsAndColumns(Scene): [-1, 1], [-2, 1], ]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) rows_brace = Brace(matrix, LEFT) rows_words = rows_brace.get_text("3", "rows") - rows_words.highlight(PINK) + rows_words.set_color(PINK) cols_brace = Brace(matrix, UP) cols_words = cols_brace.get_text("2", "columns") - cols_words.highlight(TEAL) + cols_words.set_color(TEAL) title = TexMobject("3", "\\times", "2", "\\text{ matrix}") title.to_edge(UP) @@ -250,7 +250,7 @@ class WriteColumnSpaceDefinition(Scene): [-1, 1], [-2, 1], ]) - matrix.highlight_columns(X_COLOR, Y_COLOR) + matrix.set_color_columns(X_COLOR, Y_COLOR) brace = Brace(matrix) words = VMobject( @@ -260,8 +260,8 @@ class WriteColumnSpaceDefinition(Scene): ) words.arrange_submobjects(DOWN, buff = 0.1) words.next_to(brace, DOWN) - words[0][0].highlight(PINK) - words[2].highlight(TEAL) + words[0][0].set_color(PINK) + words[2].set_color(TEAL) words[0].add_background_rectangle() words[2].add_background_rectangle() VMobject(matrix, brace, words).center() @@ -297,7 +297,7 @@ class MatrixInTheWild(Scene): ShowCreation(bubble), randy.change_mode, "pondering" ) - # self.play(matrix.highlight_columns, X_COLOR, Y_COLOR) + # self.play(matrix.set_color_columns, X_COLOR, Y_COLOR) self.wait() for x in range(3): self.play(Blink(randy)) @@ -325,12 +325,12 @@ class MatrixInTheWild(Scene): 2 coordinates for each landing spots """) - side_words.highlight(YELLOW) + side_words.set_color(YELLOW) self.play( GrowFromCenter(top_brace), Write(top_words), - matrix.highlight_columns, X_COLOR, Y_COLOR, Z_COLOR + matrix.set_color_columns, X_COLOR, Y_COLOR, Z_COLOR ) self.play(randy.change_mode, "happy") self.play( @@ -395,11 +395,11 @@ class Symbolic2To1DTransform(Scene): def construct(self): func = TexMobject("L(", "\\vec{\\textbf{v}}", ")") input_array = Matrix([2, 7]) - input_array.highlight(YELLOW) + input_array.set_color(YELLOW) in_arrow = Arrow(LEFT, RIGHT, color = input_array.get_color()) - func[1].highlight(input_array.get_color()) + func[1].set_color(input_array.get_color()) output_array = Matrix([1.8]) - output_array.highlight(PINK) + output_array.set_color(PINK) out_arrow = Arrow(LEFT, RIGHT, color = output_array.get_color()) VMobject( input_array, in_arrow, func, out_arrow, output_array @@ -409,8 +409,8 @@ class Symbolic2To1DTransform(Scene): input_words = input_brace.get_text("2d input") output_brace = Brace(output_array, UP) output_words = output_brace.get_text("1d output") - input_words.highlight(input_array.get_color()) - output_words.highlight(output_array.get_color()) + input_words.set_color(input_array.get_color()) + output_words.set_color(output_array.get_color()) self.add(func, input_array) @@ -480,7 +480,7 @@ class TwoDTo1DTransform(LinearTransformationScene): ) direction = UP if vect is self.i_hat else DOWN vect.words.next_to(vect.get_end(), direction, buff = LARGE_BUFF) - vect.words.highlight(vect.get_color()) + vect.words.set_color(vect.get_color()) matrix = Matrix([[1, 2]]) matrix_words = TextMobject("Transformation matrix: ") matrix_group = VMobject(matrix_words, matrix) @@ -562,8 +562,8 @@ class DotProductPreview(VectorScene): def add_symbols(self): - v = matrix_to_mobject(self.v_coords).highlight(self.v_color) - w = matrix_to_mobject(self.w_coords).highlight(self.w_color) + v = matrix_to_mobject(self.v_coords).set_color(self.v_color) + w = matrix_to_mobject(self.w_coords).set_color(self.w_color) v.add_background_rectangle() w.add_background_rectangle() dot = TexMobject("\\cdot") @@ -583,7 +583,7 @@ class DotProductPreview(VectorScene): line.rotate(self.v.get_angle()) self.play(Write(line), Animation(self.v)) self.play( - line.highlight, self.v.get_color(), + line.set_color, self.v.get_color(), Animation(self.v), rate_func = there_and_back ) @@ -623,8 +623,8 @@ class DotProductPreview(VectorScene): ("\\text{Scale by }", "||\\vec{\\textbf{v}}||",), ("\\text{Length of}", "\\text{ scaled projection}",), ])) - length_texs[1][1].highlight(self.v_color) - length_texs[2][1].highlight(self.w_color) + length_texs[1][1].set_color(self.v_color) + length_texs[2][1].set_color(self.w_color) for brace, tex_mob in zip(braces, length_texs): tex_mob.add_background_rectangle() brace.put_at_tip(tex_mob, buff = SMALL_BUFF) diff --git a/old_projects/eola/thumbnails.py b/old_projects/eola/thumbnails.py index ac91416a..a419b63f 100644 --- a/old_projects/eola/thumbnails.py +++ b/old_projects/eola/thumbnails.py @@ -39,7 +39,7 @@ class Chapter1(Scene): arrow = Vector(2*UP+RIGHT) vs = TextMobject("vs.") array = Matrix([1, 2]) - array.highlight(TEAL) + array.set_color(TEAL) everyone = VMobject(arrow, vs, array) everyone.arrange_submobjects(RIGHT, buff = 0.5) everyone.scale_to_fit_height(4) @@ -129,8 +129,8 @@ class Chapter10(LinearTransformationScene): def construct(self): v_tex = "\\vec{\\textbf{v}}" eq = TexMobject("A", v_tex, "=", "\\lambda", v_tex) - eq.highlight_by_tex(v_tex, YELLOW) - eq.highlight_by_tex("\\lambda", MAROON_B) + eq.set_color_by_tex(v_tex, YELLOW) + eq.set_color_by_tex("\\lambda", MAROON_B) eq.scale(3) eq.add_background_rectangle() eq.shift(2*DOWN) @@ -141,9 +141,9 @@ class Chapter10(LinearTransformationScene): , arg_separator = "") title.scale(2.5) title.to_edge(UP) - # title.highlight_by_tex("Eigen", MAROON_B) - title[0].highlight(YELLOW) - title[2].highlight(MAROON_B) + # title.set_color_by_tex("Eigen", MAROON_B) + title[0].set_color(YELLOW) + title[2].set_color(MAROON_B) title.add_background_rectangle() diff --git a/old_projects/eulers_characteristic_formula.py b/old_projects/eulers_characteristic_formula.py index 26a01af9..1a2a299c 100644 --- a/old_projects/eulers_characteristic_formula.py +++ b/old_projects/eulers_characteristic_formula.py @@ -49,7 +49,7 @@ class PreferOtherProofDialogue(Scene): self.add(student, teacher, teacher_bubble, teacher_bubble.text) self.wait(2) self.play(Transform( - Dot(student_bubble.tip).highlight("black"), + Dot(student_bubble.tip).set_color("black"), Mobject(student_bubble, student_bubble.text) )) self.wait(2) @@ -110,7 +110,7 @@ class IntroduceGraph(GraphScene): connected, planar, graph = TextMobject([ "Connected ", "Planar ", "Graph" ]).to_edge(UP).split() - not_okay = TextMobject("Not Okay").highlight("red") + not_okay = TextMobject("Not Okay").set_color("red") planar_explanation = TextMobject(""" (``Planar'' just means we can draw it without intersecting lines) @@ -183,7 +183,7 @@ class PlanarGraphDefinition(Scene): # "no matter how \\\\ hard you try" ]).split() shift_val = Mobject(Not, planar).to_corner().get_center() - Not.highlight("red").shift(shift_val) + Not.set_color("red").shift(shift_val) graphs = [ Mobject(*GraphScene(g).mobjects) for g in [ @@ -205,10 +205,10 @@ class PlanarGraphDefinition(Scene): self.wait() self.remove(graphs[0]) self.add(graphs[1]) - planar.highlight("red") + planar.set_color("red") self.add(Not) self.wait(2) - planar.highlight("white") + planar.set_color("white") self.remove(Not) self.remove(graphs[1]) self.add(graphs[2]) @@ -258,7 +258,7 @@ class TerminologyFromPolyhedra(GraphScene): self.remove(dots_to_vertices, *self.vertices) self.add(lines_to_edges) self.play(ApplyMethod( - Mobject(*self.edges).highlight, "yellow" + Mobject(*self.edges).set_color, "yellow" )) self.wait(2) self.clear() @@ -266,7 +266,7 @@ class TerminologyFromPolyhedra(GraphScene): self.add(regions_to_faces) self.generate_regions() for region in self.regions: - self.highlight_region(region) + self.set_color_region(region) self.wait(3.0) @@ -284,9 +284,9 @@ class ThreePiecesOfTerminology(GraphScene): self.generate_spanning_tree() scale_factor = 1.2 def accent(mobject, color = "yellow"): - return mobject.scale_in_place(scale_factor).highlight(color) + return mobject.scale_in_place(scale_factor).set_color(color) def tone_down(mobject): - return mobject.scale_in_place(1.0/scale_factor).highlight("white") + return mobject.scale_in_place(1.0/scale_factor).set_color("white") self.add(accent(cycles)) self.trace_cycle(run_time = 1.0) @@ -337,7 +337,7 @@ class WalkingRandolph(GraphScene): for next, last in zip(point_path[1:], point_path): self.play( WalkPiCreature(randy, next), - ShowCreation(Line(last, next).highlight("yellow")), + ShowCreation(Line(last, next).set_color("yellow")), run_time = 2.0 ) self.randy = randy @@ -355,8 +355,8 @@ class PathExamples(GraphScene): [(0, 1), (7, 8), (5, 6),], [(5, 0), (0, 2), (0, 1)], ] - valid_path = TextMobject("Valid \\\\ Path").highlight("green") - not_a_path = TextMobject("Not a \\\\ Path").highlight("red") + valid_path = TextMobject("Valid \\\\ Path").set_color("green") + not_a_path = TextMobject("Not a \\\\ Path").set_color("red") for mob in valid_path, not_a_path: mob.to_edge(UP) kwargs = {"run_time" : 1.0} @@ -365,14 +365,14 @@ class PathExamples(GraphScene): Line( self.points[path[i]], self.points[path[i+1]] - ).highlight("yellow") + ).set_color("yellow") for i in range(len(path) - 1) ]) non_path_lines = Mobject(*[ Line( self.points[pp[0]], self.points[pp[1]], - ).highlight("yellow") + ).set_color("yellow") for pp in non_path ]) @@ -404,7 +404,7 @@ class IntroduceCycle(WalkingRandolph): for cycle in encompassed_cycles ] for region in regions: - self.highlight_region(region) + self.set_color_region(region) self.wait() @@ -463,7 +463,7 @@ class DefineSpanningTree(GraphScene): Line( self.points[pair[0]], self.points[pair[1]] - ).highlight("yellow"), + ).set_color("yellow"), run_time = run_time_per_branch )) self.play(ShowCreation( @@ -475,7 +475,7 @@ class DefineSpanningTree(GraphScene): unneeded_edges = filter(out_of_spanning_set, self.graph.edges) for edge, limit in zip(unneeded_edges, range(5)): line = Line(self.points[edge[0]], self.points[edge[1]]) - line.highlight("red") + line.set_color("red") self.play(ShowCreation(line, run_time = 1.0)) self.add(unneeded.center().shift(line.get_center() + 0.2*UP)) self.wait() @@ -602,7 +602,7 @@ class FacebookGraphAsAbstractSet(Scene): lines = Mobject( Line(UP*FRAME_Y_RADIUS, DOWN*FRAME_Y_RADIUS), Line(LEFT*FRAME_X_RADIUS + 3*UP, RIGHT*FRAME_X_RADIUS + 3*UP) - ).highlight("white") + ).set_color("white") self.add(accounts, friendships, lines) self.wait() @@ -699,12 +699,12 @@ class ExamplesOfGraphs(GraphScene): def handle_dual_graph(self, words1, words2): - words1.highlight("yellow") - words2.highlight("yellow") + words1.set_color("yellow") + words2.set_color("yellow") connected = TextMobject("Connected") - connected.highlight("lightgreen") + connected.set_color("lightgreen") not_connected = TextMobject("Not Connected") - not_connected.highlight("red") + not_connected.set_color("red") for mob in connected, not_connected: mob.shift(self.points[3] + UP) @@ -714,7 +714,7 @@ class ExamplesOfGraphs(GraphScene): ]) self.wait() for region in self.regions: - self.highlight_region(region) + self.set_color_region(region) self.add(words1) self.wait() self.reset_background() @@ -736,7 +736,7 @@ class ExamplesOfGraphs(GraphScene): break for cycle in cycle1, cycle2: index = self.graph.region_cycles.index(cycle) - self.highlight_region(self.regions[index]) + self.set_color_region(self.regions[index]) if want_matching: self.remove(not_connected) self.add(connected) @@ -744,7 +744,7 @@ class ExamplesOfGraphs(GraphScene): if tup not in self.graph.edges: tup = tuple(reversed(tup)) edge = deepcopy(self.edges[self.graph.edges.index(tup)]) - edge.highlight("red") + edge.set_color("red") self.play(ShowCreation(edge), run_time = 1.0) self.wait() self.remove(edge) @@ -768,7 +768,7 @@ class DrawDualGraph(GraphScene): for reg in self.regions ] for region, mob in zip(self.regions, region_mobs): - self.highlight_region(region, mob.get_color()) + self.set_color_region(region, mob.get_color()) outer_region = self.regions.pop() outer_region_mob = region_mobs.pop() outer_dual_vertex = self.dual_vertices.pop() @@ -786,7 +786,7 @@ class DrawDualGraph(GraphScene): self.wait() self.reset_background() - self.highlight_region(outer_region, outer_region_mob.get_color()) + self.set_color_region(outer_region, outer_region_mob.get_color()) self.play(*[ Transform(reg_mob, dot) for reg_mob, dot in zip(region_mobs, self.dual_vertices) @@ -855,9 +855,9 @@ class ListOfCorrespondances(Scene): lines.append(Mobject(left, right, this_arrow)) last = None for line in lines: - self.add(line.highlight("yellow")) + self.add(line.set_color("yellow")) if last: - last.highlight("white") + last.set_color("white") last = line self.wait(1) @@ -879,7 +879,7 @@ class CyclesCorrespondWithConnectedComponents(GraphScene): lines_to_remove = [] for last, next in zip(cycle, cycle[1:]): line = Line(self.points[last], self.points[next]) - line.highlight("yellow") + line.set_color("yellow") self.play( ShowCreation(line), WalkPiCreature(randy, self.points[next]), @@ -889,22 +889,22 @@ class CyclesCorrespondWithConnectedComponents(GraphScene): self.wait() self.remove(randy, *lines_to_remove) for region in np.array(self.regions)[enclosed_regions]: - self.highlight_region(region) + self.set_color_region(region) self.wait(2) self.reset_background() lines = Mobject(*[ Line(self.dual_points[last], self.dual_points[next]) for last, next in zip(dual_cycle, dual_cycle[1:]) - ]).highlight("red") + ]).set_color("red") self.play(ShowCreation(lines)) self.play(*[ Transform(v, Dot( v.get_center(), radius = 3*Dot.DEFAULT_RADIUS - ).highlight("green")) + ).set_color("green")) for v in np.array(self.vertices)[enclosed_vertices] ] + [ - ApplyMethod(self.edges[0].highlight, "green") + ApplyMethod(self.edges[0].set_color, "green") ]) self.wait() @@ -922,7 +922,7 @@ class IntroduceMortimer(GraphScene): randy_path = (0, 1, 3) morty_path = (-2, -3, -4) morty_crossed_lines = [ - Line(self.points[i], self.points[j]).highlight("red") + Line(self.points[i], self.points[j]).set_color("red") for i, j in [(7, 1), (1, 5)] ] kwargs = {"run_time" : 1.0} @@ -947,14 +947,14 @@ class IntroduceMortimer(GraphScene): self.wait() - self.highlight_region(self.regions[morty_path[0]]) + self.set_color_region(self.regions[morty_path[0]]) for last, next in zip(morty_path, morty_path[1:]): self.play(WalkPiCreature(morty, self.dual_points[next]),**kwargs) - self.highlight_region(self.regions[next]) + self.set_color_region(self.regions[next]) self.wait() for last, next in zip(randy_path, randy_path[1:]): line = Line(self.points[last], self.points[next]) - line.highlight("yellow") + line.set_color("yellow") self.play( WalkPiCreature(randy, self.points[next]), ShowCreation(line), @@ -1004,19 +1004,19 @@ class RandolphMortimerSpanningTreeGame(GraphScene): # ShowCreation(Line( # midpoint, # tip - # ).highlight("red")) + # ).set_color("red")) # for tip in edge.start, edge.end # ], run_time = time_per_dual_edge) - self.highlight_region(self.regions[region_ordering[index]]) + self.set_color_region(self.regions[region_ordering[index]]) self.wait(time_per_dual_edge) self.wait() cycle_index = region_ordering[-1] cycle = self.graph.region_cycles[cycle_index] - self.highlight_region(self.regions[cycle_index], "black") + self.set_color_region(self.regions[cycle_index], "black") self.play(ShowCreation(Mobject(*[ - Line(self.points[last], self.points[next]).highlight("green") + Line(self.points[last], self.points[next]).set_color("green") for last, next in zip(cycle, list(cycle)[1:] + [cycle[0]]) ]))) self.wait() @@ -1042,7 +1042,7 @@ class MortimerCannotTraverseCycle(GraphScene): kwargs = {"run_time" : time_per_edge, "rate_func" : None} for last, next in zip(dual_cycle, dual_cycle[1:]): line = Line(self.dual_points[last], self.dual_points[next]) - line.highlight("red") + line.set_color("red") self.play( WalkPiCreature(morty, self.dual_points[next], **kwargs), ShowCreation(line, **kwargs), @@ -1066,7 +1066,7 @@ class MortimerCannotTraverseCycle(GraphScene): ]) self.add(text) self.play(*[ - Transform(line, deepcopy(edge).highlight(line.get_color())) + Transform(line, deepcopy(edge).set_color(line.get_color())) for line, edge in zip(all_lines, matching_edges) ]) self.wait() @@ -1095,7 +1095,7 @@ class TwoPropertiesOfSpanningTree(Scene): explanation.get_center() + vect, tail = word.get_center() - vect, )) - self.play(ApplyMethod(word.highlight, "yellow")) + self.play(ApplyMethod(word.set_color, "yellow")) self.wait() @@ -1118,7 +1118,7 @@ class DualSpanningTree(GraphScene): self.add(self.spanning_tree, randy, morty) self.play(ShowCreation(Mobject( *np.array(self.edges)[dual_edges] - ).highlight("red"))) + ).set_color("red"))) self.add(words) self.wait() diff --git a/old_projects/fourier.py b/old_projects/fourier.py index 871c7302..b024e70c 100644 --- a/old_projects/fourier.py +++ b/old_projects/fourier.py @@ -59,7 +59,7 @@ def get_fourier_graph( ) for x, y in zip(frequencies, fft_output[:n_samples//2]) ]) - graph.highlight(color) + graph.set_color(color) f_min, f_max = [ axes.x_axis.point_to_number(graph.points[i]) for i in 0, -1 @@ -97,14 +97,14 @@ class Introduction(TeacherStudentsScene): graph.stretch(0.25, 1) graph.next_to(title, DOWN) graph.to_edge(LEFT) - graph.highlight(BLUE) + graph.set_color(BLUE) fourier_graph = FunctionGraph( get_fourier_transform(func, 0, 5), x_min = 0, x_max = 5 ) fourier_graph.move_to(graph) fourier_graph.to_edge(RIGHT) - fourier_graph.highlight(RED) + fourier_graph.set_color(RED) arrow = Arrow(graph, fourier_graph, color = WHITE) self.add(title, graph) @@ -198,7 +198,7 @@ class AddingPureFrequencies(PiCreatureScene): def play_A440(self): randy = self.pi_creature A_label = TextMobject("A440") - A_label.highlight(self.A_color) + A_label.set_color(self.A_color) A_label.next_to(self.speaker, UP) self.broadcast( @@ -233,7 +233,7 @@ class AddingPureFrequencies(PiCreatureScene): frequency = self.A_frequency graph = self.get_wave_graph(frequency, axes) func = graph.underlying_function - graph.highlight(self.A_color) + graph.set_color(self.A_color) pressure = TextMobject("Pressure") time = TextMobject("Time") for label in pressure, time: @@ -291,7 +291,7 @@ class AddingPureFrequencies(PiCreatureScene): graph.set_color(self.D_color) D_label = TextMobject("D294") - D_label.highlight(self.D_color) + D_label.set_color(self.D_color) D_label.move_to(self.A_label) self.play( @@ -407,7 +407,7 @@ class AddingPureFrequencies(PiCreatureScene): return result sum_graph = axes.get_graph(new_func) - sum_graph.highlight(self.sum_color) + sum_graph.set_color(self.sum_color) thin_sum_graph = sum_graph.copy().fade() A_graph = self.A_graph @@ -469,15 +469,15 @@ class AddingPureFrequencies(PiCreatureScene): C_axes = self.A_axes.deepcopy() VGroup(F_axes, C_axes).next_to(squish_group, DOWN) F_graph = self.get_wave_graph(self.A_frequency*4.0/5, F_axes) - F_graph.highlight(self.F_color) + F_graph.set_color(self.F_color) C_graph = self.get_wave_graph(self.A_frequency*6.0/5, C_axes) - C_graph.highlight(self.C_color) + C_graph.set_color(self.C_color) F_label = TextMobject("F349") C_label = TextMobject("C523") for label, graph in (F_label, F_graph), (C_label, C_graph): label.scale(0.5) - label.highlight(graph.get_stroke_color()) + label.set_color(graph.get_stroke_color()) label.next_to(graph, UP, SMALL_BUFF) graphs = VGroup(self.A_graph, self.D_graph, F_graph, C_graph) @@ -492,7 +492,7 @@ class AddingPureFrequencies(PiCreatureScene): new_sum_func, num_graph_points = 200 ) - new_sum_graph.highlight(BLUE_C) + new_sum_graph.set_color(BLUE_C) thin_new_sum_graph = new_sum_graph.copy().fade() self.play(*it.chain( @@ -561,8 +561,8 @@ class AddingPureFrequencies(PiCreatureScene): A_line, D_line = lines A_line.shift(point - A_line.get_start()) D_line.shift(A_line.get_end()-D_line.get_start()) - A_line.highlight(self.A_color) - D_line.highlight(self.D_color) + A_line.set_color(self.A_color) + D_line.set_color(self.D_color) return lines def create_pi_creature(self): @@ -611,7 +611,7 @@ class BreakApartSum(Scene): axes.center() axes.to_edge(LEFT) graph = axes.get_graph(func, num_graph_points = 200) - graph.highlight(YELLOW) + graph.set_color(YELLOW) v_line = Line(ORIGIN, 4*UP) v_line.move_to(axes.coords_to_point(0, 0), DOWN) @@ -675,7 +675,7 @@ class BreakApartSum(Scene): ShowCreation(rect), LaggedStart( ApplyFunction, pure_graphs, - lambda g : (lambda m : m.shift(SMALL_BUFF*UP).highlight(YELLOW), g), + lambda g : (lambda m : m.shift(SMALL_BUFF*UP).set_color(YELLOW), g), rate_func = wiggle ) ) @@ -707,7 +707,7 @@ class UnmixMixedPaint(Scene): def construct(self): angles = np.arange(4)*np.pi/2 quadrants = VGroup(*[ - Quadrant().rotate(angle, about_point = ORIGIN).highlight(color) + Quadrant().rotate(angle, about_point = ORIGIN).set_color(color) for color, angle in zip(self.colors, angles) ]) quadrants.add(*it.chain(*[ @@ -765,15 +765,15 @@ class MachineThatTreatsOneFrequencyDifferently(Scene): arrow1, q_marks, arrow2 = group = VGroup( Vector(DOWN), TextMobject("???").scale(1.5), Vector(DOWN) ) - group.highlight(WHITE) + group.set_color(WHITE) group.arrange_submobjects(DOWN) group.next_to(graph, DOWN) self.add(group) self.change_graph_frequency(1) - graph.highlight(GREEN) + graph.set_color(GREEN) self.wait() - graph.highlight(YELLOW) + graph.set_color(YELLOW) self.change_graph_frequency(2) self.wait() @@ -1078,7 +1078,7 @@ class FourierMachineScene(Scene): ctp(0, 0), ctp(0, time_axes.y_max), stroke_width = 6, ) - v_line.highlight(RED) + v_line.set_color(RED) for x in range(n_repeats): v_line.move_to(ctp(0, 0), DOWN) @@ -1282,7 +1282,7 @@ class WrapCosineGraphAroundCircle(FourierMachineScene): self.play(LaggedStart( ApplyFunction, v_lines, lambda mob : ( - lambda m : m.shift(0.25*UP).highlight(YELLOW), + lambda m : m.shift(0.25*UP).set_color(YELLOW), mob ), rate_func = there_and_back @@ -1406,7 +1406,7 @@ class DrawFrequencyPlot(WrapCosineGraphAroundCircle, PiCreatureScene): dot.move_to(arrow.get_start()) words = TextMobject("Center of mass") words.next_to(arrow.get_start(), RIGHT) - words.highlight(color) + words.set_color(color) self.play( GrowArrow(arrow), @@ -1437,7 +1437,7 @@ class DrawFrequencyPlot(WrapCosineGraphAroundCircle, PiCreatureScene): com_label.add_background_rectangle() frequency_axes = self.get_frequency_axes() x_coord_label = TextMobject("$x$-coordinate for center of mass") - x_coord_label.highlight(self.center_of_mass_color) + x_coord_label.set_color(self.center_of_mass_color) x_coord_label.scale(self.text_scale_val) x_coord_label.next_to( frequency_axes.y_axis.get_top(), @@ -1527,7 +1527,7 @@ class DrawFrequencyPlot(WrapCosineGraphAroundCircle, PiCreatureScene): self.play(FadeIn(rect)) self.wait() for group in groups: - graph_copy = group[0].copy().highlight(PINK) + graph_copy = group[0].copy().set_color(PINK) self.play(FadeIn(group)) self.play(ShowCreation(graph_copy)) self.play(FadeOut(graph_copy)) @@ -1732,7 +1732,7 @@ class ShowLowerFrequency(DrawFrequencyPlot): graph = self.get_cosine_wave( freq = self.signal_frequency, ) - graph.highlight(self.lower_signal_color) + graph.set_color(self.lower_signal_color) self.graph = graph ratio = float(self.higher_signal_frequency)/self.signal_frequency @@ -1751,7 +1751,7 @@ class ShowLowerFrequency(DrawFrequencyPlot): # self.add(start_graph) self.play( start_graph.stretch, ratio, 0, {"about_edge" : LEFT}, - start_graph.highlight, graph.get_color(), + start_graph.set_color, graph.get_color(), ) self.play(FadeOut(start_graph), Animation(graph)) self.remove(start_graph) @@ -1836,7 +1836,7 @@ class ShowLowerFrequency(DrawFrequencyPlot): self.signal_frequency, fourier_graph ), UP ) - x_coord_label.highlight(self.center_of_mass_color) + x_coord_label.set_color(self.center_of_mass_color) self.generate_fourier_dot_transform(fourier_graph) self.play(Write(x_coord_label)) @@ -1918,8 +1918,8 @@ class ShowLinearity(DrawFrequencyPlot): ] for label, graph, color in trips: label.next_to(graph, UP) - graph.highlight(color) - label.highlight(color) + graph.set_color(color) + label.set_color(color) sum_label[0].match_color(low_freq_graph) sum_label[2].match_color(high_freq_graph) @@ -1978,7 +1978,7 @@ class ShowLinearity(DrawFrequencyPlot): self.signal_frequency, fourier_graph ), UP ) - x_coord_label.highlight(self.center_of_mass_color) + x_coord_label.set_color(self.center_of_mass_color) almost_fourier_label = TextMobject( "``Almost-Fourier transform''" ) @@ -2058,7 +2058,7 @@ class ShowCommutativeDiagram(ShowLinearity): ta_group.to_corner(UP+LEFT, buff = MED_SMALL_BUFF) frequency_axes = Axes(**self.frequency_axes_config) - frequency_axes.highlight(TEAL) + frequency_axes.set_color(TEAL) freq_label = TextMobject("Frequency") freq_label.scale(self.text_scale_val) freq_label.next_to(frequency_axes.x_axis, DOWN, SMALL_BUFF, RIGHT) @@ -2097,15 +2097,15 @@ class ShowCommutativeDiagram(ShowLinearity): ] for func, color, label, ta, fa in zip(funcs, colors, labels, ta_group, fa_group): time_graph = ta.get_graph(func) - time_graph.highlight(color) - label.highlight(color) + time_graph.set_color(color) + label.set_color(color) label.scale(0.75) label.next_to(time_graph, UP, SMALL_BUFF) fourier = get_fourier_transform( func, ta.x_min, 4*ta.x_max ) fourier_graph = fa.get_graph(fourier) - fourier_graph.highlight(self.center_of_mass_color) + fourier_graph.set_color(self.center_of_mass_color) arrow = Arrow( ta.x_axis.main_line, fa.x_axis.main_line, @@ -2338,7 +2338,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram): for f in 0.5, 0.7, 1.0, 1.2, 3.0, ]) graph = axes.get_graph(func) - graph.highlight(BLUE) + graph.set_color(BLUE) self.play( FadeIn(axes), @@ -2369,7 +2369,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram): y_max = 1, y_axis_config = {"unit_size" : 2}, ) - frequency_axes.highlight(TEAL) + frequency_axes.set_color(TEAL) frequency_axes.next_to(time_axes, DOWN, LARGE_BUFF, LEFT) freq_label = TextMobject("Frequency") freq_label.scale(0.75) @@ -2386,7 +2386,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram): fourier_graph = frequency_axes.get_graph( fourier_func, num_graph_points = 150, ) - fourier_graph.highlight(RED) + fourier_graph.set_color(RED) frequency_axes.graph = fourier_graph arrow = Arrow(time_graph, fourier_graph, color = WHITE) @@ -2427,7 +2427,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram): new_graph = frequency_axes.get_graph( filtered_func, num_graph_points = 300 ) - new_graph.highlight(RED) + new_graph.set_color(RED) self.play(spike_rect.stretch, 4, 0) self.play( @@ -2450,7 +2450,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram): filtered_graph = time_axes.get_graph( lambda t : time_graph.underlying_function(t)-np.cos(TAU*3*t) ) - filtered_graph.highlight(BLUE_C) + filtered_graph.set_color(BLUE_C) to_fourier_arrow = self.to_fourier_arrow arrow = to_fourier_arrow.copy() @@ -2458,7 +2458,7 @@ class FilterOutHighPitch(AddingPureFrequencies, ShowCommutativeDiagram): arrow.shift(MED_SMALL_BUFF*LEFT) inv_fourier_words = TextMobject("Inverse Fourier \\\\ transform") inv_fourier_words.next_to(arrow, LEFT) - VGroup(arrow, inv_fourier_words).highlight(MAROON_B) + VGroup(arrow, inv_fourier_words).set_color(MAROON_B) self.play( GrowArrow(arrow), @@ -2571,12 +2571,12 @@ class ApplyFourierToFourier(DrawFrequencyPlot): wound_up_graph = self.get_polarized_mobject(new_fourier_graph, freq = 0) double_fourier_graph = frequency_axes.get_graph( lambda t : 0.25*np.cos(TAU*2*t) - ).highlight(PINK) + ).set_color(PINK) self.fourier_graph = double_fourier_graph self.remove(self.fourier_graph_dot) self.get_fourier_graph_drawing_update_anim(double_fourier_graph) self.generate_fourier_dot_transform(double_fourier_graph) - self.center_of_mass_dot.highlight(PINK) + self.center_of_mass_dot.set_color(PINK) self.generate_center_of_mass_dot_update_anim() def new_get_pol_graph_center_of_mass(): result = DrawFrequencyPlot.get_pol_graph_center_of_mass(self) @@ -2680,7 +2680,7 @@ class WriteComplexExponentialExpression(DrawFrequencyPlot): v_line = Line(ORIGIN, UP) h_line = Line(ORIGIN, RIGHT) lines = VGroup(v_line, h_line) - lines.highlight(PINK) + lines.set_color(PINK) def lines_update(lines): point = com_dot.get_center() x, y = plane.point_to_coords(point) @@ -2867,8 +2867,8 @@ class WriteComplexExponentialExpression(DrawFrequencyPlot): plane.coords_to_point(1, 1), UP+RIGHT ) - f.highlight(RED) - t.highlight(YELLOW) + f.set_color(RED) + t.set_color(YELLOW) exp_expression.add_background_rectangle() two_pi_i_f_t_group = VGroup(two_pi_i, f, t) two_pi_i_f_t_group.save_state() @@ -3193,10 +3193,10 @@ class BuildUpExpressionStepByStep(TeacherStudentsScene): ) frac, integral, g, e, two_pi_i, f, t, dt = expression expression.next_to(self.teacher, UP+LEFT) - t.highlight(YELLOW) - g[2].highlight(YELLOW) - dt[1].highlight(YELLOW) - f.highlight(GREEN) + t.set_color(YELLOW) + g[2].set_color(YELLOW) + dt[1].set_color(YELLOW) + f.set_color(GREEN) t.save_state() t.move_to(f, LEFT) @@ -3257,10 +3257,10 @@ class ScaleUpCenterOfMass(WriteComplexExponentialExpression): ) frac, integral, g, e, two_pi_i, f, t, dt = expression expression.to_corner(UP+RIGHT) - t.highlight(YELLOW) - g[2].highlight(YELLOW) - dt[1].highlight(YELLOW) - f.highlight(GREEN) + t.set_color(YELLOW) + g[2].set_color(YELLOW) + dt[1].set_color(YELLOW) + f.set_color(GREEN) self.expression = expression self.add(expression) @@ -3314,7 +3314,7 @@ class ScaleUpCenterOfMass(WriteComplexExponentialExpression): com_vector.copy().shift(x*com_vector.get_vector()) for x in range(1, n+1) ]) - com_vector_copies.highlight(TEAL) + com_vector_copies.set_color(TEAL) return com_vector_copies com_vector_update = UpdateFromFunc( com_vector, @@ -3518,7 +3518,7 @@ class ScaleUpCenterOfMass(WriteComplexExponentialExpression): graph_portion = axes.get_graph( graph.underlying_function, x_min = 1, x_max = 2 ) - graph_portion.highlight(TEAL) + graph_portion.set_color(TEAL) bps_label = TextMobject("2 beats per second") bps_label.scale(0.75) bps_label.next_to(graph_portion, UP, aligned_edge = LEFT) @@ -3653,9 +3653,9 @@ class SummarizeTheFullTransform(DrawFrequencyPlot): ) graph = time_axes.get_graph(func) - graph.highlight(GREEN) + graph.set_color(GREEN) fourier_graph = frequency_axes.get_graph(fourier_func) - fourier_graph.highlight(RED) + fourier_graph.set_color(RED) g_t = TexMobject("g(t)") g_t[-2].match_color(graph) @@ -3711,7 +3711,7 @@ class SummarizeTheFullTransform(DrawFrequencyPlot): morty = self.pi_creature g_hat_f = self.g_hat_f g_hat_f_rect = SurroundingRectangle(g_hat_f) - g_hat_f_rect.highlight(TEAL) + g_hat_f_rect.set_color(TEAL) g_hat_rect = SurroundingRectangle(g_hat_f[0]) g_hat_rect.match_style(g_hat_f_rect) @@ -3734,7 +3734,7 @@ class SummarizeTheFullTransform(DrawFrequencyPlot): use_almost_fourier = False, ) ) - imaginary_fourier_graph.highlight(BLUE) + imaginary_fourier_graph.set_color(BLUE) imaginary_fourier_graph.shift( frequency_axes.x_axis.main_line.get_right() - \ imaginary_fourier_graph.points[-1], @@ -3832,11 +3832,11 @@ class SummarizeFormula(Scene): "\\hat g(", "f", ")", "=", "\\int", "_{t_1}", "^{t_2}", "g({}", "t", ")", "e", "^{-2\\pi i", "f", "t}", "dt" ) - expression.highlight_by_tex( + expression.set_color_by_tex( "t", YELLOW, substring = False, ) - expression.highlight_by_tex("t}", YELLOW) - expression.highlight_by_tex( + expression.set_color_by_tex("t}", YELLOW) + expression.set_color_by_tex( "f", RED, substring = False, ) expression.scale(1.2) @@ -3867,7 +3867,7 @@ class BoundsAtInfinity(SummarizeFormula): SurroundingRectangle(b, buff = 0.5*SMALL_BUFF) for b in bounds ]) - bound_rects.highlight(TEAL) + bound_rects.set_color(TEAL) inf_bounds = VGroup(*[ VGroup(TexMobject(s + "\\infty")) for s in "-", "+" @@ -3948,7 +3948,7 @@ class BoundsAtInfinity(SummarizeFormula): return np.exp(-0.1*x**2)*(1 + np.cos(TAU*x)) graph = axes.get_graph(func) self.add(graph) - graph.highlight(YELLOW) + graph.set_color(YELLOW) self.set_variables_as_attrs(axes, graph) @@ -4013,9 +4013,9 @@ class ShowUncertaintyPrinciple(Scene): def get_bell_func(factor = 1): return lambda x : 2*np.exp(-factor*x**2) top_graph = top_axes.get_graph(get_bell_func()) - top_graph.highlight(YELLOW) + top_graph.set_color(YELLOW) bottom_graph = bottom_axes.get_graph(get_bell_func()) - bottom_graph.highlight(RED) + bottom_graph.set_color(RED) def get_update_func(axes): def update_graph(graph): f = ghost_dot.get_center()[0] @@ -4047,7 +4047,7 @@ class ShowUncertaintyPrinciple(Scene): class XCoordinateLabelTypoFix(Scene): def construct(self): words = TextMobject("$x$-coordinate for center of mass") - words.highlight(RED) + words.set_color(RED) self.add(words) class NextVideoWrapper(Scene): @@ -4065,16 +4065,16 @@ class SubscribeOrBinge(PiCreatureScene): morty = self.pi_creature morty.center().to_edge(DOWN, LARGE_BUFF) subscribe = TextMobject("Subscribe") - subscribe.highlight(RED) + subscribe.set_color(RED) subscribe.next_to(morty, UP+RIGHT) binge = TextMobject("Binge") - binge.highlight(BLUE) + binge.set_color(BLUE) binge.next_to(morty, UP+LEFT) videos = VGroup(*[VideoIcon() for x in range(30)]) colors = it.cycle([BLUE_D, BLUE_E, BLUE_C, GREY_BROWN]) for video, color in zip(videos, colors): - video.highlight(color) + video.set_color(color) videos.move_to(binge.get_bottom(), UP) video_anim = LaggedStart( Succession, videos, @@ -4132,15 +4132,15 @@ class PuzzleDescription(Scene): TextMobject("Prove that", "$D$", "is convex") ) for line in lines: - line.highlight_by_tex_to_color_map({ + line.set_color_by_tex_to_color_map({ "$C$" : BLUE_D, "\\partial C" : BLUE_D, "$B$" : BLUE_C, "$D$" : YELLOW, }) - VGroup(lines[2][1][2], lines[2][1][6]).highlight(RED) - VGroup(lines[2][1][4], lines[2][1][8]).highlight(MAROON_B) - lines[2][1][10].highlight(BLUE_C) + VGroup(lines[2][1][2], lines[2][1][6]).set_color(RED) + VGroup(lines[2][1][4], lines[2][1][8]).set_color(MAROON_B) + lines[2][1][10].set_color(BLUE_C) lines.scale(1.25) lines.arrange_submobjects(DOWN, buff = LARGE_BUFF, aligned_edge = LEFT) @@ -4256,7 +4256,7 @@ class FourierEndScreen(PatreonEndScreen): class Thumbnail(Scene): def construct(self): title = TextMobject("Fourier\\\\", "Visualized") - title.highlight(YELLOW) + title.set_color(YELLOW) title.set_stroke(RED, 2) title.scale(2.5) title.add_background_rectangle() @@ -4266,9 +4266,9 @@ class Thumbnail(Scene): fourier = get_fourier_transform(func, -5, 5) graph = FunctionGraph(func, x_min = -5, x_max = 5) - graph.highlight(BLUE) + graph.set_color(BLUE) fourier_graph = FunctionGraph(fourier, x_min = 0, x_max = 6) - fourier_graph.highlight(YELLOW) + fourier_graph.set_color(YELLOW) for g in graph, fourier_graph: g.stretch_to_fit_height(2) g.stretch_to_fit_width(10) diff --git a/old_projects/fractal_dimension.py b/old_projects/fractal_dimension.py index 4952d4b0..e2d15b1f 100644 --- a/old_projects/fractal_dimension.py +++ b/old_projects/fractal_dimension.py @@ -180,7 +180,7 @@ class WhatAreFractals(TeacherStudentsScene): ) self.wait(2) question = TextMobject("Aren't they", "self-similar", "shapes?") - question.highlight_by_tex("self-similar", YELLOW) + question.set_color_by_tex("self-similar", YELLOW) self.student_says(question) self.play(self.get_teacher().change_mode, "happy") self.wait(2) @@ -253,7 +253,7 @@ class IntroduceVonKochCurve(Scene): n_parts = len(curve.split()) sub_portion = VGroup(*curve[:n_parts/4]) self.play( - sub_portion.highlight, YELLOW, + sub_portion.set_color, YELLOW, rate_func = there_and_back ) self.wait() @@ -644,7 +644,7 @@ class FourSelfSimilarShapes(Scene): Line(LEFT, ORIGIN), Line(ORIGIN, RIGHT) ) - line.highlight(BLUE_C) + line.set_color(BLUE_C) square = VGroup(*[ Square().next_to(ORIGIN, vect, buff = 0) @@ -742,7 +742,7 @@ class FourSelfSimilarShapes(Scene): self.play( Write(label, run_time = 1), - shape[0].highlight, YELLOW + shape[0].set_color, YELLOW ) self.wait() @@ -768,7 +768,7 @@ class GeneralWordForMeasurement(Scene): words.next_to(measure, DOWN, buff = 2*LARGE_BUFF) colors = color_gradient([BLUE_B, BLUE_D], len(words)) for word, color in zip(words, colors): - word.highlight(color) + word.set_color(color) lines = VGroup(*[ Line( measure.get_bottom(), word.get_top(), @@ -808,7 +808,7 @@ class ImagineShapesAsMetal(FourSelfSimilarShapes): self.add(titles, shapes) for shape in shapes: shape.generate_target() - shape.target.highlight(LIGHT_GREY) + shape.target.set_color(LIGHT_GREY) shapes[-1].target.gradient_highlight(GREY, WHITE) for shape, title in zip(shapes, titles): self.play( @@ -842,12 +842,12 @@ class ScaledLineMass(Scene): scaling_factor_label = TextMobject( "Scaling factor:", "$\\frac{1}{2}$" ) - scaling_factor_label[1].highlight(YELLOW) + scaling_factor_label[1].set_color(YELLOW) scaling_factor_label.to_edge(LEFT).shift(UP) mass_scaling_label = TextMobject( "Mass scaling factor:", "$%s$"%self.mass_scaling_factor ) - mass_scaling_label[1].highlight(GREEN) + mass_scaling_label[1].set_color(GREEN) mass_scaling_label.next_to( scaling_factor_label, DOWN, aligned_edge = LEFT, @@ -906,7 +906,7 @@ class ScaledLineMass(Scene): return VGroup( Line(LEFT, ORIGIN), Line(ORIGIN, RIGHT) - ).highlight(BLUE) + ).set_color(BLUE) class ScaledSquareMass(ScaledLineMass): CONFIG = { @@ -972,7 +972,7 @@ class DefineTwoDimensional(PiCreatureScene): arg_separator = "" ) self.dimension_in_title = title[0] - self.dimension_in_title.highlight(self.dimension_color) + self.dimension_in_title.set_color(self.dimension_color) title.to_edge(UP) self.add(title) @@ -1008,7 +1008,7 @@ class DefineTwoDimensional(PiCreatureScene): self.dimension_in_exp = VGroup( *bottom_mass[1][-len(self.dimension):] ) - self.dimension_in_exp.highlight(self.dimension_color) + self.dimension_in_exp.set_color(self.dimension_color) top_group = VGroup(top_length, top_mass) bottom_group = VGroup(bottom_length, bottom_mass) @@ -1018,8 +1018,8 @@ class DefineTwoDimensional(PiCreatureScene): buff = MED_LARGE_BUFF, aligned_edge = LEFT ) - group[0][-1].highlight(self.length_color) - group[1][-1].highlight(self.mass_color) + group[0][-1].set_color(self.length_color) + group[1][-1].set_color(self.mass_color) top_group.next_to(self.h_line, UP, buff = LARGE_BUFF) bottom_group.next_to(self.h_line, DOWN, buff = LARGE_BUFF) @@ -1106,7 +1106,7 @@ class DefineSierpinskiDimension(DefineTwoDimensional): "$= \\left(\\frac{1}{3}\\right)$", "$M$", arg_separator = "" ) - equation.highlight_by_tex("$M$", self.mass_color) + equation.set_color_by_tex("$M$", self.mass_color) equation.next_to(self.bottom_mass) self.play(Write(equation)) @@ -1154,12 +1154,12 @@ class DefineSierpinskiDimension(DefineTwoDimensional): self.wait(2) simpler_equation = TexMobject("2^D = 3") - simpler_equation[1].highlight(self.dimension_color) + simpler_equation[1].set_color(self.dimension_color) simpler_equation.scale(self.equation_scale_factor) simpler_equation.next_to(equation, DOWN, buff = MED_LARGE_BUFF) log_expression = TexMobject("\\log_2(3) \\approx", "1.585") - log_expression[-1].highlight(self.dimension_color) + log_expression[-1].set_color(self.dimension_color) log_expression.scale(self.equation_scale_factor) log_expression.next_to(simpler_equation, DOWN, buff = MED_LARGE_BUFF) log_expression.shift_onto_screen() @@ -1196,7 +1196,7 @@ class ShowSierpinskiCurve(Scene): def get_curve(self, order): curve = SierpinskiCurve(order = order, monochromatic = True) - curve.highlight(RED) + curve.set_color(RED) return curve class LengthAndAreaOfSierpinski(ShowSierpinskiCurve): @@ -1294,7 +1294,7 @@ class DimensionOfKoch(Scene): ) scaling_factor.next_to(ORIGIN, UP) scaling_factor.to_edge(LEFT) - scaling_factor[1].highlight(self.scaling_factor_color) + scaling_factor[1].set_color(self.scaling_factor_color) self.add(scaling_factor[0]) mass_scaling = TextMobject( @@ -1303,7 +1303,7 @@ class DimensionOfKoch(Scene): ) mass_scaling.next_to(ORIGIN, DOWN) mass_scaling.to_edge(LEFT) - mass_scaling[1].highlight(self.mass_scaling_color) + mass_scaling[1].set_color(self.mass_scaling_color) self.add(mass_scaling[0]) self.scaling_factor_mob = scaling_factor[1] @@ -1342,7 +1342,7 @@ class DimensionOfKoch(Scene): one = big_brace.get_text("$1$") little_brace = Brace(self.broken_curve[0], DOWN) one_third = little_brace.get_text("1/%d"%self.scaling_factor) - one_third.highlight(self.scaling_factor_color) + one_third.set_color(self.scaling_factor_color) self.play( GrowFromCenter(big_brace), @@ -1378,9 +1378,9 @@ class DimensionOfKoch(Scene): simpler_formula.move_to(formula, UP) for mob in formula, simpler_formula: - mob[0].highlight(self.scaling_factor_color) - mob[1].highlight(self.dimension_color) - mob[3].highlight(self.mass_scaling_color) + mob[0].set_color(self.scaling_factor_color) + mob[1].set_color(self.dimension_color) + mob[3].set_color(self.mass_scaling_color) log_expression = TexMobject( "D = \\log_%d(%d) %s"%( @@ -1389,9 +1389,9 @@ class DimensionOfKoch(Scene): self.dimension_rhs ) ) - log_expression[0].highlight(self.dimension_color) - log_expression[5].highlight(self.scaling_factor_color) - log_expression[7].highlight(self.mass_scaling_color) + log_expression[0].set_color(self.dimension_color) + log_expression[5].set_color(self.scaling_factor_color) + log_expression[7].set_color(self.mass_scaling_color) log_expression.next_to( simpler_formula, DOWN, aligned_edge = LEFT, @@ -1434,7 +1434,7 @@ class DimensionOfQuadraticKoch(DimensionOfKoch): def construct(self): self.add_labels() self.add_curve() - self.highlight_curve_subparts() + self.set_color_curve_subparts() self.show_dimension() def get_curve(self, order): @@ -1476,7 +1476,7 @@ class DimensionOfQuadraticKoch(DimensionOfKoch): self.curve = curve - def highlight_curve_subparts(self): + def set_color_curve_subparts(self): n_parts = self.num_subparts colored_curve = self.curve_class( order = self.koch_curve_order, @@ -1490,7 +1490,7 @@ class DimensionOfQuadraticKoch(DimensionOfKoch): ]) colors = it.cycle([WHITE, RED]) for subpart, color in zip(broken_curve, colors): - subpart.highlight(color) + subpart.set_color(color) self.play( FadeOut(self.curve), FadeIn(colored_curve) @@ -1542,7 +1542,7 @@ class ShowSeveralSelfSimilarityDimensions(Scene): title = TextMobject("``Self-similarity dimension''") title.to_edge(UP) - title.highlight(YELLOW) + title.set_color(YELLOW) self.add(title) @@ -1841,7 +1841,7 @@ class BoxCountingScene(Scene): self.play(Write(num)) self.play( num.next_to, self.counting_num_reference, RIGHT, MED_SMALL_BUFF, DOWN, - num.highlight, YELLOW + num.set_color, YELLOW ) return num @@ -1871,7 +1871,7 @@ class BoxCountingWithDisk(BoxCountingScene): counting_label = self.get_counting_label() prop_words = TextMobject("Proportional to", "$\\pi r^2$") - prop_words[1].highlight(BLUE) + prop_words[1].set_color(BLUE) prop_words.next_to(counting_label, DOWN, aligned_edge = LEFT) self.add(disk, one) @@ -1906,7 +1906,7 @@ class BoxCountingWithDisk(BoxCountingScene): self.wait() frac_line = TexMobject("-") - frac_line.highlight(YELLOW) + frac_line.set_color(YELLOW) frac_line.stretch_to_fit_width(new_counting_mob.get_width()) frac_line.next_to(new_counting_mob, DOWN, buff = SMALL_BUFF) decimal = TexMobject(self.decimal_string%(float(large_box_count)/small_box_num)) @@ -2050,7 +2050,7 @@ class BoxCountingSierpinski(BoxCountingScene): self.wait() frac_line = TexMobject("-") - frac_line.highlight(YELLOW) + frac_line.set_color(YELLOW) frac_line.stretch_to_fit_width(new_counting_mob.get_width()) frac_line.next_to(new_counting_mob, DOWN, buff = SMALL_BUFF) approx_three = TexMobject("\\approx 3") @@ -2119,9 +2119,9 @@ class BoxCountingWithBritain(BoxCountingScene): s = equation[word_len+3].copy() dim = VGroup(*equation[-len("1.21"):]).copy() - N.highlight(YELLOW) - s.highlight(BLUE) - dim.highlight(GREEN) + N.set_color(YELLOW) + s.set_color(BLUE) + dim.set_color(GREEN) simpler_eq = VGroup(N, approx, c, s, dim) simpler_eq.generate_target() @@ -2158,10 +2158,10 @@ class BoxCountingWithBritain(BoxCountingScene): ) for log_expression in log_expression1, log_expression2: log_expression.next_to(simpler_eq, DOWN, aligned_edge = LEFT) - log_expression.highlight_by_tex("N", N.get_color()) - log_expression.highlight_by_tex("s", s.get_color()) - log_expression.highlight_by_tex("^{1.21}", dim.get_color()) - log_expression.highlight_by_tex("1.21", dim.get_color()) + log_expression.set_color_by_tex("N", N.get_color()) + log_expression.set_color_by_tex("s", s.get_color()) + log_expression.set_color_by_tex("^{1.21}", dim.get_color()) + log_expression.set_color_by_tex("1.21", dim.get_color()) rewired_log_expression1 = VGroup(*[ log_expression1[index].copy() for index in [ @@ -2258,8 +2258,8 @@ class IntroduceLogLogPlot(GraphScene): self.add(expression) self.setup_axes(animate = False) - self.x_axis_label_mob[-2].highlight(BLUE) - self.y_axis_label_mob[-2].highlight(YELLOW) + self.x_axis_label_mob[-2].set_color(BLUE) + self.y_axis_label_mob[-2].set_color(YELLOW) graph = self.graph_function( lambda x : self.y_intercept+self.dimension*x ) @@ -2270,10 +2270,10 @@ class IntroduceLogLogPlot(GraphScene): h_line = Line(p1, interim_point) v_line = Line(interim_point, p2) slope_lines = VGroup(h_line, v_line) - slope_lines.highlight(GREEN) + slope_lines.set_color(GREEN) slope = TextMobject("Slope = ", "$%.2f$"%self.dimension) - slope[-1].highlight(GREEN) + slope[-1].set_color(GREEN) slope.next_to(slope_lines, RIGHT) self.wait() @@ -2370,10 +2370,10 @@ class RoughnessAndFractionalDimension(Scene): dimension_label = TextMobject("Boundary dimension = ", "1") dimension_label.to_edge(LEFT) one = dimension_label[1] - one.highlight(BLUE) + one.set_color(BLUE) new_dim = TexMobject("1.2") new_dim.move_to(one, DOWN+LEFT) - new_dim.highlight(one.get_color()) + new_dim.set_color(one.get_color()) self.add(dimension_label) self.play(Blink(randy)) @@ -2394,8 +2394,8 @@ class RoughnessAndFractionalDimension(Scene): class DifferentSlopesAtDifferentScales(IntroduceLogLogPlot): def construct(self): self.setup_axes(animate = False) - self.x_axis_label_mob[-2].highlight(BLUE) - self.y_axis_label_mob[-2].highlight(YELLOW) + self.x_axis_label_mob[-2].set_color(BLUE) + self.y_axis_label_mob[-2].set_color(YELLOW) self.graph_function( lambda x : 0.01*(x-5)**3 + 0.3*x + 3 ) @@ -2532,7 +2532,7 @@ class ZoomInOnBritain(Scene): class NoteTheConstantSlope(Scene): def construct(self): words = TextMobject("Note the \\\\ constant slope") - words.highlight(YELLOW) + words.set_color(YELLOW) self.play(Write(words)) self.wait(2) @@ -2573,8 +2573,8 @@ class WhatSlopeDoesLogLogPlotApproach(IntroduceLogLogPlot): } def construct(self): self.setup_axes(animate = False) - self.x_axis_label_mob[-2].highlight(BLUE) - self.y_axis_label_mob[-2].highlight(YELLOW) + self.x_axis_label_mob[-2].set_color(BLUE) + self.y_axis_label_mob[-2].set_color(YELLOW) spacing = 0.5 x_range = np.arange(1, self.x_max, spacing) @@ -2682,7 +2682,7 @@ class SmoothBritainLogLogPlot(IntroduceLogLogPlot): [p3, interim_point2, p4] ) slope_lines_group = VGroup(slope_lines1, slope_lines2) - slope_lines_group.highlight(GREEN) + slope_lines_group.set_color(GREEN) slope_label1 = TextMobject("Slope $> 1$") slope_label2 = TextMobject("Slope $= 1$") @@ -2812,8 +2812,8 @@ class FractalNonFractalFlowChart(Scene): yes = TextMobject("Yes") no = TextMobject("No") - yes.highlight(GREEN) - no.highlight(RED) + yes.set_color(GREEN) + no.set_color(RED) for word, arrow in (yes, yes_arrow), (no, no_arrow): word.next_to(ORIGIN, UP) diff --git a/old_projects/generate_logo.py b/old_projects/generate_logo.py index 31b8b537..7b927da3 100644 --- a/old_projects/generate_logo.py +++ b/old_projects/generate_logo.py @@ -52,14 +52,14 @@ class LogoGeneration(Scene): self.interpolation_factor ) for mob, color in [(iris, self.sphere_brown), (circle, self.circle_brown)]: - mob.highlight(color, lambda (x, y, z) : x < 0 and y > 0) - mob.highlight( + mob.set_color(color, lambda (x, y, z) : x < 0 and y > 0) + mob.set_color( "black", lambda point: np.linalg.norm(point) < \ self.inner_radius_ratio*self.radius ) self.name_mob = TextMobject("3Blue1Brown").center() - self.name_mob.highlight("grey") + self.name_mob.set_color("grey") self.name_mob.shift(2*DOWN) self.play(Transform( diff --git a/old_projects/hanoi.py b/old_projects/hanoi.py index e6e4e389..a6be1440 100644 --- a/old_projects/hanoi.py +++ b/old_projects/hanoi.py @@ -198,7 +198,7 @@ class CountingScene(Scene): digit = TexMobject(str(num % self.base)) if place >= len(self.power_colors): self.power_colors += self.power_colors - digit.highlight(self.power_colors[place]) + digit.set_color(self.power_colors[place]) digit.scale(self.num_scale_factor) digit.move_to(result, RIGHT) digit.shift(place*(self.digit_width+SMALL_BUFF)*LEFT) @@ -326,7 +326,7 @@ class TowersOfHanoiScene(Scene): ]) for number, disk in enumerate(self.disks): label = TexMobject(str(number)) - label.highlight(BLACK) + label.set_color(BLACK) label.scale_to_fit_height(self.disk_height/2) label.move_to(disk) disk.add(label) @@ -548,9 +548,9 @@ class IntroduceKeith(Scene): one_width = bubble.content[1].get_width() for mob in bubble.content[:8]: if abs(mob.get_width() - zero_width) < 0.01: - mob.highlight(GREEN) + mob.set_color(GREEN) else: - mob.highlight(YELLOW) + mob.set_color(YELLOW) bubble.resize_to_content() bubble.pin_to(keith) @@ -595,7 +595,7 @@ class IntroduceKeith(Scene): ) self.play(Blink(keith)) bubble.write("But \\emph{analyzing} puzzles!") - VGroup(*bubble.content[3:12]).highlight(YELLOW) + VGroup(*bubble.content[3:12]).set_color(YELLOW) self.play( keith.change_mode, "hooray", Transform(original_content, bubble.content) @@ -699,7 +699,7 @@ class IntroduceTowersOfHanoi(TowersOfHanoiScene): label.save_state() self.play( label.scale_in_place, 2, - label.highlight, YELLOW, + label.set_color, YELLOW, last.restore, run_time = 0.5 ) @@ -747,7 +747,7 @@ class IntroduceTowersOfHanoi(TowersOfHanoiScene): def cannot_move_disk_onto_smaller_disk(self): also_not_allowed = TextMobject("Not allowed") also_not_allowed.to_edge(UP) - also_not_allowed.highlight(RED) + also_not_allowed.set_color(RED) cross = TexMobject("\\times") cross.set_fill(RED, opacity = 0.5) @@ -775,14 +775,14 @@ class ExampleFirstMoves(TowersOfHanoiScene): self.wait() self.play( self.disks[0].set_fill, YELLOW, - self.disks[0].label.highlight, BLACK + self.disks[0].label.set_color, BLACK ) self.wait() self.move_disk(0) self.wait() self.play( self.disks[1].set_fill, YELLOW_D, - self.disks[1].label.highlight, BLACK + self.disks[1].label.set_color, BLACK ) self.move_disk_to_peg(1, 1) cross.replace(self.disks[1]) @@ -898,10 +898,10 @@ class IntroduceBase10(Scene): number.generate_target() for color, digit, term in zip(colors, number.target, expansion): - digit.highlight(color) - term.highlight(color) + digit.set_color(color) + term.set_color(color) arrow = Arrow(digit, term.get_top()) - arrow.highlight(color) + arrow.set_color(color) arrows.add(arrow) expansion.save_state() for digit, term in zip(number, expansion): @@ -1039,8 +1039,8 @@ class IntroduceBinaryCounting(BinaryCountingScene): binary_digits = TextMobject("bi", "nary digi", "ts", arg_separator = "") for mob in bits, binary_digits: mob.next_to(brace, DOWN, buff = SMALL_BUFF) - VGroup(brace, bits, binary_digits).highlight(BLUE) - binary_digits[1].highlight(BLUE_E) + VGroup(brace, bits, binary_digits).set_color(BLUE) + binary_digits[1].set_color(BLUE_E) self.play( GrowFromCenter(brace), Write(bits) @@ -1085,7 +1085,7 @@ class IntroduceBinaryCounting(BinaryCountingScene): self.wait() curr_content = bubble.content bubble.write("$1 \\! \\cdot \\! 2+$", "$0$") - bubble.content[0][0].highlight(self.power_colors[1]) + bubble.content[0][0].set_color(self.power_colors[1]) self.play( Transform(curr_content, bubble.content), randy.change_mode, "pondering", @@ -1096,9 +1096,9 @@ class IntroduceBinaryCounting(BinaryCountingScene): #Up to 11 zero = bubble.content[-1] - zero.highlight(self.power_colors[0]) + zero.set_color(self.power_colors[0]) one = TexMobject("1").replace(zero, dim_to_match = 1) - one.highlight(zero.get_color()) + one.set_color(zero.get_color()) self.play(Blink(randy)) self.increment(added_anims = [Transform(zero, one)]) self.wait() @@ -1112,7 +1112,7 @@ class IntroduceBinaryCounting(BinaryCountingScene): ) colors = reversed(self.power_colors[:3]) for piece, color in zip(bubble.content.submobjects, colors): - piece[0].highlight(color) + piece[0].set_color(color) self.increment(added_anims = [Transform(curr_content, bubble.content)]) four_brace = Brace(self.number_mob[-1]) fours_place = four_brace.get_text("Four's place") @@ -1178,13 +1178,13 @@ class BinaryCountingAtEveryScale(Scene): lower_brace = Brace(VGroup(*curr_bits[1:])) do_a_thing = lower_brace.get_text("Do a thing") - VGroup(lower_brace, do_a_thing).highlight(YELLOW) + VGroup(lower_brace, do_a_thing).set_color(YELLOW) upper_brace = Brace(curr_bits, UP) roll_over = upper_brace.get_text("Roll over") - VGroup(upper_brace, roll_over).highlight(MAROON_B) + VGroup(upper_brace, roll_over).set_color(MAROON_B) again = TextMobject("again") again.next_to(do_a_thing, RIGHT, 2*SMALL_BUFF) - again.highlight(YELLOW) + again.set_color(YELLOW) self.add(curr_bits, lower_brace, do_a_thing) @@ -1199,8 +1199,8 @@ class BinaryCountingAtEveryScale(Scene): for bit_mob in bit_mobs: curr_bits.align_data(bit_mob) - bit_mob.highlight(YELLOW) - bit_mob[0].highlight(MAROON_B) + bit_mob.set_color(YELLOW) + bit_mob[0].set_color(MAROON_B) self.play(get_run_through(bit_mobs[1:2**(self.num_bits-1)])) self.play(*map(FadeIn, [upper_brace, roll_over])) self.play(Transform( @@ -1388,7 +1388,7 @@ class IntroduceSolveByCounting(TowersOfHanoiScene): for bit_mob in bit_mobs: bit_mob.align_data(self.curr_bit_mob) for bit, disk in zip(bit_mob, reversed(list(self.disks))): - bit.highlight(disk.get_color()) + bit.set_color(disk.get_color()) bit_mobs.next_to(self.peg_labels, DOWN) self.add(self.curr_bit_mob) @@ -1470,14 +1470,14 @@ class RecursiveSolution(TowersOfHanoiScene): "Move disk 3,", "Move 3-tower", ) - sub_steps[1].highlight(GREEN) + sub_steps[1].set_color(GREEN) sub_step_brace = Brace(sub_steps, UP) sub_sub_steps = TextMobject( "Move 2-tower,", "Move disk 2,", "Move 2-tower", ) - sub_sub_steps[1].highlight(RED) + sub_sub_steps[1].set_color(RED) sub_sub_steps_brace = Brace(sub_sub_steps, UP) steps = VGroup( title, sub_step_brace, sub_steps, @@ -1564,7 +1564,7 @@ class RecursiveSolution(TowersOfHanoiScene): self.disk_tracker = [set([]), set([0, 1, 2]), set([3])] arc = Arc(-5*np.pi/6, start_angle = 5*np.pi/6) arc.add_tip() - arc.highlight(YELLOW) + arc.set_color(YELLOW) arc.scale_to_fit_width( VGroup(*self.pegs[1:]).get_width()*0.8 ) @@ -1574,7 +1574,7 @@ class RecursiveSolution(TowersOfHanoiScene): self.play( ShowCreation(arc), Write(q_mark), - sub_steps[-1].highlight, YELLOW + sub_steps[-1].set_color, YELLOW ) self.wait() self.play( @@ -1959,7 +1959,7 @@ class IntroduceConstrainedTowersOfHanoi(ConstrainedTowersOfHanoiScene): } def construct(self): title = TextMobject("Constrained", "Towers of Hanoi") - title.highlight_by_tex("Constrained", YELLOW) + title.set_color_by_tex("Constrained", YELLOW) title.to_edge(UP) self.play(Write(title)) @@ -1996,7 +1996,7 @@ class IntroduceConstrainedTowersOfHanoi(ConstrainedTowersOfHanoiScene): for curved_arrow in curved_arrows: for arc in curved_arrow: arc.add_tip(tip_length = 0.15) - arc.highlight(YELLOW) + arc.set_color(YELLOW) peg_sets = (self.pegs[:2], self.pegs[1:]) for curved_arrow, pegs in zip(curved_arrows, peg_sets): peg_group = VGroup(*pegs) @@ -2011,7 +2011,7 @@ class IntroduceConstrainedTowersOfHanoi(ConstrainedTowersOfHanoiScene): big_curved_arrow.scale_to_fit_width(0.9*self.pegs.get_width()) big_curved_arrow.next_to(self.pegs, UP) big_curved_arrow.add_tip(tip_length = 0.4) - big_curved_arrow.highlight(WHITE) + big_curved_arrow.set_color(WHITE) self.big_curved_arrow = big_curved_arrow class StillRecruse(Scene): @@ -2055,14 +2055,14 @@ class RecursiveSolutionToConstrained(RecursiveSolution): "\\, Move %d-tower, \\,"%d, "Move disk %d,"%d, "Move %d-tower"%d, - ).highlight_by_tex("Move disk %d,"%d, color) + ).set_color_by_tex("Move disk %d,"%d, color) for d, color in (3, GREEN), (2, RED), (1, BLUE_C) ] sub_steps, sub_sub_steps = subdivisions[:2] for steps in subdivisions: steps.scale_to_fit_width(FRAME_WIDTH-1) subdivisions.append( - TextMobject("\\tiny Move disk 0, Move disk 0").highlight(BLUE) + TextMobject("\\tiny Move disk 0, Move disk 0").set_color(BLUE) ) braces = [ Brace(steps, UP) @@ -2104,12 +2104,12 @@ class RecursiveSolutionToConstrained(RecursiveSolution): #Talk about tower blocking tower = VGroup(*self.disks[:self.num_disks-1]) blocking = TextMobject("Still\\\\", "Blocking") - blocking.highlight(RED) + blocking.set_color(RED) blocking.to_edge(LEFT) blocking.shift(2*UP) arrow = Arrow(blocking.get_bottom(), tower.get_top(), buff = SMALL_BUFF) new_arrow = Arrow(blocking.get_bottom(), self.pegs[1], buff = SMALL_BUFF) - VGroup(arrow, new_arrow).highlight(RED) + VGroup(arrow, new_arrow).set_color(RED) self.play( Write(blocking[1]), @@ -2160,10 +2160,10 @@ class RecursiveSolutionToConstrained(RecursiveSolution): self.play(FadeOut(self.eyes)) #Ask about subproblem - sub_sub_steps_brace.highlight(WHITE) + sub_sub_steps_brace.set_color(WHITE) self.move_subtower_to_peg(self.num_disks-1, 0, added_anims = [ steps_to_fade.fade, 0.7, - sub_steps[2].highlight, WHITE, + sub_steps[2].set_color, WHITE, sub_steps[2].scale_in_place, 1.2, FadeIn(sub_sub_steps_brace) ]) @@ -2311,7 +2311,7 @@ class CompareNumberSystems(Scene): binary.to_corner(UP+RIGHT).shift(LEFT) ternary = TextMobject("Ternary") ternary.to_edge(UP) - ternary.highlight(YELLOW) + ternary.set_color(YELLOW) titles = [base_ten, binary, ternary] zero_to_nine = TextMobject(""" @@ -2430,7 +2430,7 @@ class TernaryCountingSelfSimilarPattern(Scene): title = TextMobject("Count to " + "2"*self.num_trits) for i, color in enumerate(colors): - title[-i-1].highlight(color) + title[-i-1].set_color(color) steps = VGroup(*map(TextMobject, [ "Count to %s,"%("2"*(self.num_trits-1)), "Roll over,", @@ -2441,8 +2441,8 @@ class TernaryCountingSelfSimilarPattern(Scene): steps.arrange_submobjects(RIGHT) for step in steps[::2]: for i, color in enumerate(colors[:-1]): - step[-i-2].highlight(color) - VGroup(*steps[1::2]).highlight(colors[-1]) + step[-i-2].set_color(color) + VGroup(*steps[1::2]).set_color(colors[-1]) steps.scale_to_fit_width(FRAME_WIDTH-1) brace = Brace(steps, UP) word_group = VGroup(title, brace, steps) @@ -2460,7 +2460,7 @@ class TernaryCountingSelfSimilarPattern(Scene): for trits in ternary_mobs: trits.align_data(curr_ternary_mob) for trit, color in zip(trits, colors): - trit.highlight(color) + trit.set_color(color) def get_increment(): return Transform( curr_ternary_mob, ternary_mob_iter.next(), @@ -2563,12 +2563,12 @@ class DescribeSolutionByCountingToConstrained(SolveConstrainedWithTernaryCountin color = YELLOW brace = braces[0] word = words[0] - words[0].highlight(color) + words[0].set_color(color) self.increment_number() self.play( FadeIn(brace), Write(word, run_time = 1), - self.curr_ternary_mob[0].highlight, color + self.curr_ternary_mob[0].set_color, color ) self.wait() self.play( @@ -2577,19 +2577,19 @@ class DescribeSolutionByCountingToConstrained(SolveConstrainedWithTernaryCountin ) self.move_next_disk(stay_on_peg = True) self.wait() - self.ternary_mobs[2][0].highlight(color) + self.ternary_mobs[2][0].set_color(color) self.increment_number() self.move_next_disk(stay_on_peg = True) self.wait() #Count 10 color = MAROON_B - words[1].highlight(color) + words[1].set_color(color) self.increment_number() self.play( Transform(brace, braces[1]), Transform(word, words[1]), - self.curr_ternary_mob[1].highlight, color + self.curr_ternary_mob[1].set_color, color ) self.wait() self.play( @@ -2607,7 +2607,7 @@ class DescribeSolutionByCountingToConstrained(SolveConstrainedWithTernaryCountin #Count to 100 color = RED - words[2].highlight(color) + words[2].set_color(color) self.wait() self.increment_number() @@ -2687,7 +2687,7 @@ class AnswerConfigurationsCount(TowersOfHanoiScene): self.prepare_disks() for parens, disk in zip(parentheticals, reversed(list(self.disks))): - VGroup(parens, parens.brace, parens.three).highlight(disk.get_color()) + VGroup(parens, parens.brace, parens.three).set_color(disk.get_color()) self.play( Write(parens, run_time = 1), FadeIn(disk) @@ -2787,7 +2787,7 @@ class RepeatingConfiguraiton(Scene): self.play(Write(title)) self.play( ShowCreation(special_arrows), - special_dots.highlight, RED + special_dots.set_color, RED ) self.wait() self.play( @@ -3025,7 +3025,7 @@ class IntroduceGraphStructure(SierpinskiGraphScene): arc.scale_to_fit_width(0.8*node.target.towers.get_width()) arc.next_to(node.target.towers, UP) arc.add_tip() - arc.highlight(YELLOW) + arc.set_color(YELLOW) node.arc = arc self.play(*map(MoveToTarget, nodes)) @@ -3057,9 +3057,9 @@ class IntroduceGraphStructure(SierpinskiGraphScene): self.zoom_into_node(n) self.zoom_into_node(0, 1) self.play( - self.disks[0].highlight, YELLOW, + self.disks[0].set_color, YELLOW, *[ - ApplyMethod(disk.label.highlight, BLACK) + ApplyMethod(disk.label.set_color, BLACK) for disk in self.disks[0] ] ) @@ -3082,9 +3082,9 @@ class DescribeTriforcePattern(SierpinskiGraphScene): index_pair = self.index_pairs[0] self.zoom_into_node(index_pair[0], self.scale) self.play( - self.disks[self.scale-1].highlight, self.disk_color, + self.disks[self.scale-1].set_color, self.disk_color, *[ - ApplyMethod(disk.label.highlight, BLACK) + ApplyMethod(disk.label.set_color, BLACK) for disk in self.disks[self.scale-1] ] ) @@ -3228,7 +3228,7 @@ class PatreonThanks(Scene): n_patrons = len(self.specific_patrons) special_thanks = TextMobject("Special thanks to:") - special_thanks.highlight(YELLOW) + special_thanks.set_color(YELLOW) special_thanks.shift(3*UP) left_patrons = VGroup(*map(TextMobject, @@ -3376,8 +3376,8 @@ class Part1Thumbnail(Scene): self.add(sierpinski) binary = TexMobject("01011") - binary.highlight_by_tex("0", GREEN) - binary.highlight_by_tex("1", BLUE) + binary.set_color_by_tex("0", GREEN) + binary.set_color_by_tex("1", BLUE) binary.gradient_highlight(GREEN, RED) binary.add_background_rectangle() binary.background_rectangle.set_fill(opacity = 0.5) diff --git a/old_projects/highD.py b/old_projects/highD.py index 71566e9b..e2d6bc3f 100644 --- a/old_projects/highD.py +++ b/old_projects/highD.py @@ -409,7 +409,7 @@ class CircleToPairsOfPoints(Scene): plane.scale(2) plane.add_coordinates(y_vals = [-1, 1]) background_plane = plane.copy() - background_plane.highlight(GREY) + background_plane.set_color(GREY) background_plane.fade() circle = Circle(radius = 2, color = YELLOW) @@ -417,8 +417,8 @@ class CircleToPairsOfPoints(Scene): dot = Dot(2*x*RIGHT + 2*y*UP, color = LIGHT_GREY) equation = TexMobject("x", "^2", "+", "y", "^2", "=", "1") - equation.highlight_by_tex("x", GREEN) - equation.highlight_by_tex("y", RED) + equation.set_color_by_tex("x", GREEN) + equation.set_color_by_tex("y", RED) equation.to_corner(UP+LEFT) equation.add_background_rectangle() @@ -431,8 +431,8 @@ class CircleToPairsOfPoints(Scene): DecimalNumber(val).replace(num, dim_to_match = 1) for val, num in zip([x, y], fixed_numbers) ]) - numbers[0].highlight(GREEN) - numbers[1].highlight(RED) + numbers[0].set_color(GREEN) + numbers[1].set_color(RED) def get_update_func(i): return lambda t : dot.get_center()[i]/2.0 @@ -703,7 +703,7 @@ class Professionals(PiCreatureScene): ) quaternion.scale(0.7) quaternion.next_to(self.mathy, UP) - quaternion.highlight_by_tex_to_color_map({ + quaternion.set_color_by_tex_to_color_map({ "i" : RED, "j" : GREEN, "k" : BLUE, @@ -718,7 +718,7 @@ class Professionals(PiCreatureScene): "\\beta", "|\\!\\downarrow\\rangle" ) - kets.highlight_by_tex_to_color_map({ + kets.set_color_by_tex_to_color_map({ "\\alpha" : GREEN, "\\beta" : RED, }) @@ -833,7 +833,7 @@ class OfferAHybrid(SliderScene): "Analytic", "Hybrid", "Geometric" ])) titles.to_edge(UP) - titles[1].highlight(BLUE) + titles[1].set_color(BLUE) titles.generate_target() titles[1].scale_in_place(0.001) titles[0].shift(FRAME_X_RADIUS*LEFT/2) @@ -870,7 +870,7 @@ class DismissProjection(PiCreatureScene): ])) colors = [YELLOW, GREEN, BLUE] for equation, edge, color in zip(equations, [LEFT, ORIGIN, RIGHT], colors): - equation.highlight(color) + equation.set_color(color) equation.shift(3*UP) equation.to_edge(edge) equations[1].shift(LEFT) @@ -908,7 +908,7 @@ class DismissProjection(PiCreatureScene): square.scale_to_fit_width(equation.get_width()) square.stretch_to_fit_height(3) square.next_to(equation, vect) - square.highlight(self.screen_rect_color) + square.set_color(self.screen_rect_color) return square def discuss_4d_sphere_definition(self): @@ -926,7 +926,7 @@ class DismissProjection(PiCreatureScene): "\\text{Just lists of numbers like }", "(%.02f \\,, %.02f \\,, %.02f \\,, %.02f \\,)"%tuple(self.example_vect) ) - descriptor[1].highlight(BLUE) + descriptor[1].set_color(BLUE) descriptor.next_to(sphere_words, DOWN) dot = Dot(descriptor[1].get_top()) dot.set_fill(WHITE, opacity = 0.75) @@ -990,7 +990,7 @@ class DismissProjection(PiCreatureScene): equation.target.center().to_edge(UP) tup.generate_target() tup.target.next_to(equation.target, DOWN) - tup.target.highlight(WHITE) + tup.target.set_color(WHITE) self.play(LaggedStart(FadeOut, VGroup(*[ self.equations, self.spheres, @@ -1038,7 +1038,7 @@ class Introduce4DSliders(SliderScene): ",", "%.02f \\,"%w, ")" ) equation.center().to_edge(UP) - equation.highlight(BLUE) + equation.set_color(BLUE) tup.next_to(equation, DOWN) self.sliders.next_to(tup, DOWN) @@ -1111,7 +1111,7 @@ class TwoDimensionalCase(Introduce4DSliders): y_radius = 2.5, ) plane.fade(0.25) - plane.axes.highlight(GREY) + plane.axes.set_color(GREY) plane.add_coordinates() plane.to_edge(LEFT) origin = plane.coords_to_point(0, 0) @@ -1169,13 +1169,13 @@ class TwoDimensionalCase(Introduce4DSliders): colors = GREEN, RED arrows = VGroup() for rect, decimal, color in zip(rects, decimals, colors): - rect.highlight(color) - decimal.highlight(color) + rect.set_color(color) + decimal.set_color(color) arrow = Arrow( rect.get_bottom()+SMALL_BUFF*UP, decimal.get_top(), tip_length = 0.2, ) - arrow.highlight(color) + arrow.set_color(color) arrows.add(arrow) self.play(ShowCreation(rect)) @@ -1211,10 +1211,10 @@ class TwoDimensionalCase(Introduce4DSliders): ) rect.move_to((p1+p2)/2) if np.mean([x1, x2]) == 0: - rect.highlight(BLUE) + rect.set_color(BLUE) blue_rects.add(rect) else: - rect.highlight(RED) + rect.set_color(RED) red_rects.add(rect) blue_rects.save_state() @@ -1317,7 +1317,7 @@ class TwoDimensionalCase(Introduce4DSliders): def write_distance_squared(self): d_squared = TexMobject("(\\text{Distance})^2") d_squared.next_to(self.real_estate_word, DOWN) - d_squared.highlight(YELLOW) + d_squared.set_color(YELLOW) self.play(Write(d_squared)) self.wait(3) @@ -1385,8 +1385,8 @@ class ThreeDCase(TwoDimensionalCase): colors = [GREEN, RED, BLUE] arrows = VGroup() for rect, decimal, color in zip(rects, decimals, colors): - rect.highlight(color) - decimal.highlight(color) + rect.set_color(color) + decimal.set_color(color) arrow = Arrow( rect.get_bottom()+SMALL_BUFF*UP, decimal.get_top(), tip_length = 0.2, @@ -1524,7 +1524,7 @@ class FourDCase(SliderScene, TeacherStudentsScene): arrow.next_to(dial, LEFT) self.play( ShowCreation(arrow), - dial.highlight, arrow.get_color() + dial.set_color, arrow.get_color() ) self.change_student_modes( "erm", "confused", "hooray", @@ -1575,7 +1575,7 @@ class TwoDBoxExample(Scene): self.plane = NumberPlane() self.plane.scale(scale_factor) self.plane.add_coordinates() - self.plane.axes.highlight(GREY) + self.plane.axes.set_color(GREY) self.add(self.plane) def construct(self): @@ -1780,14 +1780,14 @@ class ShowDistanceFormula(TeacherStudentsScene): "=", "\\sqrt", "{x_1^2", " + ", "x_2^2", " +\\cdots", "x_n^2", "}" ) - rule.highlight_by_tex_to_color_map({ + rule.set_color_by_tex_to_color_map({ "x_1" : GREEN, "x_2" : RED, "x_n" : BLUE, }) for part in rule.get_parts_by_tex("x_"): if len(part) > 2: - part[1].highlight(WHITE) + part[1].set_color(WHITE) rule.next_to(self.teacher, UP, LARGE_BUFF) rule.to_edge(RIGHT) rule.shift(UP) @@ -1824,17 +1824,17 @@ class GeneralizePythagoreanTheoremBeyondTwoD(ThreeDScene): ) bottom = Line(rect.get_left(), rect.get_right()) bottom.move_to(rect.get_bottom()) - bottom.highlight(tex_to_color_map["x"]) + bottom.set_color(tex_to_color_map["x"]) side = Line(rect.get_bottom(), rect.get_top()) side.move_to(rect.get_right()) - side.highlight(tex_to_color_map["y"]) + side.set_color(tex_to_color_map["y"]) x = TexMobject("x") x.next_to(rect.get_bottom(), UP, SMALL_BUFF) y = TexMobject("y") y.next_to(rect.get_right(), LEFT, SMALL_BUFF) hyp = TexMobject("\\sqrt", "{x", "^2 + ", "y", "^2}") - hyp.highlight_by_tex_to_color_map(tex_to_color_map) + hyp.set_color_by_tex_to_color_map(tex_to_color_map) hyp.next_to(ORIGIN, UP) hyp.rotate(diag.get_angle()) hyp.shift(diag.get_center()) @@ -1854,13 +1854,13 @@ class GeneralizePythagoreanTheoremBeyondTwoD(ThreeDScene): corner = diag.get_end() z_line = Line(corner, corner + 3*UP) - z_line.highlight(tex_to_color_map["z"]) + z_line.set_color(tex_to_color_map["z"]) z = TexMobject("z") - z.highlight(tex_to_color_map["z"]) + z.set_color(tex_to_color_map["z"]) z.next_to(z_line, RIGHT) dot = Dot(z_line.get_end()) three_d_diag = Line(diag.get_start(), z_line.get_end()) - three_d_diag.highlight(MAROON_B) + three_d_diag.set_color(MAROON_B) self.play( ShowCreation(z_line), @@ -1894,7 +1894,7 @@ class ThreeDBoxFormulas(Scene): "&\\approx", "0.73" ) inner_r.next_to(answer, DOWN, LARGE_BUFF, LEFT) - inner_r.highlight(GREEN_C) + inner_r.set_color(GREEN_C) VGroup(question, answer).shift(0.55*RIGHT) self.play(Write(question)) @@ -1960,13 +1960,13 @@ class TwoDBoxWithSliders(TwoDimensionalCase): x_slider.number_to_point(value), LEFT, MED_SMALL_BUFF ) - self.plane.axes.highlight(BLUE) + self.plane.axes.set_color(BLUE) ##Add box material corner_circles = VGroup(*[ self.circle.copy().move_to( self.plane.coords_to_point(*coords) - ).highlight(GREY) + ).set_color(GREY) for coords in (1, 1), (-1, 1), (-1, -1) ]) line = Line( @@ -2049,14 +2049,14 @@ class TwoDBoxWithSliders(TwoDimensionalCase): TextMobject("$y$", "real estate:", "$(y+1)^2$"), ) phrases.next_to(self.plane, UP) - phrases[0].highlight_by_tex("x", GREEN) - phrases[1].highlight_by_tex("y", RED) + phrases[0].set_color_by_tex("x", GREEN) + phrases[1].set_color_by_tex("y", RED) x_brace, y_brace = [ Brace(slider.real_estate_ticks, RIGHT) for slider in self.sliders ] - x_brace.highlight(GREEN) - y_brace.highlight(RED) + x_brace.set_color(GREEN) + y_brace.set_color(RED) self.play(FadeOut(self.question)) self.play( @@ -2365,7 +2365,7 @@ class ThreeDBoxExampleWithSliders(SliderScene): half_label = TexMobject("0.5") half_label.scale(self.sliders[0].number_scale_val) half_label.next_to(half_line, LEFT, MED_SMALL_BUFF) - half_label.highlight(half_line.get_color()) + half_label.set_color(half_line.get_color()) curr_vector = self.get_vector() target_vector = 0.5*np.ones(3) @@ -2377,7 +2377,7 @@ class ThreeDBoxExampleWithSliders(SliderScene): cross = Cross(self.re_words.get_parts_by_tex("frac")) new_re = TexMobject("(0.5)^2 = 0.25") new_re.next_to(cross, DOWN, MED_SMALL_BUFF, LEFT) - new_re.highlight(MAROON_B) + new_re.set_color(MAROON_B) self.play( FadeOut(self.arrow), @@ -2512,7 +2512,7 @@ class FourDBoxExampleWithSliders(ThreeDBoxExampleWithSliders): self.add(sphere_words) pairs = zip(self.coordinate_mobs, self.coordinates) for coord_mob, coords in pairs[1:] + [pairs[0]]: - coord_mob.highlight(GREEN) + coord_mob.set_color(GREEN) coord_mob_copy = coord_mob.copy() coord_mob_copy.next_to(sphere_words, DOWN) for slider, x in zip(self.sliders, coords): @@ -2525,7 +2525,7 @@ class FourDBoxExampleWithSliders(ThreeDBoxExampleWithSliders): self.add(coord_mob_copy) self.wait() self.remove(coord_mob_copy) - coord_mob.highlight(WHITE) + coord_mob.set_color(WHITE) self.add(coord_mob_copy) sphere_words.add(coord_mob_copy) self.sphere_words = sphere_words @@ -2549,7 +2549,7 @@ class FourDBoxExampleWithSliders(ThreeDBoxExampleWithSliders): half_label = TexMobject("0.5") half_label.scale(self.sliders[0].number_scale_val) half_label.next_to(re_line, LEFT, MED_SMALL_BUFF) - half_label.highlight(MAROON_B) + half_label.set_color(MAROON_B) self.wind_down_ambient_movement() self.play(*[ @@ -2597,7 +2597,7 @@ class FourDBoxExampleWithSliders(ThreeDBoxExampleWithSliders): old_coords = sphere_words.target[1] new_coords = TexMobject("(0, 0, 0, 0)") new_coords.replace(old_coords, dim_to_match = 1) - new_coords.highlight(old_coords.get_color()) + new_coords.set_color(old_coords.get_color()) Transform(old_coords, new_coords).update(1) self.play(Animation(self.sliders), *[ @@ -2645,7 +2645,7 @@ class FourDBoxExampleWithSliders(ThreeDBoxExampleWithSliders): brace = Brace(VGroup(*computation[1][1:-2]), UP) brace_text = brace.get_text("Distance to corner") brace_text.scale(0.8, about_point = brace_text.get_bottom()) - VGroup(brace, brace_text).highlight(RED) + VGroup(brace, brace_text).set_color(RED) self.play(LaggedStart(FadeIn, computation, run_time = 3)) self.play(GrowFromCenter(brace)) @@ -2662,7 +2662,7 @@ class FourDBoxExampleWithSliders(ThreeDBoxExampleWithSliders): ) touching_words.to_corner(UP+LEFT) arrow = Arrow(MED_SMALL_BUFF*DOWN, 3*RIGHT+DOWN) - arrow.highlight(BLUE) + arrow.set_color(BLUE) arrow.shift(touching_words.get_bottom()) self.wind_down_ambient_movement(wait = False) @@ -2678,7 +2678,7 @@ class TwoDInnerSphereTouchingBox(TwoDBoxWithSliders, PiCreatureScene): PiCreatureScene.setup(self) self.remove(self.sliders) self.remove(self.dot) - self.circle.highlight(GREY) + self.circle.set_color(GREY) self.randy.next_to(self.plane, RIGHT, LARGE_BUFF, DOWN) def construct(self): @@ -2761,7 +2761,7 @@ class FiveDBoxExampleWithSliders(FourDBoxExampleWithSliders): s = s.replace("1", "+1") s = s.replace("-+1", "-1") coords_mob = TexMobject(s) - coords_mob.highlight(GREEN) + coords_mob.set_color(GREEN) coords_mob.next_to(sphere_words, DOWN) for slider, x in zip(self.sliders, coords): for mob in slider.real_estate_ticks, slider.dial: @@ -2824,11 +2824,11 @@ class FiveDBoxExampleWithSliders(FourDBoxExampleWithSliders): self.sliders[i].number_to_point(0.5)+MED_SMALL_BUFF*vect for i, vect in (0, LEFT), (-1, RIGHT) ]) - half_line.highlight(MAROON_B) + half_line.set_color(MAROON_B) half_label = TexMobject("0.5") half_label.scale(self.sliders[0].number_scale_val) half_label.next_to(half_line, LEFT, MED_SMALL_BUFF) - half_label.highlight(half_line.get_color()) + half_label.set_color(half_line.get_color()) curr_vector = self.get_vector() ghost_dials = VGroup(*[ @@ -2836,7 +2836,7 @@ class FiveDBoxExampleWithSliders(FourDBoxExampleWithSliders): for slider in self.sliders ]) point_25 = TexMobject("0.25") - point_25.highlight(half_label.get_color()) + point_25.set_color(half_label.get_color()) point_25.move_to(self.re_words[0], RIGHT) self.re_words.save_state() @@ -2877,12 +2877,12 @@ class FiveDBoxExampleWithSliders(FourDBoxExampleWithSliders): old_coords = self.sphere_words.target[1] new_coords = TexMobject(str(tuple(5*[0]))) new_coords.replace(old_coords, dim_to_match = 1) - new_coords.highlight(old_coords.get_color()) + new_coords.set_color(old_coords.get_color()) Transform(old_coords, new_coords).update(1) self.re_words.generate_target() new_re = TexMobject("0.31") - new_re.highlight(GREEN) + new_re.set_color(GREEN) old_re = self.re_words.target[0] new_re.move_to(old_re, RIGHT) Transform(old_re, new_re).update(1) @@ -2928,7 +2928,7 @@ class FiveDBoxExampleWithSliders(FourDBoxExampleWithSliders): words = TextMobject("Poking outside \\\\ the box!") words.to_edge(LEFT) - words.highlight(RED) + words.set_color(RED) arrow = Arrow( words.get_top(), self.sliders[0].dial, @@ -3066,7 +3066,7 @@ class TenDBoxExampleWithSliders(FiveDBoxExampleWithSliders): "bounding box!" ) words.to_edge(LEFT) - words.highlight(RED) + words.set_color(RED) arrow = Arrow( words.get_top(), self.sliders[0].dial, @@ -3083,7 +3083,7 @@ class TwoDOuterBox(TwoDInnerSphereTouchingBox): def construct(self): words = TextMobject("$4 \\!\\times\\! 4$ outer bounding box") words.next_to(self.plane, UP) - words.highlight(MAROON_B) + words.set_color(MAROON_B) line = Line( self.plane.coords_to_point(-2, -2), self.plane.coords_to_point(2, 2), @@ -3112,7 +3112,7 @@ class ThreeDOuterBoundingBoxWords(Scene): ) words.scale_to_fit_width(FRAME_WIDTH-1) words.to_edge(DOWN) - words.highlight(MAROON_B) + words.set_color(MAROON_B) self.play(Write(words)) self.wait(4) @@ -3228,7 +3228,7 @@ class ProportionOfSphereInBox(GraphScene): graph.point_from_proportion(0.3), UP+RIGHT, SMALL_BUFF ) - footnote.highlight(YELLOW) + footnote.set_color(YELLOW) self.play(ShowCreation(graph, run_time = 5, rate_func = None)) self.wait() @@ -3305,7 +3305,7 @@ class FunHighDSpherePhenomena(Scene): "Fun high-D sphere phenomena" ) title.to_edge(UP) - title.highlight(BLUE) + title.set_color(BLUE) h_line = Line(LEFT, RIGHT).scale(5) h_line.next_to(title, DOWN) self.add(title, h_line) @@ -3390,7 +3390,7 @@ class Skeptic(TeacherStudentsScene, SliderScene): box = Square(color = RED) box.next_to(self.sliders, LEFT) line = Line(box.get_center(), box.get_corner(UP+RIGHT)) - line.highlight(YELLOW) + line.set_color(YELLOW) self.student_says( analytic_thought, @@ -3460,7 +3460,7 @@ class JustBecauseYouCantVisualize(Scene): phrase += "something doesn't mean you can't\\\\ " phrase += "still think about it visually." phrase_mob = TextMobject(*phrase.split(" ")) - phrase_mob.highlight_by_tex("visual", YELLOW) + phrase_mob.set_color_by_tex("visual", YELLOW) phrase_mob.next_to(ORIGIN, UP) for part in phrase_mob: diff --git a/old_projects/hilbert/section1.py b/old_projects/hilbert/section1.py index 16d2bc93..16d9234c 100644 --- a/old_projects/hilbert/section1.py +++ b/old_projects/hilbert/section1.py @@ -438,7 +438,7 @@ class ListenToAllPixels(Scene): vibration_copy.mobject.stroke_width = 1 sub_vibrations = [ Vibrate( - string.copy().shift((n-1)*UP).highlight(colors[n]), + string.copy().shift((n-1)*UP).set_color(colors[n]), overtones = 1, spatial_period = 6./(n+1), temporal_period = 1./(n+1), @@ -743,7 +743,7 @@ class Order1PseudoHilbertCurve(Scene): cluster.center() cluster.scale(0.7) cluster.to_edge(UP, buff = 0.3) - cluster.highlight(GREEN) + cluster.set_color(GREEN) grid1 = Grid(1, 1) grid2 = Grid(2, 2) curve = HilbertCurve(order = 1) @@ -770,7 +770,7 @@ class Order2PseudoHilbertCurve(Scene): def construct(self): words = TextMobject("Order 2 Pseudo-Hilbert Curve") words.to_edge(UP, buff = 0.3) - words.highlight(GREEN) + words.set_color(GREEN) grid2 = Grid(2, 2) grid4 = Grid(4, 4, stroke_width = 2) # order_1_curve = HilbertCurve(order = 1) @@ -815,7 +815,7 @@ class Order2PseudoHilbertCurve(Scene): class Order3PseudoHilbertCurve(Scene): def construct(self): words = TextMobject("Order 3 Pseudo-Hilbert Curve") - words.highlight(GREEN) + words.set_color(GREEN) words.to_edge(UP) grid4 = Mobject( Grid(2, 2), @@ -899,7 +899,7 @@ class UseOrder8(Scene): mathy, bubble = get_mathy_and_bubble() bubble.write("For a 256x256 pixel array...") words = TextMobject("Order 8 Pseudo-Hilbert Curve") - words.highlight(GREEN) + words.set_color(GREEN) words.to_edge(UP, buff = 0.3) curve = HilbertCurve(order = 8) @@ -957,7 +957,7 @@ class RandyWithHeadphones(Scene): headphones.scale(0.1) headphones.stretch(2, 0) headphones.shift(1.2*UP+0.05*LEFT) - headphones.highlight(GREY) + headphones.set_color(GREY) randy = Randolph() self.add(randy, headphones) diff --git a/old_projects/hilbert/section2.py b/old_projects/hilbert/section2.py index 6265ce8d..74e1e090 100644 --- a/old_projects/hilbert/section2.py +++ b/old_projects/hilbert/section2.py @@ -69,7 +69,7 @@ class SectionTwo(Scene): class HilbertCurveIsPerfect(Scene): def construct(self): curve = HilbertCurve(order = 6) - curve.highlight(WHITE) + curve.set_color(WHITE) colored_curve = curve.copy() colored_curve.thin_out(3) lion = ImageMobject("lion", invert = False) @@ -196,7 +196,7 @@ class NotPixelatedSpace(Scene): self.wait() self.play(Transform(grid, space_mobject, run_time = 5)) self.remove(grid) - self.highlight_region(space_region, DARK_GREY) + self.set_color_region(space_region, DARK_GREY) self.wait() self.add(infinitely, detailed) self.wait() @@ -204,7 +204,7 @@ class NotPixelatedSpace(Scene): self.play(ShowCreation(arrows)) self.wait() self.clear() - self.highlight_region(space_region, DARK_GREY) + self.set_color_region(space_region, DARK_GREY) self.play(ShowCreation(line)) self.play(Transform(line, curve, run_time = 5)) @@ -331,7 +331,7 @@ class PseudoHilbertCurvesDontFillSpace(Scene): square.corner.add_line(ORIGIN, 3*RIGHT) square.digest_mobject_attrs() square.scale(2**(-5)) - square.corner.highlight( + square.corner.set_color( Color(rgb = curve.rgbas[curve.get_num_points()/3]) ) square.shift( @@ -486,7 +486,7 @@ class ContinuityRequired(Scene): "\\emph{continuous}", "if it is to represent a curve." ]) - words.split()[1].highlight(YELLOW_C) + words.split()[1].set_color(YELLOW_C) self.add(words) self.wait() @@ -522,14 +522,14 @@ class FormalDefinitionOfContinuity(Scene): Mobject.align_data(self.spiril1, self.spiril2) self.output = Mobject(self.spiril1, self.spiril2) self.output.ingest_submobjects() - self.output.highlight(GREEN_A) + self.output.set_color(GREEN_A) self.interval = UnitInterval() self.interval.scale_to_fit_width(FRAME_X_RADIUS-1) self.interval.to_edge(LEFT) self.input_dot = Dot(color = self.input_color) - self.output_dot = self.input_dot.copy().highlight(self.output_color) + self.output_dot = self.input_dot.copy().set_color(self.output_color) left, right = self.interval.get_left(), self.interval.get_right() self.input_homotopy = lambda (x, y, z, t) : (x, y, t) + interpolate(left, right, t) output_size = self.output.get_num_points()-1 @@ -861,7 +861,7 @@ class WonderfulPropertyOfPseudoHilbertCurves(Scene): text.to_edge(UP) text_parts = text.split() for index in 1, -1: - text_parts[index].highlight() + text_parts[index].set_color() starters = Mobject(*func_parts + [ Point(mob.get_center(), stroke_width=1) for mob in text_parts[5:] @@ -880,10 +880,10 @@ class FollowManyPoints(Scene): ]) parts = text.split() parts[-1].next_to(Mobject(*parts[:-1]), DOWN) - parts[-1].highlight(BLUE) - parts[3].highlight(BLUE) - parts[1].highlight() - parts[-2].highlight() + parts[-1].set_color(BLUE) + parts[3].set_color(BLUE) + parts[1].set_color() + parts[-2].set_color() text.to_edge(UP) curve = UnitInterval() curve.sort_points(lambda p : p[0]) @@ -926,7 +926,7 @@ class FormalDefinitionOfHilbertCurve(Scene): text.to_edge(UP) x1 = text.split()[1] x2 = text.split()[-2] - x2.highlight(BLUE) + x2.set_color(BLUE) explanation = TextMobject("Actual Hilbert curve function") exp_arrow = Arrow(explanation, text.split()[0]) curve = UnitInterval() @@ -944,7 +944,7 @@ class FormalDefinitionOfHilbertCurve(Scene): self.remove(explanation, exp_arrow) self.play(ShowCreation(curve)) self.play( - ApplyMethod(x1.highlight, BLUE), + ApplyMethod(x1.set_color, BLUE), ShowCreation(x_arrow), ShowCreation(dot) ) @@ -978,8 +978,8 @@ class ThreeThingsToProve(Scene): "=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")" ]) definition.to_edge(UP) - definition.split()[1].highlight(BLUE) - definition.split()[-2].highlight(BLUE) + definition.split()[1].set_color(BLUE) + definition.split()[-2].set_color(BLUE) intro = TextMobject("Three things need to be proven") prove_that = TextMobject("Prove that HC is $\\dots$") prove_that.scale(0.7) @@ -994,9 +994,9 @@ class ThreeThingsToProve(Scene): "Each point in the unit square is an output of HC", "\\end{enumerate}", ]).split() - items[1].highlight(GREEN) - items[3].highlight(YELLOW_C) - items[5].highlight(MAROON) + items[1].set_color(GREEN) + items[3].set_color(YELLOW_C) + items[5].set_color(MAROON) Mobject(*items).to_edge(RIGHT) self.add(definition) @@ -1062,7 +1062,7 @@ class ColorIntervals(Scene): brace_anim = ApplyMethod(brace.shift, 2*RIGHT) self.play( ApplyMethod( - number_line.highlight, + number_line.set_color, RED, lambda p : p[0] > n-6.2 and p[0] < n-4 and p[1] > -0.4 ), diff --git a/old_projects/hilbert/section3.py b/old_projects/hilbert/section3.py index 724eb4e5..a81e4ae9 100644 --- a/old_projects/hilbert/section3.py +++ b/old_projects/hilbert/section3.py @@ -100,7 +100,7 @@ class InfiniteResultsFiniteWorld(Scene): self.clear() self.add(left_mob, arrow, right_mob) ex = TextMobject("\\times") - ex.highlight(RED) + ex.set_color(RED) # ex.shift(arrow.get_center()) middle = TexMobject( "\\sum_{n=0}^N 2^n \\equiv -1 \\mod 2^{N+1}" @@ -150,7 +150,7 @@ class InfiniteResultsFiniteWorld(Scene): self.add(left_mob, arrow, right_mob) words = TextMobject("is equivalent to") words.shift(0.25*LEFT) - words.highlight(BLUE) + words.set_color(BLUE) new_left = left_mob.copy().shift(RIGHT) new_right = right_mob.copy() new_right.shift( @@ -230,29 +230,29 @@ class InfiniteObjectsEncapsulateFiniteObjects(Scene): ] ] - words[0].highlight(RED) + words[0].set_color(RED) words[1].next_to(words[0]) - words[2].highlight(GREEN).next_to(words[1]) + words[2].set_color(GREEN).next_to(words[1]) Mobject(*words).center().to_edge(UP) infinite_objects = [ TexMobject( "\\sum_{n=0}^\\infty", size = "\\normal" - ).highlight(RED_E), + ).set_color(RED_E), Sierpinski(order = 8).scale(0.3), TextMobject( "$\\exists$ something infinite $\\dots$" - ).highlight(RED_B) + ).set_color(RED_B) ] finite_objects = [ TexMobject( "\\sum_{n=0}^N", size = "\\normal" - ).highlight(GREEN_E), + ).set_color(GREEN_E), self.get_triangles(), TextMobject( "$\\forall$ finite somethings $\\dots$" - ).highlight(GREEN_B) + ).set_color(GREEN_B) ] for infinite, finite, n in zip(infinite_objects, finite_objects, it.count(1, 2)): infinite.next_to(words[0], DOWN, buff = n) diff --git a/old_projects/inventing_math.py b/old_projects/inventing_math.py index ed9082c2..11f66762 100644 --- a/old_projects/inventing_math.py +++ b/old_projects/inventing_math.py @@ -100,7 +100,7 @@ def zero_to_one_interval(): def draw_you(with_bubble = False): result = PiCreature() - result.give_straight_face().highlight("grey") + result.give_straight_face().set_color("grey") result.to_corner(LEFT+DOWN) result.rewire_part_attributes() if with_bubble: @@ -215,10 +215,10 @@ class ClearlyNonsense(Scene): (FRAME_X_RADIUS-0.5)*RIGHT + DOWN, tail = (max(this_way.points[:,0]), -1, 0) ) - how_here.highlight("red") - neg_1_arrow.highlight("red") - this_way.highlight("yellow") - right_arrow.highlight("yellow") + how_here.set_color("red") + neg_1_arrow.set_color("red") + this_way.set_color("yellow") + right_arrow.set_color("yellow") self.play(Transform( div_sum, @@ -241,7 +241,7 @@ class OutlineOfVideo(Scene): conv_sum.get_left(), conv_sum.get_right() ).rotate(np.pi, RIGHT).shift(0.75*UP*conv_sum.get_height()) - dots = conv_sum.split()[-2].highlight("green") + dots = conv_sum.split()[-2].set_color("green") dots.sort_points() arrow = Arrow( dots.get_bottom(), @@ -254,7 +254,7 @@ class OutlineOfVideo(Scene): for mob in div_sum, u_brace: mob.shift(DOWN) texts = [ - TextMobject(words).highlight("yellow") + TextMobject(words).set_color("yellow") for words in [ "1. Discover this", "2. Clarify what this means", @@ -263,7 +263,7 @@ class OutlineOfVideo(Scene): ] ] last_one_split = texts[-1].split() - last_one_split[1].highlight("skyblue") + last_one_split[1].set_color("skyblue") texts[-1] = Mobject(*last_one_split) texts[0].shift(overbrace.get_top()+texts[0].get_height()*UP) texts[1].shift(sum([ @@ -302,8 +302,8 @@ class OutlineOfVideo(Scene): # # \\end{itemize} # # """ # # ], size = "\\Small") -# # text.scale(1.5).to_edge(LEFT).shift(UP).highlight("white") -# # text.highlight("green", lambda (x, y, z) : x < -FRAME_X_RADIUS + 1) +# # text.scale(1.5).to_edge(LEFT).shift(UP).set_color("white") +# # text.set_color("green", lambda (x, y, z) : x < -FRAME_X_RADIUS + 1) # # line_one_first, equation, line_one_last, line_two = text.split() # # line_two.shift(2*DOWN) # # div_sum = divergent_sum().scale(0.5).shift(3*UP) @@ -330,7 +330,7 @@ class OutlineOfVideo(Scene): # sum_mob.shift(2*UP) # define.shift(2*DOWN) # define_parts = define.split() -# define_parts[1].highlight("skyblue") +# define_parts[1].set_color("skyblue") # self.add(sum_mob) # self.play(FadeIn(discover)) @@ -348,7 +348,7 @@ class YouAsMathematician(Scene): arrow = Arrow(you.get_center(), direction = LEFT) arrow.nudge(you.get_width()) for mob in arrow, explanation: - mob.highlight("yellow") + mob.set_color("yellow") equation = convergent_sum() bubble.add_content(equation) equation_parts = equation.split() @@ -433,7 +433,7 @@ class ZoomInOnInterval(Scene): interval = zero_to_one_interval().split() new_line = deepcopy(number_line) - new_line.highlight("black", lambda (x,y,z) : x < 0 or x > 1 or y < -0.2) + new_line.set_color("black", lambda (x,y,z) : x < 0 or x > 1 or y < -0.2) # height = new_line.get_height() new_line.scale(2*INTERVAL_RADIUS) new_line.shift(INTERVAL_RADIUS*LEFT) @@ -485,7 +485,7 @@ class DanceDotOnInterval(Scene): shift_val = 2*RIGHT*INTERVAL_RADIUS*(1-prop)*(prop**count) start = dots[0].get_center() line = Line(start, start + shift_val*RIGHT) - line.highlight(color_range.next()) + line.set_color(color_range.next()) self.play( ApplyMethod(dots[0].shift, shift_val), ShowCreation(line) @@ -513,10 +513,10 @@ class DanceDotOnInterval(Scene): partial_sums = TexMobject(PARTIAL_CONVERGENT_SUMS_TEXT, size = "\\small") partial_sums.scale(1.5).to_edge(UP) partial_sum_parts = partial_sums.split() - partial_sum_parts[0].highlight("yellow") + partial_sum_parts[0].set_color("yellow") for x in range(0, len(partial_sum_parts), 4): - partial_sum_parts[x+2].highlight("yellow") + partial_sum_parts[x+2].set_color("yellow") self.play(*[ FadeIn(partial_sum_parts[y]) for y in range(x, x+4) @@ -529,14 +529,14 @@ class OrganizePartialSums(Scene): partial_sums.scale(1.5).to_edge(UP) partial_sum_parts = partial_sums.split() for x in [0] + range(2, len(partial_sum_parts), 4): - partial_sum_parts[x].highlight("yellow") + partial_sum_parts[x].set_color("yellow") pure_sums = [ partial_sum_parts[x] for x in range(0, len(partial_sum_parts), 4) ] new_pure_sums = deepcopy(pure_sums) for pure_sum, count in zip(new_pure_sums, it.count(3, -1.2)): - pure_sum.center().scale(1/1.25).highlight("white") + pure_sum.center().scale(1/1.25).set_color("white") pure_sum.to_edge(LEFT).shift(2*RIGHT+count*UP) self.add(*partial_sum_parts) @@ -566,7 +566,7 @@ class SeeNumbersApproachOne(Scene): def construct(self): interval = zero_to_one_interval() arrow = Arrow(INTERVAL_RADIUS*RIGHT, tail=ORIGIN).nudge() - arrow.shift(DOWN).highlight("yellow") + arrow.shift(DOWN).set_color("yellow") num_dots = 6 colors = Color("green").range_to("yellow", num_dots) dots = Mobject(*[ @@ -575,7 +575,7 @@ class SeeNumbersApproachOne(Scene): ).scale(1+1.0/2.0**x).shift( INTERVAL_RADIUS*RIGHT +\ (INTERVAL_RADIUS/2.0**x)*LEFT - ).highlight(colors.next()) + ).set_color(colors.next()) for x in range(num_dots) ]) @@ -592,7 +592,7 @@ class OneAndInfiniteSumAreTheSameThing(Scene): one, equals, inf_sum = TexMobject([ "1", "=", "\\sum_{n=1}^\\infty \\frac{1}{2^n}" ]).split() - point = Point(equals.get_center()).highlight("black") + point = Point(equals.get_center()).set_color("black") self.add(one.shift(LEFT)) self.wait() @@ -613,7 +613,7 @@ class HowDoYouDefineInfiniteSums(Scene): ["How", " do", " you,\\\\", "\\emph{define}"], size = "\\Huge" ).shift(UP).split() - text[-1].shift(3*DOWN).highlight("skyblue") + text[-1].shift(3*DOWN).set_color("skyblue") sum_mob = TexMobject("\\sum_{n=0}^\\infty{a_n}") text[-1].shift(LEFT) sum_mob.shift(text[-1].get_center()+2*RIGHT) @@ -637,14 +637,14 @@ class LessAboutNewThoughts(Scene): "Generating", " new", " thoughts", "$\\rightarrow$", "useful definitions" ], size = "\\large").split() - gen_cross = TexMobject("\\hline").highlight("red") + gen_cross = TexMobject("\\hline").set_color("red") new_cross = deepcopy(gen_cross) for cross, mob in [(gen_cross, generating), (new_cross, new)]: cross.replace(mob) cross.stretch_to_fit_height(0.03) - disecting = TextMobject("Disecting").highlight("green") + disecting = TextMobject("Disecting").set_color("green") disecting.shift(generating.get_center() + 0.6*UP) - old = TextMobject("old").highlight("green") + old = TextMobject("old").set_color("green") old.shift(new.get_center()+0.6*UP) kwargs = {"run_time" : 0.25} @@ -690,11 +690,11 @@ class ListOfPartialSums(Scene): ) self.wait() self.play(*[ - ApplyMethod(s.highlight, "yellow", rate_func = there_and_back) + ApplyMethod(s.set_color, "yellow", rate_func = there_and_back) for s in sums ]) self.wait() - self.add(one.highlight("green")) + self.add(one.set_color("green")) self.wait() @@ -711,7 +711,7 @@ class ShowDecreasingDistance(Scene): horiz_line = Line(vert_line0.end, vert_line1.end) lines = [vert_line0, vert_line1, horiz_line] for line in lines: - line.highlight("green") + line.set_color("green") dots = Mobject(*[ Dot().scale(1.0/(n+1)).shift((1+partial_sum(n))*RIGHT) for n in range(10) @@ -724,7 +724,7 @@ class ShowDecreasingDistance(Scene): ApplyMethod(vert_line0.shift, RIGHT), Transform( horiz_line, - Line(vert_line0.end+RIGHT, vert_line1.end).highlight("green") + Line(vert_line0.end+RIGHT, vert_line1.end).set_color("green") ), ShowCreation(dots), run_time = 2.5 @@ -754,7 +754,7 @@ class CircleZoomInOnOne(Scene): self.add(number_line, dots) self.play( - Transform(circle, Point(2*RIGHT).highlight("white")), + Transform(circle, Point(2*RIGHT).set_color("white")), run_time = 5.0 ) @@ -848,7 +848,7 @@ class DefineInfiniteSum(Scene): "\\text{\\emph{Define} }", "\\sum_{n = 0}^\\infty a_n = X" ]).split() - define.highlight("skyblue") + define.set_color("skyblue") expression = Mobject(define, infinite_sum) self.add(expression) @@ -864,7 +864,7 @@ class DefineInfiniteSum(Scene): Line(FRAME_Y_RADIUS*UP+side, side+bottom) ] self.play(*[ - ShowCreation(line.highlight("white")) + ShowCreation(line.set_color("white")) for line in lines ]) self.wait() @@ -894,7 +894,7 @@ class DefineInfiniteSum(Scene): esses = np.array(terms)[range(0, len(terms), 3)] other_terms = filter(lambda m : m not in esses, terms) self.play(*[ - ApplyMethod(ess.highlight, "yellow") + ApplyMethod(ess.set_color, "yellow") for ess in esses ]) @@ -916,7 +916,7 @@ class DefineInfiniteSum(Scene): ]) lines = [ - Line(x+0.25*DOWN, x+0.25*UP).highlight("white") + Line(x+0.25*DOWN, x+0.25*UP).set_color("white") for y in [-1, -0.01, 1, 0.01] for x in [ex_point+y*RIGHT] ] @@ -937,7 +937,7 @@ class YouJustInventedSomeMath(Scene): mob.shift(1.3*DOWN) # you = draw_you().center().rewire_part_attributes() # smile = PiCreature().mouth.center().shift(you.mouth.get_center()) - you = PiCreature().highlight("grey") + you = PiCreature().set_color("grey") you.center().rewire_part_attributes() self.add(you) @@ -1202,7 +1202,7 @@ class PlugNumbersIntoRightside(Scene): num.scale(scale_factor) num.shift(rhs[1].get_center()) num.shift(0.1*RIGHT + 0.08*UP) - num.highlight("green") + num.set_color("green") if num_string == "(-1)": num.shift(0.3*RIGHT) right_words = TextMobject( @@ -1219,8 +1219,8 @@ class PlugNumbersIntoRightside(Scene): lhs.get_center() + 0.3*DOWN, tail = left_words.get_center() + 0.3*UP )) - right_words.highlight("green") - left_words.highlight("yellow") + right_words.set_color("green") + left_words.set_color("yellow") self.add(lhs, *rhs) @@ -1331,7 +1331,7 @@ class ListPartialDivergentSums(Scene): self.play(FadeIn(words), ShowCreation(arrow)) for x in range(0, len(terms), 2): self.play( - ApplyMethod(terms[x].highlight, "green"), + ApplyMethod(terms[x].set_color, "green"), run_time = 0.1 ) self.wait() @@ -1364,7 +1364,7 @@ class SumPowersOfTwoAnimation(Scene): topbrace = Underbrace(top_brace_left, right).rotate(np.pi, RIGHT) bottombrace = Underbrace(bottom_brace_left, right) colors = Color("yellow").range_to("purple", iterations) - curr_dots.highlight(colors.next()) + curr_dots.set_color(colors.next()) equation = TexMobject( "1+2+4+\\cdots+2^n=2^{n+1} - 1", size = "\\Huge" @@ -1391,7 +1391,7 @@ class SumPowersOfTwoAnimation(Scene): shift_val = (2**n)*(dot_width+dot_buff) right += shift_val new_dots = Mobject(new_dot, curr_dots) - new_dots.highlight(colors.next()).shift(shift_val) + new_dots.set_color(colors.next()).shift(shift_val) alt_bottombrace = deepcopy(bottombrace).shift(shift_val) alt_bottom_num = deepcopy(bottom_num).shift(shift_val) alt_topbrace = deepcopy(alt_bottombrace).rotate(np.pi, RIGHT) @@ -1457,7 +1457,7 @@ class PretendTheyDoApproachNegativeOne(RearrangeEquation): (lambda n : str(2**(n+1)), ["\\vdots", da, "0"]), ] ] - columns[-1].highlight() + columns[-1].set_color() columns[2].shift(0.2*DOWN) shift_val = 3*RIGHT for column in columns: @@ -1526,7 +1526,7 @@ class DistanceIsAFunction(Scene): ("2", "3", "7"), ("\\frac{1}{2}", "100", "\\frac{4}{5}"), ] - dist.highlight("orange") + dist.set_color("orange") self.add(dist) self.wait() elif mode == "Euclidian": @@ -1546,7 +1546,7 @@ class DistanceIsAFunction(Scene): ("3", "7", "\\frac{1}{4}"), ("\\frac{3}{2}", "1", "2"), ] - dist.highlight("green") + dist.set_color("green") self.add(dist) self.wait() example_mobs = [ @@ -1619,9 +1619,9 @@ class NameShiftInvarianceProperty(Scene): label = TextMobject("Shifted values") label.shift(u_brace.get_center()+0.5*DOWN) name = TextMobject("``Shift Invariance''") - name.highlight("green").to_edge(UP) + name.set_color("green").to_edge(UP) for mob in u_brace, label: - mob.highlight("yellow") + mob.set_color("yellow") self.add(prop) self.play(ShimmerIn(label), ShimmerIn(u_brace)) @@ -1711,18 +1711,18 @@ class RoomsAndSubrooms(Scene): b_set = [1.5*UP, 1.5*DOWN] c_set = [LEFT, RIGHT] rectangle_groups = [ - [Rectangle(7, 12).highlight(colors[0])], + [Rectangle(7, 12).set_color(colors[0])], [ - Rectangle(6, 5).shift(a).highlight(colors[1]) + Rectangle(6, 5).shift(a).set_color(colors[1]) for a in a_set ], [ - Rectangle(2, 4).shift(a + b).highlight(colors[2]) + Rectangle(2, 4).shift(a + b).set_color(colors[2]) for a in a_set for b in b_set ], [ - Rectangle(1, 1).shift(a+b+c).highlight(colors[3]) + Rectangle(1, 1).shift(a+b+c).set_color(colors[3]) for a in a_set for b in b_set for c in c_set @@ -1787,7 +1787,7 @@ class RoomsAndSubroomsWithNumbers(Scene): ) rect.sort_points(np.linalg.norm) rect.to_edge(LEFT, buff = 0.2).shift(n*side_buff*RIGHT) - rect.highlight(colors[n]) + rect.set_color(colors[n]) rectangles.append(rect) for rect in rectangles: self.play(ShowCreation(rect)) @@ -1911,7 +1911,7 @@ class RoomsAndSubroomsWithNumbers(Scene): ) for pair in sample(pairs, min(10, len(pairs))): for index in pair: - num_mobs[index].highlight("green") + num_mobs[index].set_color("green") self.play(*[ ApplyMethod( num_mobs[index].rotate_in_place, np.pi/10, @@ -1921,7 +1921,7 @@ class RoomsAndSubroomsWithNumbers(Scene): ]) self.wait() for index in pair: - num_mobs[index].highlight("white") + num_mobs[index].set_color("white") @staticmethod def clear_way_for_text(text, mobjects): @@ -1945,7 +1945,7 @@ class DeduceWhereNegativeOneFalls(Scene): colors = list(get_room_colors()) num_labels = len(colors) texts = [ - Mobject(parts[0], parts[1].highlight(color)) + Mobject(parts[0], parts[1].set_color(color)) for count, color in zip(it.count(), colors) for parts in [TextMobject([ "Represented (heuristically) \\\\ by being in the same \\\\", @@ -2010,17 +2010,17 @@ class PAdicMetric(Scene): def construct(self): p_str, text = TextMobject(["$p$", "-adic metric"]).shift(2*UP).split() primes = [TexMobject(str(p)) for p in [2, 3, 5, 7, 11, 13, 17, 19, 23]] - p_str.highlight("yellow") + p_str.set_color("yellow") colors = Color("green").range_to("skyblue", len(primes)) new_numbers = TextMobject("Completely new types of numbers!") - new_numbers.highlight("skyblue").shift(2.3*DOWN) + new_numbers.set_color("skyblue").shift(2.3*DOWN) arrow = Arrow(2*DOWN, tail = 1.7*UP) curr = deepcopy(p_str) self.add(curr, text) self.wait() for prime, count in zip(primes, it.count()): - prime.scale(1.0).highlight(colors.next()) + prime.scale(1.0).set_color(colors.next()) prime.shift(center_of_mass([p_str.get_top(), p_str.get_center()])) self.play(DelayByOrder(Transform(curr, prime))) self.wait() @@ -2040,7 +2040,7 @@ class PAdicMetric(Scene): ), DelayByOrder(Transform( start, - Point(arrow.points[0]).highlight("white") + Point(arrow.points[0]).set_color("white") )) ) self.play(ShimmerIn(end)) @@ -2068,7 +2068,7 @@ class FuzzyDiscoveryToNewMath(Scene): Line(UP, ORIGIN), ] for line, char in zip(triangle_lines, ["a", "c", "b"]): - line.highlight("blue") + line.set_color("blue") char_mob = TexMobject(char).scale(0.25) line.add(char_mob.shift(line.get_center())) triangle = Mobject(*triangle_lines) @@ -2162,7 +2162,7 @@ class DiscoveryAndInvention(Scene): for color in Color("yellow").range_to("red", 4): for arrow in arrows: self.play( - ShowCreation(deepcopy(arrow).highlight(color)), + ShowCreation(deepcopy(arrow).set_color(color)), run_time = 0.25 ) diff --git a/old_projects/leibniz.py b/old_projects/leibniz.py index 90772673..f854ce2a 100644 --- a/old_projects/leibniz.py +++ b/old_projects/leibniz.py @@ -215,7 +215,7 @@ class Introduction(PiCreatureScene): morty = self.get_primary_pi_creature() video = VideoIcon() - video.highlight(TEAL) + video.set_color(TEAL) video.next_to(morty.get_corner(UP+LEFT), UP) self.play( @@ -263,7 +263,7 @@ class Introduction(PiCreatureScene): ) for title in titles: title.next_to(screen, UP) - title.highlight(YELLOW) + title.set_color(YELLOW) self.play( ShowCreation(screen), FadeIn(titles[0]) @@ -287,7 +287,7 @@ class Introduction(PiCreatureScene): label = TexMobject("1 + 2i") label.add_background_rectangle() label.next_to(dot, UP+RIGHT, buff = SMALL_BUFF) - label.highlight(YELLOW) + label.set_color(YELLOW) plane.label = label plane.add(dot, label) return plane @@ -296,7 +296,7 @@ class Introduction(PiCreatureScene): result = TexMobject("\\pi", "=", "%.8f\\dots"%np.pi) pi = result.get_part_by_tex("pi") pi.scale(2, about_point = pi.get_right()) - pi.highlight(MAROON_B) + pi.set_color(MAROON_B) return result class ShowSum(TeacherStudentsScene): @@ -347,7 +347,7 @@ class ShowSum(TeacherStudentsScene): "\\frac{\\pi}{4}", "=", ) lhs.next_to(sum_mob, LEFT) - lhs.highlight_by_tex("pi", YELLOW) + lhs.set_color_by_tex("pi", YELLOW) sum_arrow = Arrow( lhs.get_part_by_tex("pi").get_bottom(), sum_point @@ -490,7 +490,7 @@ class CertainRegularityInPrimes(LatticePointScene): "+", "\\frac{1}{5}", "-", "\\frac{1}{7}", "+\\cdots" ) - formula.highlight_by_tex("pi", YELLOW) + formula.set_color_by_tex("pi", YELLOW) formula.add_background_rectangle() formula.to_corner(UP+LEFT, buff = MED_SMALL_BUFF) self.add_foreground_mobject(formula) @@ -541,9 +541,9 @@ class Outline(PiCreatureScene): TextMobject("5. Shift perspective"), ) for step in steps[1:3]: - step.highlight_by_tex("1", RED, substring = False) - step.highlight_by_tex("i", RED, substring = False) - step.highlight_by_tex("4", GREEN, substring = False) + step.set_color_by_tex("1", RED, substring = False) + step.set_color_by_tex("i", RED, substring = False) + step.set_color_by_tex("4", GREEN, substring = False) steps.arrange_submobjects( DOWN, buff = MED_LARGE_BUFF, @@ -557,7 +557,7 @@ class Outline(PiCreatureScene): question = TexMobject("\\pi", "=???") pi = question.get_part_by_tex("pi") pi.scale(2, about_point = pi.get_right()) - pi.highlight(YELLOW) + pi.set_color(YELLOW) question.next_to(self.pi_creature.body, LEFT, aligned_edge = UP) self.think( "Who am I really?", @@ -659,8 +659,8 @@ class Outline(PiCreatureScene): arrow.next_to(chi, DOWN, SMALL_BUFF) arrows.add(arrow) value = TexMobject(str(chi_func(n))) - value.highlight_by_tex("1", BLUE) - value.highlight_by_tex("-1", GREEN) + value.set_color_by_tex("1", BLUE) + value.set_color_by_tex("-1", GREEN) value.next_to(arrow, DOWN) numerators.add(value) group = VGroup(chis, arrows, numerators) @@ -807,7 +807,7 @@ class CountLatticePoints(LatticePointScene): def draw_lattice_points_in_circle(self): circle = self.get_circle() radius = Line(ORIGIN, circle.get_right()) - radius.highlight(RED) + radius.set_color(RED) brace = Brace(radius, DOWN, buff = SMALL_BUFF) radius_label = brace.get_text( str(self.max_lattice_point_radius), @@ -874,13 +874,13 @@ class CountLatticePoints(LatticePointScene): radius_10_eq, radius_million_eq, radius_R_eq = equations for eq in equations: for tex_mob in eq: - tex_mob.highlight_by_tex("0", BLUE) + tex_mob.set_color_by_tex("0", BLUE) radius_10_eq.to_corner(UP+LEFT) radius_million_eq.next_to(radius_10_eq, DOWN, LARGE_BUFF) radius_million_eq.to_edge(LEFT) brace = Brace(radius_million_eq, DOWN) brace.add(brace.get_text("More accurate")) - brace.highlight(YELLOW) + brace.set_color(YELLOW) background = FullScreenFadeRectangle(opacity = 0.9) @@ -906,7 +906,7 @@ class CountLatticePoints(LatticePointScene): arg_separator = "" ) alt_count.to_corner(UP+LEFT) - alt_count.highlight_by_tex("something", MAROON_B) + alt_count.set_color_by_tex("something", MAROON_B) self.radius_R_eq.next_to(alt_count, RIGHT) final_group = VGroup( @@ -1024,9 +1024,9 @@ class CountThroughRings(LatticePointScene): x_spot = self.plane.coords_to_point(x, 0) radial_line = Line(self.plane_center, dot) h_line = Line(self.plane_center, x_spot) - h_line.highlight(GREEN) + h_line.set_color(GREEN) v_line = Line(x_spot, dot) - v_line.highlight(RED) + v_line.set_color(RED) distance = TexMobject("\\sqrt{a^2 + b^2}") distance_num = TexMobject("\\sqrt{%d}"%(x**2 + y**2)) @@ -1088,7 +1088,7 @@ class CountThroughRings(LatticePointScene): left_counts = VGroup() left_roots = VGroup() for mob in left_list: - mob[1].highlight(YELLOW) + mob[1].set_color(YELLOW) left_counts.add(VGroup(mob[1])) mob.add_background_rectangle() left_roots.add(VGroup(mob[0], mob[1][0])) @@ -1104,7 +1104,7 @@ class CountThroughRings(LatticePointScene): TexMobject("%d, "%count) for count in counts ]) - top_list.highlight(YELLOW) + top_list.set_color(YELLOW) top_list.arrange_submobjects(RIGHT, aligned_edge = DOWN) top_list.scale_to_fit_width(FRAME_WIDTH - MED_LARGE_BUFF) top_list.to_edge(UP, buff = SMALL_BUFF) @@ -1221,8 +1221,8 @@ class LookAtExampleRing(LatticePointScene): for label in labels: label.x = label[1] label.y = label[3] - label.x.highlight(x_color) - label.y.highlight(y_color) + label.x.set_color(x_color) + label.y.set_color(y_color) label.add_background_rectangle() for label, point in zip(labels, points): @@ -1244,8 +1244,8 @@ class LookAtExampleRing(LatticePointScene): for tex_mob in sums_of_squares: tex_mob.x = tex_mob[0] tex_mob.y = tex_mob[3] - tex_mob.x.highlight(x_color) - tex_mob.y.highlight(y_color) + tex_mob.x.set_color(x_color) + tex_mob.y.set_color(y_color) tex_mob.add_background_rectangle() tex_mob.to_corner(UP+RIGHT) @@ -1269,7 +1269,7 @@ class LookAtExampleRing(LatticePointScene): curr_sum_of_squares = sums_of_squares[0] self.play( Write(curr_label), - curr_label.point.highlight, PINK + curr_label.point.set_color, PINK ) x, y = curr_label.x.copy(), curr_label.y.copy() self.play( @@ -1286,8 +1286,8 @@ class LookAtExampleRing(LatticePointScene): for label, sum_of_squares in zip(labels, sums_of_squares)[1:]: self.play( ReplacementTransform(curr_label, label), - label.point.highlight, PINK, - curr_label.point.highlight, self.dot_color + label.point.set_color, PINK, + curr_label.point.set_color, self.dot_color ) curr_label = label self.play( @@ -1324,8 +1324,8 @@ class LookAtExampleRing(LatticePointScene): circle = self.get_circle(radius = R) radius, root_label = self.get_radial_line_with_label(R) equation = TexMobject("11 \\ne ", "a", "^2", "+", "b", "^2") - equation.highlight_by_tex("a", GREEN) - equation.highlight_by_tex("b", RED) + equation.set_color_by_tex("a", GREEN) + equation.set_color_by_tex("b", RED) equation.add_background_rectangle() equation.to_corner(UP+RIGHT) @@ -1411,25 +1411,25 @@ class IntroduceComplexConjugate(LatticePointScene): x_point = self.plane.coords_to_point(x, 0) h_arrow = Arrow(self.plane_center, x_point, buff = 0) v_arrow = Arrow(x_point, point, buff = 0) - h_arrow.highlight(x_color) - v_arrow.highlight(y_color) + h_arrow.set_color(x_color) + v_arrow.set_color(y_color) x_coord = TexMobject(str(x)) x_coord.next_to(h_arrow, DOWN, SMALL_BUFF) - x_coord.highlight(x_color) + x_coord.set_color(x_color) x_coord.add_background_rectangle() y_coord = TexMobject(str(y)) imag_y_coord = TexMobject(str(y) + "i") for coord in y_coord, imag_y_coord: coord.next_to(v_arrow, RIGHT, SMALL_BUFF) - coord.highlight(y_color) + coord.set_color(y_color) coord.add_background_rectangle() tuple_label = TexMobject(str((x, y))) - tuple_label[1].highlight(x_color) - tuple_label[3].highlight(y_color) + tuple_label[1].set_color(x_color) + tuple_label[3].set_color(y_color) complex_label = TexMobject("%d+%di"%(x, y)) - complex_label[0].highlight(x_color) - complex_label[2].highlight(y_color) + complex_label[0].set_color(x_color) + complex_label[2].set_color(y_color) for label in tuple_label, complex_label: label.add_background_rectangle() label.next_to(dot, UP+RIGHT, buff = 0) @@ -1495,8 +1495,8 @@ class IntroduceComplexConjugate(LatticePointScene): equation.to_corner(UP+RIGHT, buff = MED_SMALL_BUFF) equation.shift(MED_LARGE_BUFF*DOWN) for tex_mob in equation: - tex_mob.highlight_by_tex(str(x), self.x_color) - tex_mob.highlight_by_tex(str(y), self.y_color) + tex_mob.set_color_by_tex(str(x), self.x_color) + tex_mob.set_color_by_tex(str(y), self.y_color) tex_mob.add_background_rectangle() dot = Dot( @@ -1504,8 +1504,8 @@ class IntroduceComplexConjugate(LatticePointScene): color = self.dot_color ) label = TexMobject("%d-%di"%(x, y)) - label[0].highlight(self.x_color) - label[2].highlight(self.y_color) + label[0].set_color(self.x_color) + label[2].set_color(self.y_color) label.add_background_rectangle() label.next_to(dot, DOWN+RIGHT, buff = 0) @@ -1584,8 +1584,8 @@ class IntroduceComplexConjugate(LatticePointScene): alt_y_term = TexMobject("+", str(y), "^2") alt_y_term.move_to(expansion[1], LEFT) for tex_mob in list(expansion) + [alt_y_term]: - tex_mob.highlight_by_tex(str(x), self.x_color) - tex_mob.highlight_by_tex(str(y), self.y_color) + tex_mob.set_color_by_tex(str(x), self.x_color) + tex_mob.set_color_by_tex(str(y), self.y_color) tex_mob.rect = BackgroundRectangle(tex_mob) x1 = self.equation[-2][1][1] @@ -1707,7 +1707,7 @@ class IntroduceComplexConjugate(LatticePointScene): self.play(ShowCreation(top_dot.line)) mover = VGroup( - top_dot.line.copy().highlight(PINK), + top_dot.line.copy().set_color(PINK), top_dot.copy() ) self.play(FadeIn( @@ -1767,8 +1767,8 @@ class NameGaussianIntegers(LatticePointScene): ) a = label.get_part_by_tex("a") b = label.get_part_by_tex("b") - a.highlight(GREEN) - b.highlight(RED) + a.set_color(GREEN) + b.set_color(RED) label.add_background_rectangle() label.to_corner(UP+RIGHT) integers = TextMobject("Integers") @@ -1856,8 +1856,8 @@ class NameGaussianIntegers(LatticePointScene): dot.equation = equation for mob in label, equation: - mob.highlight_by_tex(x_str, GREEN, substring = False) - mob.highlight_by_tex(y_str, RED, substring = False) + mob.set_color_by_tex(x_str, GREEN, substring = False) + mob.set_color_by_tex(y_str, RED, substring = False) dot.line_pair = VGroup(*[ Line( @@ -1877,8 +1877,8 @@ class NameGaussianIntegers(LatticePointScene): last_dot = None for dot in self.circle_dots: anims = [ - dot.highlight, PINK, - dot.conjugate_dot.highlight, PINK, + dot.set_color, PINK, + dot.conjugate_dot.set_color, PINK, ] if last_dot is None: anims += [ @@ -1888,8 +1888,8 @@ class NameGaussianIntegers(LatticePointScene): anims += map(ShowCreation, dot.line_pair) else: anims += [ - last_dot.highlight, self.dot_color, - last_dot.conjugate_dot.highlight, self.dot_color, + last_dot.set_color, self.dot_color, + last_dot.conjugate_dot.set_color, self.dot_color, ReplacementTransform(last_dot.equation, dot.equation), ReplacementTransform(last_dot.label, dot.label), ReplacementTransform(last_dot.line_pair, dot.line_pair), @@ -1914,14 +1914,14 @@ class FactorOrdinaryNumber(TeacherStudentsScene): ])) for alt_rhs in alt_rhs_list: if "\\ne" in alt_rhs.get_tex_string(): - alt_rhs.highlight(RED) + alt_rhs.set_color(RED) else: - alt_rhs.highlight(GREEN) + alt_rhs.set_color(GREEN) alt_rhs.move_to(equation.get_right()) number.save_state() number.next_to(self.teacher, UP+LEFT) title = TextMobject("Almost", "Unique factorization") - title.highlight_by_tex("Almost", YELLOW) + title.set_color_by_tex("Almost", YELLOW) title.to_edge(UP) self.play( @@ -2000,11 +2000,11 @@ class IntroduceGaussianPrimes(LatticePointScene, PiCreatureScene): ] ] five_dot = dots[0] - five_dot.highlight(YELLOW) + five_dot.set_color(YELLOW) p_dots = VGroup(*dots[1:]) p1_dot, p2_dot, p3_dot, p4_dot, p5_dot, p6_dot = p_dots - VGroup(p1_dot, p3_dot, p5_dot).highlight(PINK) - VGroup(p2_dot, p4_dot, p6_dot).highlight(RED) + VGroup(p1_dot, p3_dot, p5_dot).set_color(PINK) + VGroup(p2_dot, p4_dot, p6_dot).set_color(RED) labels = [ TexMobject(tex).add_background_rectangle() @@ -2043,7 +2043,7 @@ class IntroduceGaussianPrimes(LatticePointScene, PiCreatureScene): ) VGroup( times_i, times_neg_i, times_i_arc, times_neg_i_arc - ).highlight(MAROON_B) + ).set_color(MAROON_B) gaussian_prime = TextMobject("$\\Rightarrow$ ``Gaussian prime''") gaussian_prime.add_background_rectangle() @@ -2161,13 +2161,13 @@ class FromIntegerFactorsToGaussianFactors(TeacherStudentsScene): expression.shift(2*UP) two = expression.get_part_by_tex("2") five = expression.get_part_by_tex("5") - two.highlight(BLUE) - five.highlight(GREEN) + two.set_color(BLUE) + five.set_color(GREEN) two.factors = TexMobject("(1+i)", "(1-i)") five.factors = TexMobject("(2+i)", "(2-i)") for mob, vect in (two, DOWN), (five, UP): mob.factors.next_to(mob, vect, LARGE_BUFF) - mob.factors.highlight(mob.get_color()) + mob.factors.set_color(mob.get_color()) mob.arrows = VGroup(*[ Arrow( mob.get_edge_center(vect), @@ -2235,14 +2235,14 @@ class FactorizationPattern(Scene): Dot(self.number_line.number_to_point(prime)) for prime in primes ]) - dots.highlight(GREEN) + dots.set_color(GREEN) prime_mobs = VGroup(*map(TexMobject, map(str, primes))) arrows = VGroup() for prime_mob, dot in zip(prime_mobs, dots): prime_mob.next_to(dot, UP, LARGE_BUFF) - prime_mob.highlight(dot.get_color()) + prime_mob.set_color(dot.get_color()) arrow = Arrow(prime_mob, dot, buff = SMALL_BUFF) - arrow.highlight(dot.get_color()) + arrow.set_color(dot.get_color()) arrows.add(arrow) factorizations = VGroup(*[ @@ -2291,14 +2291,14 @@ class FactorizationPattern(Scene): Dot(self.number_line.number_to_point(prime)) for prime in primes ]) - dots.highlight(RED) + dots.set_color(RED) prime_mobs = VGroup(*map(TexMobject, map(str, primes))) arrows = VGroup() for prime_mob, dot in zip(prime_mobs, dots): prime_mob.next_to(dot, UP, LARGE_BUFF) - prime_mob.highlight(dot.get_color()) + prime_mob.set_color(dot.get_color()) arrow = Arrow(prime_mob, dot, buff = SMALL_BUFF) - arrow.highlight(dot.get_color()) + arrow.set_color(dot.get_color()) arrows.add(arrow) words = TextMobject("Already Gaussian primes") @@ -2358,7 +2358,7 @@ class FactorizationPattern(Scene): two = TexMobject("2") two.next_to(two_dot, UP, LARGE_BUFF) arrow = Arrow(two, two_dot, buff = SMALL_BUFF) - VGroup(two_dot, two, arrow).highlight(YELLOW) + VGroup(two_dot, two, arrow).set_color(YELLOW) mover = two.copy() mover.generate_target() @@ -2375,7 +2375,7 @@ class FactorizationPattern(Scene): times_i = TexMobject("\\times i") # times_i.scale(1.5) times_i.next_to(time_i_arrow, DOWN) - times_i.highlight(time_i_arrow.get_color()) + times_i.set_color(time_i_arrow.get_color()) words = TextMobject("You'll see why this matters...") words.next_to(times_i, DOWN) words.shift_onto_screen() @@ -2419,13 +2419,13 @@ class FactorTwo(LatticePointScene): } def construct(self): two_dot = Dot(self.plane.coords_to_point(2, 0)) - two_dot.highlight(YELLOW) + two_dot.set_color(YELLOW) factor_dots = VGroup(*[ Dot(self.plane.coords_to_point(1, u)) for u in 1, -1 ]) two_label = TexMobject("2").next_to(two_dot, DOWN) - two_label.highlight(YELLOW) + two_label.set_color(YELLOW) two_label.add_background_rectangle() factor_labels = VGroup(*[ TexMobject(tex).add_background_rectangle().next_to(dot, vect) @@ -2433,11 +2433,11 @@ class FactorTwo(LatticePointScene): ["1+i", "1-i"], factor_dots, [UP, DOWN] ) ]) - VGroup(factor_labels, factor_dots).highlight(MAROON_B) + VGroup(factor_labels, factor_dots).set_color(MAROON_B) for dot in it.chain(factor_dots, [two_dot]): line = Line(self.plane_center, dot.get_center()) - line.highlight(dot.get_color()) + line.set_color(dot.get_color()) dot.add(line) self.play( @@ -2455,7 +2455,7 @@ class FactorTwo(LatticePointScene): ]) self.wait(2) dot_copy = factor_dots[1].copy() - dot_copy.highlight(RED) + dot_copy.set_color(RED) for angle in np.pi/2, -np.pi/2: self.play(Rotate(dot_copy, angle, run_time = 2)) self.wait(2) @@ -2505,7 +2505,7 @@ class IntroduceRecipe(Scene): strings = ("a", "b", self.N_string) colors = (self.x_color, self.y_color, self.N_color) for tex, color in zip(strings, colors): - title.highlight_by_tex(tex, color, substring = False) + title.set_color_by_tex(tex, color, substring = False) title.to_edge(UP, buff = MED_SMALL_BUFF) h_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS) h_line.next_to(title, DOWN) @@ -2553,11 +2553,11 @@ class IntroduceRecipe(Scene): mob.underlying_number = factor y = complex(factor).imag if y == 0: - mob.highlight(self.i_zero_color) + mob.set_color(self.i_zero_color) elif y > 0: - mob.highlight(self.i_positive_color) + mob.set_color(self.i_positive_color) elif y < 0: - mob.highlight(self.i_negative_color) + mob.set_color(self.i_negative_color) movers = VGroup() mover = self.integer_factorization[0].copy() mover.target = factorization[0] @@ -2727,7 +2727,7 @@ class IntroduceRecipe(Scene): product_mob = TexMobject( self.complex_number_to_tex(product) ) - product_mob.highlight(color) + product_mob.set_color(color) product_mob.next_to(line, DOWN) product_mobjects.add(product_mob) self.product_mobjects = product_mobjects @@ -2892,7 +2892,7 @@ class WriteAlternateLastStep(IntroduceRecipe): output_words, arrow = self.output_label_group cross = TexMobject("\\times") cross.replace(output_words, stretch = True) - cross.highlight(RED) + cross.set_color(RED) self.add(output_words, arrow) self.play(Write(cross)) @@ -2921,7 +2921,7 @@ class ThreeOutputsAsLatticePointsContinued(ThreeOutputsAsLatticePoints): ]) for words, color in zip(words_group, self.colors): words.add_background_rectangle() - words.highlight(color) + words.set_color(color) words_group.arrange_submobjects(DOWN, aligned_edge = LEFT) words_group.to_corner(UP+LEFT, buff = MED_SMALL_BUFF) angles = [np.pi/2, np.pi, -np.pi/2] @@ -2935,7 +2935,7 @@ class ThreeOutputsAsLatticePointsContinued(ThreeOutputsAsLatticePoints): dots_copy = original_dots.copy() self.play( dots_copy.rotate, angle, - dots_copy.highlight, color, + dots_copy.set_color, color, path_arc = angle ) self.wait() @@ -3272,8 +3272,8 @@ class SummarizeCountingRule(Show125Circle): self.play(FadeIn(factorization)) self.wait() self.play( - five.highlight, GREEN, - thirteen.highlight, GREEN, + five.set_color, GREEN, + thirteen.set_color, GREEN, FadeIn(five_brace), FadeIn(thirteen_brace), ) @@ -3287,7 +3287,7 @@ class SummarizeCountingRule(Show125Circle): ) self.wait() self.play( - three.highlight, RED, + three.set_color, RED, FadeIn(three_brace) ) self.wait() @@ -3318,11 +3318,11 @@ class SummarizeCountingRule(Show125Circle): equals_four = TexMobject("=", "4") four = equals_four.get_part_by_tex("4") - four.highlight(YELLOW) + four.set_color(YELLOW) final_choice_words = TextMobject( "Mutiply", "by $1$, $i$, $-1$ or $-i$" ) - final_choice_words.highlight(YELLOW) + final_choice_words.set_color(YELLOW) final_choice_words.next_to(four, DOWN, LARGE_BUFF, LEFT) final_choice_words.to_edge(RIGHT) final_choice_arrow = Arrow( @@ -3422,7 +3422,7 @@ class FactorsOfTwoNeitherHelpNorHurt(TeacherStudentsScene): words = TextMobject( "Factors of", "$2^k$", "neither \\\\ help nor hurt" ) - words.highlight_by_tex("2", YELLOW) + words.set_color_by_tex("2", YELLOW) self.teacher_says(words) self.change_student_modes(*["pondering"]*3) self.wait(3) @@ -3559,7 +3559,7 @@ class IntroduceChi(FactorizationPattern): arrows.add(arrow) value = TexMobject(str(chi_func(n))) for tex, color in zip(["1", "-1", "0"], self.colors): - value.highlight_by_tex(tex, color) + value.set_color_by_tex(tex, color) value.next_to(arrow, UP) numbers.add(value) group = VGroup(chis, arrows, numbers) @@ -3617,7 +3617,7 @@ class IntroduceChi(FactorizationPattern): for brace, n in zip(braces, [x, y, x*y]): output = chi_func(n) label = brace.get_tex(str(output)) - label.highlight(self.number_to_color(output)) + label.set_color(self.number_to_color(output)) brace.add(label) expression.add(brace) expressions.add(expression) @@ -3651,7 +3651,7 @@ class IntroduceChi(FactorizationPattern): label.scale(0.8) label.next_to(dot, UP, LARGE_BUFF) arrow = Arrow(label, dot, buff = SMALL_BUFF) - VGroup(dot, label, arrow).highlight(color) + VGroup(dot, label, arrow).set_color(color) dots.add(dot) arrows.add(arrow) labels.add(label) @@ -3691,9 +3691,9 @@ class IntroduceChi(FactorizationPattern): result.inputs = VGroup() for n in truncated_numbers: num_mob = result.get_part_by_tex(str(n), substring = False) - num_mob.highlight(color) + num_mob.set_color(color) result.inputs.add(num_mob) - result.highlight_by_tex(output, color, substring = False) + result.set_color_by_tex(output, color, substring = False) return result def number_to_color(self, n): @@ -3727,7 +3727,7 @@ class WriteCountingRuleWithChi(SummarizeCountingRule): "5", "^3", ) for tex, color in zip(["5", "3", "2"], self.colors): - factorization.highlight_by_tex(tex, color, substring = False) + factorization.set_color_by_tex(tex, color, substring = False) factorization.to_edge(UP) factorization.shift(LEFT) @@ -3739,7 +3739,7 @@ class WriteCountingRuleWithChi(SummarizeCountingRule): ) count.arrange_submobjects(RIGHT, buff = SMALL_BUFF) for i, color in zip([3, 2, 1], self.colors): - count[i][1].highlight(color) + count[i][1].set_color(color) count.next_to( factorization.get_part_by_tex("="), DOWN, buff = LARGE_BUFF, @@ -3774,8 +3774,8 @@ class WriteCountingRuleWithChi(SummarizeCountingRule): args += ["\\chi(", str(n), "^%d"%i, ")", "+"] args[-1] = ")" factor = TexMobject(*args) - factor.highlight_by_tex(str(n), color, substring = False) - factor.highlight_by_tex("1", color, substring = False) + factor.set_color_by_tex(str(n), color, substring = False) + factor.set_color_by_tex("1", color, substring = False) factor.scale(0.8) expression.add(factor) expression.arrange_submobjects( @@ -3828,7 +3828,7 @@ class WriteCountingRuleWithChi(SummarizeCountingRule): chi_sum, count, base, exp = group brace = Brace(chi_sum, DOWN) evaluation = brace.get_tex(*tex) - evaluation.highlight(base.get_color()) + evaluation.set_color(base.get_color()) evaluation_rect = BackgroundRectangle(evaluation) self.play(FadeIn(rect), Animation(group)) @@ -3846,7 +3846,7 @@ class WriteCountingRuleWithChi(SummarizeCountingRule): count_num = count[1] new_count = TexMobject("0") new_count.replace(count_num, dim_to_match = 1) - new_count.highlight(count_num.get_color()) + new_count.set_color(count_num.get_color()) evaluation_point = VectorizedPoint(evaluation[-4].get_right()) chi_sum_point = VectorizedPoint(chi_sum[-7].get_right()) new_brace = Brace(VGroup(*chi_sum[:-6]), DOWN) @@ -3918,7 +3918,7 @@ class ExpandCountWith45(SummarizeCountingRule): "45", "=", "3", "^2", "\\cdot", "5", ) for tex, color in zip(["5", "3",], [GREEN, RED]): - factorization.highlight_by_tex(tex, color, substring = False) + factorization.set_color_by_tex(tex, color, substring = False) factorization.to_edge(UP) factorization.shift(1.7*LEFT) @@ -3938,7 +3938,7 @@ class ExpandCountWith45(SummarizeCountingRule): args[-1] = ")" factor = TexMobject(*args) for part in factor[1::2]: - part[2].highlight(color) + part[2].set_color(color) factor.scale(0.8) expression.add(factor) expression.arrange_submobjects(RIGHT, buff = SMALL_BUFF) @@ -3953,7 +3953,7 @@ class ExpandCountWith45(SummarizeCountingRule): ]) for brace, num, color in zip(braces, [1, 2], [RED, GREEN]): num_mob = brace.get_tex(str(num), buff = SMALL_BUFF) - num_mob.highlight(color) + num_mob.set_color(color) brace.add(num_mob) self.play( @@ -4052,7 +4052,7 @@ class ExpandCountWith45(SummarizeCountingRule): for product in products: chi_mob = TexMobject("\\chi(", str(product), ")") product_mob = chi_mob.get_part_by_tex(str(product)) - product_mob.highlight(color) + product_mob.set_color(color) product_mobs.add(product_mob) divisor_sum.add(chi_mob) chi_mobs.add(chi_mob) @@ -4066,7 +4066,7 @@ class ExpandCountWith45(SummarizeCountingRule): prime_pairs = self.prime_pairs.copy() for prime_pair, product_mob in zip(prime_pairs, product_mobs): prime_pair.target = product_mob.copy() - prime_pair.target.highlight(YELLOW) + prime_pair.target.set_color(YELLOW) braces = VGroup(*[Brace(m, DOWN) for m in chi_mobs]) for brace, product in zip(braces, products): @@ -4083,7 +4083,7 @@ class ExpandCountWith45(SummarizeCountingRule): lag_ratio = 0.25, )) self.remove(prime_pairs) - product_mobs.highlight(YELLOW) + product_mobs.set_color(YELLOW) self.wait(2) self.play(LaggedStart( ApplyMethod, @@ -4120,7 +4120,7 @@ class CountLatticePointsInBigCircle(LatticePointScene): def introduce_points(self): circle = self.get_circle(radius = self.max_lattice_point_radius) radius = Line(ORIGIN, circle.get_right()) - radius.highlight(RED) + radius.set_color(RED) R = TexMobject("R").next_to(radius, UP) R_rect = BackgroundRectangle(R) R_group = VGroup(R_rect, R) @@ -4318,7 +4318,7 @@ class AddUpGrid(Scene): if N%d != 0: continue chi_mob = TexMobject("\\chi(", str(d), ")") - chi_mob[1].highlight(YELLOW) + chi_mob[1].set_color(YELLOW) chi_mob.d = d chi_mobs.add(chi_mob) chi_sum.add(chi_mob) @@ -4381,7 +4381,7 @@ class AddUpGrid(Scene): ]) for numbers in [6, 12], [2, 3, 5, 7, 11] ] - prime_rects.highlight(GREEN) + prime_rects.set_color(GREEN) randy = Randolph().flip() randy.next_to(self.chi_mobs, RIGHT) @@ -4464,7 +4464,7 @@ class AddUpGrid(Scene): TexMobject("+") ) term.arrange_submobjects(RIGHT, SMALL_BUFF) - term[1][1].highlight(YELLOW) + term[1][1].set_color(YELLOW) full_sum.add(term) full_sum.arrange_submobjects(RIGHT, SMALL_BUFF) full_sum.scale(0.7) @@ -4612,7 +4612,7 @@ class AddUpGrid(Scene): pi_sum.scale(0.9) pi = pi_sum.get_part_by_tex("pi") pi.scale(2, about_point = pi.get_left()) - pi.highlight(YELLOW) + pi.set_color(YELLOW) pi_sum.shift( self.alt_rhs[-1].get_bottom(), MED_SMALL_BUFF*DOWN, @@ -4660,7 +4660,7 @@ class IntersectionOfTwoFields(TeacherStudentsScene): title.move_to(circle) title.to_edge(UP, buff = SMALL_BUFF) circle.next_to(title, DOWN, SMALL_BUFF) - title.highlight(color) + title.set_color(color) circle.title = title circles.add(circle) new_number_systems = TextMobject( @@ -4672,7 +4672,7 @@ class IntersectionOfTwoFields(TeacherStudentsScene): new_number_systems.next_to(circles[0].get_top(), DOWN, MED_SMALL_BUFF) new_number_systems.shift(MED_LARGE_BUFF*(DOWN+2*LEFT)) gaussian_integers.next_to(new_number_systems, DOWN) - gaussian_integers.highlight(BLUE) + gaussian_integers.set_color(BLUE) circles[0].words = VGroup(new_number_systems, gaussian_integers) zeta = TexMobject("\\zeta(s) = \\sum_{n=1}^\\infty \\frac{1}{n^s}") @@ -4684,7 +4684,7 @@ class IntersectionOfTwoFields(TeacherStudentsScene): zeta.next_to(circles[1].get_top(), DOWN, MED_LARGE_BUFF) zeta.shift(MED_LARGE_BUFF*RIGHT) L_function.next_to(zeta, DOWN, MED_LARGE_BUFF) - L_function.highlight(YELLOW) + L_function.set_color(YELLOW) circles[1].words = VGroup(zeta, L_function) mid_words = TextMobject("Where\\\\ we \\\\ were") @@ -4828,7 +4828,7 @@ class Thumbnail(Scene): y = i//n_cols prime_mob.shift(x*x_spacing*RIGHT + y*y_spacing*DOWN) prime_mobs.add(prime_mob) - prime_mob.highlight({ + prime_mob.set_color({ -1 : YELLOW, 0 : RED, 1 : BLUE_C, diff --git a/old_projects/matrix_as_transform_2d.py b/old_projects/matrix_as_transform_2d.py index 3925d4c6..bb48c5a7 100644 --- a/old_projects/matrix_as_transform_2d.py +++ b/old_projects/matrix_as_transform_2d.py @@ -72,7 +72,7 @@ class ShowMultiplication(NumberLineScene): copied_num_mobs = deepcopy(self.number_mobs) self.play( ApplyFunction( - lambda m : m.shift(DOWN).highlight("lightgreen"), + lambda m : m.shift(DOWN).set_color("lightgreen"), copied_line ), *[ ApplyMethod(mob.shift, DOWN) @@ -101,7 +101,7 @@ class ExamplesOfNonlinearOneDimensionalTransforms(NumberLineScene): def shift_zero((x, y, z)): return (2*x+4, y, z) self.nonlinear = TextMobject("Not a Linear Transform") - self.nonlinear.highlight(LIGHT_RED).to_edge(UP, buff = 1.5) + self.nonlinear.set_color(LIGHT_RED).to_edge(UP, buff = 1.5) pairs = [ (sinx_plux_x, "numbers don't remain evenly spaced"), (shift_zero, "zero does not remain fixed") @@ -118,7 +118,7 @@ class ExamplesOfNonlinearOneDimensionalTransforms(NumberLineScene): "density" : 5*DEFAULT_POINT_DENSITY_1D, } NumberLineScene.construct(self, **config) - words = TextMobject(explanation).highlight(LIGHT_RED) + words = TextMobject(explanation).set_color(LIGHT_RED) words.next_to(self.nonlinear, DOWN, buff = 0.5) self.add(words) @@ -301,7 +301,7 @@ class ExamplesOfNonlinearTwoDimensionalTransformations(Scene): def shift_zero((x, y, z)): return (2*x + 3*y + 4, -1*x+y+2, z) self.nonlinear = TextMobject("Nonlinear Transform") - self.nonlinear.highlight(LIGHT_RED) + self.nonlinear.set_color(LIGHT_RED) self.nonlinear.to_edge(UP, buff = 1.5) pairs = [ (squiggle, "lines do not remain straight"), @@ -323,7 +323,7 @@ class ExamplesOfNonlinearTwoDimensionalTransformations(Scene): number_plane = NumberPlane(**config) numbers = number_plane.get_coordinate_labels() words = TextMobject(explanation) - words.highlight(LIGHT_RED) + words.set_color(LIGHT_RED) words.next_to(self.nonlinear, DOWN, buff = 0.5) self.add(number_plane, *numbers) @@ -358,9 +358,9 @@ class ExamplesOfNonlinearTwoDimensionalTransformations(Scene): image = disp.paint_region(region, color = WHITE) self.blackness = TextMobject("") ImageMobject.generate_points_from_image_array(self.blackness, image) - self.blackness.highlight(BLACK) + self.blackness.set_color(BLACK) rectangle = Rectangle(width = 7, height=1.7) - rectangle.highlight(WHITE) + rectangle.set_color(WHITE) rectangle.shift(self.blackness.get_center()) self.blackness.add(rectangle) self.blackness.scale_in_place(0.95) @@ -379,7 +379,7 @@ class TrickyExamplesOfNonlinearTwoDimensionalTransformations(Scene): "These might look like they keep lines straight...", "but diagonal lines get curved" ]).to_edge(UP, buff = 1.5).split() - phrase2.highlight(LIGHT_RED) + phrase2.set_color(LIGHT_RED) diagonal = Line( DOWN*FRAME_Y_RADIUS+LEFT*FRAME_X_RADIUS, UP*FRAME_Y_RADIUS+RIGHT*FRAME_X_RADIUS, @@ -429,9 +429,9 @@ class TrickyExamplesOfNonlinearTwoDimensionalTransformations(Scene): image = disp.paint_region(region, color = WHITE) self.blackness = TextMobject("") ImageMobject.generate_points_from_image_array(self.blackness, image) - self.blackness.highlight(BLACK) + self.blackness.set_color(BLACK) rectangle = Rectangle(width = 9, height=1.5) - rectangle.highlight(WHITE) + rectangle.set_color(WHITE) rectangle.shift(self.blackness.get_center()) self.blackness.add(rectangle) self.blackness.scale_in_place(0.95) diff --git a/old_projects/moser_intro.py b/old_projects/moser_intro.py index 3156c249..68f462fe 100644 --- a/old_projects/moser_intro.py +++ b/old_projects/moser_intro.py @@ -22,7 +22,7 @@ def logo_to_circle(): small_circle = Circle( density = CIRCLE_DENSITY, color = 'skyblue' - ).scale(LOGO_RADIUS).highlight( + ).scale(LOGO_RADIUS).set_color( DARK_BROWN, lambda (x, y, z) : x < 0 and y > 0 ) big_circle = Circle(density = CIRCLE_DENSITY).scale(RADIUS) @@ -62,7 +62,7 @@ def count_sections(*radians): last_num = None for reg, count in zip(regions, it.count(1)): number = TexMobject(str(count)).shift((RADIUS, 3, 0)) - sc.highlight_region(reg) + sc.set_color_region(reg) rt = 1.0 / (x**0.8) sc.add(number) sc.remove(last_num) @@ -227,7 +227,7 @@ def next_few_videos(*radians): for point1, point2 in it.combinations(points, 2) ]) thumbnail = Mobject(circle, dots, lines) - frame = VideoIcon().highlight( + frame = VideoIcon().set_color( "black", lambda point : np.linalg.norm(point) < 0.5 ) diff --git a/old_projects/moser_main.py b/old_projects/moser_main.py index 5dddf0df..b069d17d 100644 --- a/old_projects/moser_main.py +++ b/old_projects/moser_main.py @@ -378,7 +378,7 @@ class NonGeneralPosition(CircleScene): color = "white", ) - self.highlight_region(center_region, "green") + self.set_color_region(center_region, "green") self.add(text, arrow) self.wait(2) self.remove(text, arrow) @@ -421,12 +421,12 @@ class GeneralPositionRule(Scene): if not first_time: self.add(words_mob) if words == "Okay": - words_mob.highlight("green") + words_mob.set_color("green") self.wait(2) else: - words_mob.highlight() + words_mob.set_color() intersecting_lines = [ - line.scale_in_place(0.3).highlight() + line.scale_in_place(0.3).set_color() for i, j in pairs for line in [Line(cs.points[i], cs.points[j])] ] @@ -543,7 +543,7 @@ class IllustrateNChooseK(Scene): count_mob.center().shift(count_center) self.add(count_mob) tuple_copy = Mobject(*[nrange_mobs[index-1] for index in tup]) - tuple_copy.highlight() + tuple_copy.set_color() self.add(tuple_copy) self.add(tuple_mobs[count]) self.wait(frame_time) @@ -662,7 +662,7 @@ class QuadrupletsToIntersections(CircleScene): for dot in dot_quad: dot.scale_in_place(2) dot_quad = Mobject(*dot_quad) - dot_quad.highlight() + dot_quad.set_color() self.add(dot_quad) self.wait(frame_time / 3) self.play(Transform( @@ -793,14 +793,14 @@ class EulersFormula(GraphScene): ]) self.add(formula) colored_dots = [ - deepcopy(d).scale_in_place(1.5).highlight("red") + deepcopy(d).scale_in_place(1.5).set_color("red") for d in self.dots ] colored_edges = [ Mobject( Line(midpoint, start), Line(midpoint, end), - ).highlight("red") + ).set_color("red") for e in self.edges for start, end, midpoint in [ (e.start, e.end, (e.start + e.end)/2.0) @@ -840,11 +840,11 @@ class CannotDirectlyApplyEulerToMoser(CircleScene): mob.shift(shift_val) self.add(n_equals) yellow_dots = [ - d.highlight("yellow").scale_in_place(2) + d.set_color("yellow").scale_in_place(2) for d in deepcopy(self.dots) ] yellow_lines = Mobject(*[ - l.highlight("yellow") for l in deepcopy(self.lines) + l.set_color("yellow") for l in deepcopy(self.lines) ]) self.play(*[ ShowCreation(dot) for dot in yellow_dots @@ -906,7 +906,7 @@ class ShowMoserGraphLines(CircleScene): run_time = 2.0, )) else: - compound.highlight("yellow") + compound.set_color("yellow") self.play(ShowCreation(compound)) self.remove(compound) if mobs == self.intersection_dots: @@ -917,7 +917,7 @@ class ShowMoserGraphLines(CircleScene): for line, small_line in zip(self.lines, small_lines) ]) yellow_lines = Mobject(*[ - line.highlight("yellow") for line in small_lines + line.set_color("yellow") for line in small_lines ]) self.add(plus_2_n_choose_4) self.play(ShowCreation(yellow_lines)) @@ -930,7 +930,7 @@ class ShowMoserGraphLines(CircleScene): ]) self.add(plus_n) self.play(ShowCreation(Mobject(*[ - mob.highlight("yellow") for mob in self.circle_pieces + mob.set_color("yellow") for mob in self.circle_pieces ]))) class HowIntersectionChopsLine(CircleScene): @@ -1059,15 +1059,15 @@ class ApplyEulerToMoser(CircleScene): for d in [V, minus, E, plus, F, equals, two] ]) self.wait() - F[1].highlight() + F[1].set_color() self.add(*self.lines + self.circle_pieces) for region in self.regions: - self.highlight_region(region) - self.highlight_region(self.exterior, "blue") + self.set_color_region(region) + self.set_color_region(self.exterior, "blue") self.wait() self.reset_background() - F[1].highlight("white") - E[1].highlight() + F[1].set_color("white") + E[1].set_color() self.remove(*self.lines + self.circle_pieces) self.play(*[ Transform( @@ -1084,14 +1084,14 @@ class ApplyEulerToMoser(CircleScene): for cp, scp in zip(self.circle_pieces, self.smaller_circle_pieces) ]) self.wait() - E[1].highlight("white") - V[1].highlight() + E[1].set_color("white") + V[1].set_color() self.add(*self.dots + self.intersection_dots) self.remove(*self.lines + self.circle_pieces) self.play(*[ Transform( deepcopy(dot), - deepcopy(dot).scale_in_place(1.4).highlight("yellow") + deepcopy(dot).scale_in_place(1.4).set_color("yellow") ) for dot in self.dots + self.intersection_dots ] + [ @@ -1105,8 +1105,8 @@ class ApplyEulerToMoser(CircleScene): all_mobs = [mob for mob in self.mobjects] self.remove(*all_mobs) self.add(*[d[1] for d in [V, minus, E, plus, F, equals, two]]) - V[1].highlight("white") - two[1].highlight() + V[1].set_color("white") + two[1].set_color() self.wait() self.add(*all_mobs) self.remove(*[d[1] for d in [V, minus, E, plus, F, equals, two]]) @@ -1174,15 +1174,15 @@ class ApplyEulerToMoser(CircleScene): self.wait() self.add(*self.lines + self.circle_pieces) for region in self.regions: - self.highlight_region(region) + self.set_color_region(region) self.wait() - self.highlight_region(self.exterior, "blue") + self.set_color_region(self.exterior, "blue") self.wait() - self.highlight_region(self.exterior, "black") + self.set_color_region(self.exterior, "black") self.remove(two[6]) two = two[7] one = TexMobject("1").shift(two.get_center()) - two.highlight("red") + two.set_color("red") self.add(two) self.play(CounterclockwiseTransform(two, one)) @@ -1219,7 +1219,7 @@ class FormulaRelatesToPowersOfTwo(Scene): TexMobject("2^{%d}"%(i-1) ).scale(scale_factor ).shift(result.get_center() - ).highlight() + ).set_color() for i, result in zip(pof2_range, results) ] self.wait() @@ -1258,14 +1258,14 @@ class PascalRuleExample(PascalsTriangleScene): self.wait() n = randint(2, nrows-1) k = randint(1, n-1) - self.coords_to_mobs[n][k].highlight("green") + self.coords_to_mobs[n][k].set_color("green") self.wait() plus = TexMobject("+").scale(0.5) nums_above = [self.coords_to_mobs[n-1][k-1], self.coords_to_mobs[n-1][k]] plus.center().shift(sum(map(Mobject.get_center, nums_above)) / 2) self.add(plus) for mob in nums_above + [plus]: - mob.highlight("yellow") + mob.set_color("yellow") self.wait() class PascalsTriangleWithNChooseK(PascalsTriangleScene): @@ -1319,25 +1319,25 @@ class PascalsTriangleNChooseKExample(PascalsTriangleScene): row = [self.coords_to_mobs[a][b] for b in range(a+1)] a_mob = TexMobject(str(a)) a_mob.shift(n_mob.get_center()) - a_mob.highlight("green") + a_mob.set_color("green") self.add(a_mob) for mob in row: - mob.highlight("green") + mob.set_color("green") self.wait(wait_time) if a < n: for mob in row: - mob.highlight("white") + mob.set_color("white") self.remove(a_mob) self.wait() for b in range(k+1): b_mob = TexMobject(str(b)) b_mob.shift(k_mob.get_center()) - b_mob.highlight("yellow") + b_mob.set_color("yellow") self.add(b_mob) - self.coords_to_mobs[n][b].highlight("yellow") + self.coords_to_mobs[n][b].set_color("yellow") self.wait(wait_time) if b < k: - self.coords_to_mobs[n][b].highlight("green") + self.coords_to_mobs[n][b].set_color("green") self.remove(b_mob) self.play(*[ ApplyMethod(mob.fade, 0.2) @@ -1430,7 +1430,7 @@ class MoserSolutionInPascal(PascalsTriangleScene): for k in range(len(terms)): if k%2 == 0 and k <= n: new_term = deepcopy(self.coords_to_n_choose_k[n][k]) - new_term.highlight(term_color) + new_term.set_color(term_color) else: new_term = Point( self.coords_to_center(n, k) @@ -1451,7 +1451,7 @@ class MoserSolutionInPascal(PascalsTriangleScene): self.wait() term_range = range(0, min(4, n)+1, 2) target_terms = dict([ - (k, deepcopy(self.coords_to_mobs[n][k]).highlight(term_color)) + (k, deepcopy(self.coords_to_mobs[n][k]).set_color(term_color)) for k in term_range ]) self.play(* @@ -1481,13 +1481,13 @@ class MoserSolutionInPascal(PascalsTriangleScene): self.add(self.coords_to_mobs[n][k]) self.play(Transform( terms[k], - Mobject(*above_terms).highlight(term_color) + Mobject(*above_terms).set_color(term_color) )) self.remove(*above_terms) self.wait() terms_sum = TexMobject(str(moser_function(n))) terms_sum.shift((FRAME_X_RADIUS-1, terms[0].get_center()[1], 0)) - terms_sum.highlight(term_color) + terms_sum.set_color(term_color) self.play(Transform(Mobject(*terms), terms_sum)) class RotatingPolyhedra(Scene): @@ -1567,7 +1567,7 @@ class ExplainNChoose2Formula(Scene): self.play(*[ CounterclockwiseTransform( mob, - Point(mob.get_center()).highlight("black") + Point(mob.get_center()).set_color("black") ) for mob in nums ]) @@ -1624,7 +1624,7 @@ class ExplainNChoose4Formula(Scene): self.remove(nums_compound) nums = nums_compound.split() chosen = nums[quad[i]-1] - nums[quad[i]-1] = Point(chosen.get_center()).highlight("black") + nums[quad[i]-1] = Point(chosen.get_center()).set_color("black") nums_compound = Mobject(*nums) self.add(chosen) if i < 3: @@ -1637,7 +1637,7 @@ class ExplainNChoose4Formula(Scene): self.play(*[ CounterclockwiseTransform( mob, - Point(mob.get_center()).highlight("black") + Point(mob.get_center()).set_color("black") ) for mob in nums ]) diff --git a/old_projects/mug.py b/old_projects/mug.py index a275aee9..e2a06e21 100644 --- a/old_projects/mug.py +++ b/old_projects/mug.py @@ -211,7 +211,7 @@ class UtilitiesPuzzleScene(Scene): words = TextMobject("No crossing!") words.next_to(arrow, UP, buff = SMALL_BUFF) result = VGroup(words, arrow) - result.highlight("RED") + result.set_color("RED") return result def get_region(self, *bounding_edges): @@ -290,7 +290,7 @@ class AboutToyPuzzles(UtilitiesPuzzleScene, TeacherStudentsScene, ThreeDScene): ) eulers = TexMobject(*"V-E+F=2") - eulers.highlight_by_tex_to_color_map({ + eulers.set_color_by_tex_to_color_map({ "V" : RED, "E" : GREEN, "F" : BLUE, @@ -505,7 +505,7 @@ class ThisPuzzleIsHard(UtilitiesPuzzleScene, PiCreatureScene): is impossible. """) meta_puzzle_words.next_to(group.target, UP) - meta_puzzle_words.highlight(BLUE) + meta_puzzle_words.set_color(BLUE) self.play( MoveToTarget(group), @@ -552,7 +552,7 @@ class IntroduceGraph(PiCreatureScene): vertices_word = TextMobject("Vertices") vertices_word.to_edge(RIGHT, buff = LARGE_BUFF) - vertices_word.highlight(YELLOW) + vertices_word.set_color(YELLOW) vertex_arrows = VGroup(*[ Arrow(vertices_word.get_left(), dot) @@ -633,14 +633,14 @@ class IsK33Planar(UtilitiesPuzzleScene): almost_solution_lines = self.get_almost_solution_lines() question = TextMobject("Is", "this graph", "planar?") - question.highlight_by_tex("this graph", YELLOW) + question.set_color_by_tex("this graph", YELLOW) question.to_edge(UP) brace = Brace(question.get_part_by_tex("graph"), DOWN, buff = SMALL_BUFF) fancy_name = brace.get_text( "``Complete bipartite graph $K_{3, 3}$''", buff = SMALL_BUFF ) - fancy_name.highlight(YELLOW) + fancy_name.set_color(YELLOW) self.add(question) self.convert_objects_to_dots() @@ -673,7 +673,7 @@ class TwoKindsOfViewers(PiCreatureScene, UtilitiesPuzzleScene): ) words.to_edge(UP) eulers = words.get_part_by_tex("V-E+F") - eulers.highlight(GREEN) + eulers.set_color(GREEN) non_eulers = VGroup(*filter(lambda m : m is not eulers, words)) self.add(words) @@ -685,10 +685,10 @@ class TwoKindsOfViewers(PiCreatureScene, UtilitiesPuzzleScene): know_eulers = TextMobject("Know about \\\\ Euler's formula") know_eulers.next_to(pi1, DOWN) - know_eulers.highlight(GREEN) + know_eulers.set_color(GREEN) dont = TextMobject("Don't") dont.next_to(pi2, DOWN) - dont.highlight(RED) + dont.set_color(RED) self.play( FadeIn(know_eulers), @@ -855,7 +855,7 @@ class IntroduceRegions(UtilitiesPuzzleScene): regions.submobjects.insert(0, back_region) front_regions = VGroup(*regions[1:]) - back_region.highlight(BLUE_E) + back_region.set_color(BLUE_E) front_regions.gradient_highlight(GREEN_E, MAROON_E) return flat_lines, line_groups, regions @@ -936,7 +936,7 @@ class AskAboutRegions(IntroduceRegions): count = new_count region.save_state() - anims = [ApplyMethod(region.highlight, YELLOW)] + anims = [ApplyMethod(region.set_color, YELLOW)] if last_region: anims.append(ApplyMethod(last_region.restore)) anims.append(Animation(front_regions)) @@ -1217,7 +1217,7 @@ class LightUpNodes(IntroduceRegions): def get_plus_one_anim(self, count): plus_one = TexMobject("+1") - plus_one.highlight(YELLOW) + plus_one.set_color(YELLOW) plus_one.move_to(count) plus_one.next_to(count, DOWN) plus_one.generate_target() @@ -1287,11 +1287,11 @@ class ShowRule(TeacherStudentsScene): word_mob.next_to(ORIGIN, UP, SMALL_BUFF) word_mob.rotate(arrow.get_angle()) word_mob.shift(arrow.get_center()) - word_mob.highlight(GREEN) + word_mob.set_color(GREEN) arrow.add(word_mob) - new_vertex.highlight(YELLOW) - new_edge.highlight(BLUE) - new_region.highlight(RED) + new_vertex.set_color(YELLOW) + new_edge.set_color(BLUE) + new_region.set_color(RED) rule = VGroup(new_edge, arrows, new_vertex, new_region) rule.center().to_edge(UP) @@ -1404,7 +1404,7 @@ class ConcludeFiveRegions(LightUpNodes): self.side_lines )) side_lines_rect = SurroundingRectangle(on_screen_side_lines) - side_lines_rect.highlight(WHITE) + side_lines_rect.set_color(WHITE) self.play(ShowCreation(side_lines_rect)) self.wait() @@ -1435,9 +1435,9 @@ class ConcludeFiveRegions(LightUpNodes): #Conclude words = TextMobject("Last line must \\\\ introduce 5th region") words.scale(0.8) - words.highlight(BLUE) + words.set_color(BLUE) rect = SurroundingRectangle(self.f_count) - rect.highlight(BLUE) + rect.set_color(BLUE) words.next_to(rect, DOWN) randy = Randolph().flip() randy.scale(0.5) @@ -1544,8 +1544,8 @@ class FiveRegionsFourEdgesEachGraph(Scene): ) words.arrange_submobjects(DOWN) words.to_edge(UP) - words[0][0].highlight(self.f_colors[0]) - words[1][0].highlight(self.e_color) + words[0][0].set_color(self.f_colors[0]) + words[1][0].set_color(self.e_color) squares = VGroup(*[Square() for x in range(5)]) squares.scale(0.5) @@ -1689,7 +1689,7 @@ class FiveRegionsFourEdgesEachGraph(Scene): for edge in region.edges: new_count = Integer(count.number + 1) new_count.replace(count, dim_to_match = 1) - new_count.highlight(count.get_color()) + new_count.set_color(count.get_color()) self.play( ShowCreation(edge), FadeOut(count), @@ -1795,7 +1795,7 @@ class EulersFormulaForGeneralPlanarGraph(LightUpNodes, ThreeDScene): points *= 0.75 points += DOWN vertices = VGroup(*map(Dot, points)) - vertices.highlight(YELLOW) + vertices.set_color(YELLOW) edges = VGroup(*[ VGroup(*[ Line(p1, p2, color = WHITE) @@ -1867,7 +1867,7 @@ class EulersFormulaForGeneralPlanarGraph(LightUpNodes, ThreeDScene): words = TextMobject("``Euler's characteristic formula''") words.next_to(counts.target, DOWN) words.shift(MED_LARGE_BUFF*RIGHT) - words.highlight(YELLOW) + words.set_color(YELLOW) for group in groups: self.play( @@ -1975,7 +1975,7 @@ class QuestionWrapper(Scene): "this proof break down?", ) question.to_edge(UP) - question.highlight_by_tex("specifically", YELLOW) + question.set_color_by_tex("specifically", YELLOW) screen_rect = ScreenRectangle(height = 5.5) screen_rect.next_to(question, DOWN) diff --git a/old_projects/music_and_measure.py b/old_projects/music_and_measure.py index ead92be2..38990b3a 100644 --- a/old_projects/music_and_measure.py +++ b/old_projects/music_and_measure.py @@ -187,7 +187,7 @@ class IntervalScene(NumberLineScene): tick_rad *= scale_factor frac_mob.shift(point + frac_mob.get_height()*UP) tick = Line(point + DOWN*tick_rad, point + UP*tick_rad) - tick.highlight("yellow") + tick.set_color("yellow") self.add(frac_mob, tick) return frac_mob, tick @@ -198,7 +198,7 @@ class IntervalScene(NumberLineScene): point = self.number_line.number_to_point(frac) tick_rad = 2.0*long_tick_size/frac.denominator tick = Line(point+tick_rad*DOWN, point+tick_rad*UP) - tick.highlight("yellow") + tick.set_color("yellow") all_ticks.append(tick) all_ticks = Mobject(*all_ticks) if run_time > 0: @@ -244,7 +244,7 @@ class IntervalScene(NumberLineScene): center_point+spatial_width*RIGHT/2 ) interval_line.do_in_place(interval_line.sort_points, np.linalg.norm) - interval_line.highlight(color) + interval_line.set_color(color) if run_time > 0: squished_interval = deepcopy(open_interval).stretch_to_fit_width(0) self.play( @@ -265,7 +265,7 @@ class TwoChallenges(Scene): two.shift(DOWN).to_edge(LEFT) notes = ImageMobject("musical_notes").scale(0.3) notes.next_to(one) - notes.highlight("blue") + notes.set_color("blue") measure = TextMobject("Measure Theory").next_to(two) probability = TextMobject("Probability") probability.next_to(measure).shift(DOWN+RIGHT) @@ -274,7 +274,7 @@ class TwoChallenges(Scene): arrow_to_prob = Arrow(measure, probability) arrow_to_int = Arrow(measure, integration) for arrow in arrow_to_prob, arrow_to_int: - arrow.highlight("yellow") + arrow.set_color("yellow") self.add(two_challenges) @@ -299,7 +299,7 @@ class MeasureTheoryToHarmony(IntervalScene): all_mobs.sort_points() self.clear() radius = self.interval.radius - line = Line(radius*LEFT, radius*RIGHT).highlight("white") + line = Line(radius*LEFT, radius*RIGHT).set_color("white") self.play(DelayByOrder(Transform(all_mobs, line))) self.clear() self.play(Vibrate(rate_func = smooth)) @@ -400,7 +400,7 @@ class JustByAnalyzingTheNumber(Scene): self.add(r_equals) for num in nums: mob = TexMobject(str(num)).next_to(r_equals) - mob.highlight() + mob.set_color() mob.sort_points() if last: self.play(DelayByOrder(Transform(last, mob, run_time = 0.5))) @@ -433,10 +433,10 @@ class QuestionAndAnswer(Scene): "with sufficiently low denominator", size = "\\small" ).scale(1.5) - correction1.highlight("yellow") + correction1.set_color("yellow") correction1.next_to(A).shift(2*answer.get_height()*DOWN) answer = answer.split() - answer[1].highlight("green") + answer[1].set_color("green") temp_answer_end = deepcopy(answer[-1]).next_to(answer[0], buff = 0.2) self.add(Q, A, question, twotwenty, r220) @@ -514,8 +514,8 @@ class DecomposeMusicalNote(Scene): class DecomposeTwoFrequencies(Scene): def construct(self): line = Line(FRAME_Y_RADIUS*DOWN, FRAME_Y_RADIUS*UP) - sine1 = LongSine().shift(2*UP).highlight("yellow") - sine2 = LongSine().shift(DOWN).highlight("lightgreen") + sine1 = LongSine().shift(2*UP).set_color("yellow") + sine2 = LongSine().shift(DOWN).set_color("lightgreen") sine1.stretch(2.0/3, 0) comp = Mobject(sine1, sine2) @@ -540,7 +540,7 @@ class FlashOnXProximity(Animation): def update_mobject(self, alpha): for mob in self.close_mobjects: if np.min(np.abs(mob.points[:,0] - self.x_val)) < 0.1: - self.mobject.highlight() + self.mobject.set_color() return self.mobject.to_original_color() @@ -557,7 +557,7 @@ class PatternInFrequencies(Scene): def construct(self, num1, num2, color): big_line = Line(FRAME_Y_RADIUS*UP, FRAME_Y_RADIUS*DOWN) - big_line.highlight("white").shift(2*LEFT) + big_line.set_color("white").shift(2*LEFT) line_template = Line(UP, DOWN) line_template.shift(2*UP+2*LEFT) setup_width = FRAME_WIDTH @@ -572,8 +572,8 @@ class PatternInFrequencies(Scene): deepcopy(line_template).shift(k*RIGHT) for k in range(num_bot_lines) ]) - bottom_lines.highlight("blue") - top_lines.highlight(color) + bottom_lines.set_color("blue") + top_lines.set_color(color) kwargs = { "run_time" : 10, "rate_func" : None @@ -608,9 +608,9 @@ class CompareFractionComplexity(Scene): arrow1 = Arrow(UP, ORIGIN).next_to(frac0[0], UP) arrow2 = Arrow(UP, ORIGIN).next_to(frac1[0], UP) simple = TextMobject("Simple").next_to(arrow1, UP) - simple.highlight("green") + simple.set_color("green") complicated = TextMobject("Complicated").next_to(arrow2, UP) - complicated.highlight("red") + complicated.set_color("red") indicates = TextMobject("Indicates complexity").shift(2*DOWN) arrow3 = Arrow(indicates.get_top(), frac0[1]) arrow4 = Arrow(indicates.get_top(), frac1[1]) @@ -624,7 +624,7 @@ class CompareFractionComplexity(Scene): ]) self.wait() self.play(*[ - DelayByOrder(ApplyMethod(frac[1].highlight, "yellow")) + DelayByOrder(ApplyMethod(frac[1].set_color, "yellow")) for frac in frac0, frac1 ]) self.play( @@ -637,12 +637,12 @@ class CompareFractionComplexity(Scene): class IrrationalGang(Scene): def construct(self): randy = Randolph() - randy.mouth.highlight(randy.DEFAULT_COLOR) + randy.mouth.set_color(randy.DEFAULT_COLOR) randy.sync_parts() sqrt13 = TexMobject("\\sqrt{13}").shift(2*LEFT) - sqrt13.highlight("green") + sqrt13.set_color("green") zeta3 = TexMobject("\\zeta(3)").shift(2*RIGHT) - zeta3.highlight("grey") + zeta3.set_color("grey") eyes = Mobject(*randy.eyes) eyes.scale(0.5) sqrt13.add(eyes.next_to(sqrt13, UP, buff = 0).shift(0.25*RIGHT)) @@ -687,14 +687,14 @@ class PianoTuning(Scene): deepcopy(semicircle).shift(jump*k*RIGHT) for k in range(23) ]) - semicircles.highlight("white") + semicircles.set_color("white") semicircles.next_to(piano, UP, buff = 0) semicircles.shift(0.05*RIGHT) semicircles.sort_points(lambda p : p[0]) first_jump = semicircles.split()[0] twelfth_root = TexMobject("2^{\\left(\\frac{1}{12}\\right)}") twelfth_root.scale(0.75).next_to(first_jump, UP, buff = 1.5) - line = Line(twelfth_root, first_jump).highlight("grey") + line = Line(twelfth_root, first_jump).set_color("grey") self.keys = piano.split() self.semicircles = semicircles.split() @@ -722,7 +722,7 @@ class PianoTuning(Scene): low = self.keys[whole_notes_to_base] high = self.keys[whole_notes_to_base + interval - 1] u_brace = Underbrace(low.get_bottom(), high.get_bottom()) - u_brace.highlight("yellow") + u_brace.set_color("yellow") ratio = TexMobject("2^{\\left(\\frac{%d}{12}\\right)}"%half_steps) ratio.next_to(u_brace, DOWN, buff = 0.2) semicircles = self.semicircles[half_notes_to_base:half_notes_to_base+half_steps] @@ -740,9 +740,9 @@ class PianoTuning(Scene): should_be = TextMobject("Should be $\\frac{%d}{%d}$"%num_den) should_be.next_to(u_brace, DOWN) - self.play(ApplyMethod(low.highlight, colors[0])) + self.play(ApplyMethod(low.set_color, colors[0])) self.play( - ApplyMethod(high.highlight, colors[interval]), + ApplyMethod(high.set_color, colors[interval]), Transform(Point(u_brace.get_left()), u_brace), ) self.wait() @@ -802,7 +802,7 @@ class PowersOfTwelfthRoot(Scene): "with", str(percent_error)[:4] + "\\%", "error" ]) error_string = error_string.split() - error_string[1].highlight() + error_string[1].set_color() error_string = Mobject(*error_string) error_string.scale(approx_form.get_height()/error_string.get_height()) error_string.next_to(frac_mob) @@ -826,8 +826,8 @@ class SupposeThereIsASavant(Scene): "notes whose frequencies have a rational ratio" words = words.split(" ") word_mobs = TextMobject(words).split() - word_mobs[4].highlight() - word_mobs[5].highlight() + word_mobs[4].set_color() + word_mobs[5].set_color() for word, word_mob in zip(words, word_mobs): self.add(word_mob) self.wait(0.1*len(word)) @@ -1036,7 +1036,7 @@ class RationalsAreDense(IntervalScene): words = TextMobject(["Rationals are", "\\emph{dense}", "in the reals"]) words.shift(2*UP) words = words.split() - words[1].highlight() + words[1].set_color() self.add(words[0]) self.play(ShimmerIn(words[1])) @@ -1084,9 +1084,9 @@ class HowCanYouNotCoverEntireInterval(IntervalScene): left = self.number_line.number_to_point(0) right = self.number_line.number_to_point(1) full_line = Line(left, right) - full_line.highlight("red") - # dot = Dot().shift(left).highlight("red") - # point = Point(left).highlight("red") + full_line.set_color("red") + # dot = Dot().shift(left).set_color("red") + # point = Point(left).set_color("red") intervals = [] for num in np.arange(0, 1.1, .1): open_interval, line = self.add_open_interval(num, 0.1) @@ -1176,7 +1176,7 @@ class StepsToSolution(IntervalScene): self.wait() for denom in range(2, 10): for mob in denom_to_mobs[denom]: - mob.highlight("green") + mob.set_color("green") self.wait() for mob in denom_to_mobs[denom]: mob.to_original_color() @@ -1279,7 +1279,7 @@ class OurSumCanBeArbitrarilySmall(Scene): ]).split() self.add(words[0]) self.wait() - self.play(ShimmerIn(words[1].highlight())) + self.play(ShimmerIn(words[1].set_color())) self.wait() class ProofDoesNotEqualIntuition(Scene): @@ -1482,8 +1482,8 @@ class ShiftSetupByOne(IntervalScene): "\\emph{precisely}", "those 1\\% covered by the intervals" ]).shift(2*UP) words = words.split() - words[1].highlight() - words[3].highlight() + words[1].set_color() + words[3].set_color() self.add(*words) self.play(ShowCreation( Mobject(*intervals), @@ -1507,7 +1507,7 @@ class FinalEquivalence(IntervalScene): arrow = TexMobject("\\Leftrightarrow") top_words = TextMobject("Harmonious numbers are rare,") bot_words = TextMobject("even for the savant") - bot_words.highlight().next_to(top_words, DOWN) + bot_words.set_color().next_to(top_words, DOWN) words = Mobject(top_words, bot_words) words.next_to(arrow) diff --git a/old_projects/nn/part1.py b/old_projects/nn/part1.py index c4d38190..13118756 100644 --- a/old_projects/nn/part1.py +++ b/old_projects/nn/part1.py @@ -349,7 +349,7 @@ def make_transparent(image_mob): image_mob.pixel_array[:,:,0], dtype = 'uint8' ) - image_mob.highlight(WHITE) + image_mob.set_color(WHITE) image_mob.pixel_array[:,:,3] = alpha_vect return image_mob @@ -594,7 +594,7 @@ class WriteAProgram(Scene): ) num.set_stroke(width = 1) color = rgba_to_color(1 - (rgb + 0.2)/1.2) - num.highlight(color) + num.set_color(color) num.scale_to_fit_width(0.7*square.get_width()) num.move_to(square) numbers.add(num) @@ -656,8 +656,8 @@ class LayOutPlan(TeacherStudentsScene, NetworkScene): def show_words(self): words = VGroup( - TextMobject("Machine", "learning").highlight(GREEN), - TextMobject("Neural network").highlight(BLUE), + TextMobject("Machine", "learning").set_color(GREEN), + TextMobject("Neural network").set_color(BLUE), ) words.next_to(self.teacher.get_corner(UP+LEFT), UP) words[0].save_state() @@ -714,7 +714,7 @@ class LayOutPlan(TeacherStudentsScene, NetworkScene): "W_l", "\\textbf{a}_l", "+", "b_l", ")" ) - equation.highlight_by_tex_to_color_map({ + equation.set_color_by_tex_to_color_map({ "\\textbf{a}" : GREEN, }) equation.move_to(self.network_mob.get_corner(UP+RIGHT)) @@ -748,7 +748,7 @@ class LayOutPlan(TeacherStudentsScene, NetworkScene): word_group = VGroup(word, rect) word_group.generate_target() word_group.target.move_to(self.equation, LEFT) - word_group.target[0].highlight(YELLOW) + word_group.target[0].set_color(YELLOW) word_group.target[1].set_stroke(width = 0) self.play(ShowCreation(rect)) @@ -773,7 +773,7 @@ class LayOutPlan(TeacherStudentsScene, NetworkScene): network_mob = self.network_mob learning = self.learning_word structure = TextMobject("Structure") - structure.highlight(YELLOW) + structure.set_color(YELLOW) videos = VGroup(*[ VideoIcon().set_fill(RED) for x in range(2) @@ -892,7 +892,7 @@ class AlternateNeuralNetworks(PiCreatureScene): maybe_words.scale(0.8) maybe_words.next_to(morty, UP) maybe_words.to_edge(RIGHT) - maybe_words.highlight(YELLOW) + maybe_words.set_color(YELLOW) self.play( Write(examples[0], run_time = 2), @@ -929,7 +929,7 @@ class NotPerfectAddOn(Scene): words = TextMobject("Not perfect!") words.scale(1.5) arrow = Arrow(UP+RIGHT, DOWN+LEFT, color = RED) - words.highlight(RED) + words.set_color(RED) arrow.to_corner(DOWN+LEFT) words.next_to(arrow, UP+RIGHT) @@ -966,8 +966,8 @@ class BreakDownName(Scene): q2.next_to(name[1].get_bottom(), DOWN+RIGHT, buff = LARGE_BUFF) a1 = Arrow(q1.get_top(), name[0].get_bottom()) a2 = Arrow(q2.get_top(), name.get_corner(DOWN+RIGHT)) - VGroup(q1, a1).highlight(BLUE) - VGroup(q2, a2).highlight(YELLOW) + VGroup(q1, a1).set_color(BLUE) + VGroup(q2, a2).set_color(YELLOW) randy = Randolph().to_corner(DOWN+LEFT) brain = SVGMobject(file_name = "brain") @@ -997,12 +997,12 @@ class BreakDownName(Scene): self.play( Write(q1, run_time = 1), ShowCreation(a1), - name[0].highlight, q1.get_color(), + name[0].set_color, q1.get_color(), ) self.play( Write(q2, run_time = 1), ShowCreation(a2), - name[1].highlight, q2.get_color() + name[1].set_color, q2.get_color() ) self.wait(2) @@ -1019,7 +1019,7 @@ class BreakDownName(Scene): arrow = TexMobject("\\rightarrow") arrow.shift(LEFT) description = TextMobject("Thing that holds a number") - neuron_word.highlight(BLUE) + neuron_word.set_color(BLUE) neuron_word.next_to(arrow, LEFT) neuron_word.shift(0.5*SMALL_BUFF*UP) description.next_to(arrow, RIGHT) @@ -1192,7 +1192,7 @@ class IntroduceEachLayer(PreviewMNistNetwork): rect = SurroundingRectangle(example_num, color = YELLOW) activation = TextMobject("``Activation''") activation.next_to(example_neuron, RIGHT) - activation.highlight(rect.get_color()) + activation.set_color(rect.get_color()) self.play(ShowCreation(rect)) self.play(Write(activation, run_time = 1)) self.wait() @@ -1326,7 +1326,7 @@ class IntroduceEachLayer(PreviewMNistNetwork): rect = SurroundingRectangle(hidden_layers, color = YELLOW) name = TextMobject("``Hidden layers''") name.next_to(rect, UP, SMALL_BUFF) - name.highlight(YELLOW) + name.set_color(YELLOW) q_marks = VGroup() for layer in hidden_layers: for neuron in layer.neurons: @@ -1337,7 +1337,7 @@ class IntroduceEachLayer(PreviewMNistNetwork): q_marks.gradient_highlight(BLUE, YELLOW) q_mark = TextMobject("?").scale(4) q_mark.move_to(hidden_layers) - q_mark.highlight(YELLOW) + q_mark.set_color(YELLOW) q_marks.add(q_mark) self.play( @@ -1370,9 +1370,9 @@ class DiscussChoiceForHiddenLayers(TeacherStudentsScene): self.add(network_mob) two_words = TextMobject("2 hidden layers") - two_words.highlight(YELLOW) + two_words.set_color(YELLOW) sixteen_words = TextMobject("16 neurons each") - sixteen_words.highlight(MAROON_B) + sixteen_words.set_color(MAROON_B) for words in two_words, sixteen_words: words.next_to(rects, UP) @@ -1559,7 +1559,7 @@ class BreakUpMacroPatterns(IntroduceEachLayer): pa[:,:] = 0 pa[i:i+14,j:j+14,:] = temp self.make_transparent(pattern[1]) - pattern[1].highlight(random_bright_color()) + pattern[1].set_color(random_bright_color()) self.added_patterns.add(pattern) self.image_map = image_map @@ -1573,7 +1573,7 @@ class BreakUpMacroPatterns(IntroduceEachLayer): parts = [upper_loop[1], right_line[1]] for mob, color in zip(parts, [YELLOW, RED]): - mob.highlight(color) + mob.set_color(color) mob.save_state() mob.move_to(nine) right_line[1].pixel_array[:14,:,3] = 0 @@ -1601,7 +1601,7 @@ class BreakUpMacroPatterns(IntroduceEachLayer): eight = self.eight upper_loop = self.upper_loop.deepcopy() lower_loop = self.lower_loop - lower_loop[1].highlight(GREEN) + lower_loop[1].set_color(GREEN) equation = self.get_equation(eight, upper_loop, lower_loop) equation.next_to(self.nine_equation, DOWN) @@ -1631,9 +1631,9 @@ class BreakUpMacroPatterns(IntroduceEachLayer): def show_four(self): four = self.four upper_left_line = self.upper_left_line - upper_left_line[1].highlight(BLUE) + upper_left_line[1].set_color(BLUE) horizontal_line = self.horizontal_line - horizontal_line[1].highlight(MAROON_B) + horizontal_line[1].set_color(MAROON_B) right_line = self.right_line.deepcopy() equation = self.get_equation(four, right_line, upper_left_line, horizontal_line) equation.next_to( @@ -1670,7 +1670,7 @@ class BreakUpMacroPatterns(IntroduceEachLayer): ) for pattern in patterns: pattern.add_to_back( - pattern[1].copy().highlight(BLACK, alpha = 1) + pattern[1].copy().set_color(BLACK, alpha = 1) ) everything.remove(*patterns) network_mob = self.network_mob @@ -1756,7 +1756,7 @@ class BreakUpMacroPatterns(IntroduceEachLayer): image_mob.pixel_array[:,:,0], dtype = 'uint8' ) - image_mob.highlight(WHITE) + image_mob.set_color(WHITE) image_mob.pixel_array[:,:,3] = alpha_vect return image_mob @@ -1810,7 +1810,7 @@ class BreakUpMicroPatterns(BreakUpMacroPatterns): def break_down_loop(self): loop = self.loop - loop[0].highlight(WHITE) + loop[0].set_color(WHITE) edges = Group(*[ getattr(self, "loop_edge%d"%d) for d in range(1, 6) @@ -1818,7 +1818,7 @@ class BreakUpMicroPatterns(BreakUpMacroPatterns): colors = color_gradient([BLUE, YELLOW, RED], 5) for edge, color in zip(edges, colors): for mob in edge: - mob.highlight(color) + mob.set_color(color) loop.generate_target() edges.generate_target() for edge in edges: @@ -1860,7 +1860,7 @@ class BreakUpMicroPatterns(BreakUpMacroPatterns): def break_down_long_line(self): randy = self.randy line = self.right_line - line[0].highlight(WHITE) + line[0].set_color(WHITE) edges = Group(*[ getattr(self, "right_line_edge%d"%d) for d in range(1, 4) @@ -1868,7 +1868,7 @@ class BreakUpMicroPatterns(BreakUpMacroPatterns): colors = Color(MAROON_B).range_to(PURPLE, 3) for edge, color in zip(edges, colors): for mob in edge: - mob.highlight(color) + mob.set_color(color) equation = self.get_equation(line, *edges) equation.scale_to_fit_height(self.loop_equation.get_height()) equation.next_to( @@ -1931,7 +1931,7 @@ class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer): ] self.nine = MNistMobject(nine_array.flatten()) self.nine.scale_to_fit_height(1.5) - self.nine[0].highlight(WHITE) + self.nine[0].set_color(WHITE) make_transparent(self.nine[1]) self.nine.next_to(layers[0].neurons, UP) @@ -1964,7 +1964,7 @@ class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer): ] for mob, color in (loop, YELLOW), (line, RED): make_transparent(mob) - mob.highlight(color) + mob.set_color(color) mob.replace(self.nine[1]) line.pixel_array[:14,:,:] = 0 @@ -1979,7 +1979,7 @@ class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer): rect = SurroundingRectangle(layer) words = TextMobject("``Little edge'' layer?") words.next_to(rect, UP, MED_LARGE_BUFF) - words.highlight(YELLOW) + words.set_color(YELLOW) self.play( ShowCreation(rect), @@ -2068,9 +2068,9 @@ class SecondLayerIsLittleEdgeLayer(IntroduceEachLayer): question.to_edge(LEFT) later = TextMobject("We'll get back \\\\ to this") later.to_corner(UP+LEFT) - later.highlight(BLUE) + later.set_color(BLUE) arrow = Arrow(later.get_bottom(), question.get_top()) - arrow.highlight(BLUE) + arrow.set_color(BLUE) self.play(Write(question, run_time = 2)) self.wait() @@ -2140,7 +2140,7 @@ class ManyTasksBreakDownLikeThis(TeacherStudentsScene): "re", "cognition", arg_separator = "" ) - word[1].highlight(BLUE) + word[1].set_color(BLUE) arrows = VGroup() def get_arrow(): arrow = Arrow(ORIGIN, RIGHT, color = BLUE) @@ -2157,7 +2157,7 @@ class ManyTasksBreakDownLikeThis(TeacherStudentsScene): sequence.to_edge(UP) audio_label.next_to(audio, DOWN) - VGroup(audio, audio_label).highlight(YELLOW) + VGroup(audio, audio_label).set_color(YELLOW) audio.save_state() self.teacher_says( @@ -2332,7 +2332,7 @@ class IntroduceWeights(IntroduceEachLayer): question = TextMobject("What", "parameters", "should exist?") parameter_word = question.get_part_by_tex("parameters") - parameter_word.highlight(self.weights_color) + parameter_word.set_color(self.weights_color) question.move_to(neuron.edges_in.get_top(), LEFT) arrow = Arrow( parameter_word.get_bottom(), @@ -2341,7 +2341,7 @@ class IntroduceWeights(IntroduceEachLayer): ) p_labels = VGroup(*[ - TexMobject("p_%d\\!:"%(i+1)).highlight(self.weights_color) + TexMobject("p_%d\\!:"%(i+1)).set_color(self.weights_color) for i in range(8) ] + [TexMobject("\\vdots")]) p_labels.arrange_submobjects(DOWN, aligned_edge = LEFT) @@ -2403,7 +2403,7 @@ class IntroduceWeights(IntroduceEachLayer): parameter_word = question.get_part_by_tex("parameters") question.remove(parameter_word) weights_word = TextMobject("Weights", "")[0] - weights_word.highlight(self.weights_color) + weights_word.set_color(self.weights_color) weights_word.move_to(parameter_word) w_labels = VGroup() @@ -2411,7 +2411,7 @@ class IntroduceWeights(IntroduceEachLayer): w_label = TexMobject( p_label.get_tex_string().replace("p", "w") ) - w_label.highlight(self.weights_color) + w_label.set_color(self.weights_color) w_label.move_to(p_label) w_labels.add(w_label) @@ -2472,7 +2472,7 @@ class IntroduceWeights(IntroduceEachLayer): weighted_sum.add( TexMobject("\\cdots"), TexMobject("+"), - TexMobject("w_n").highlight(self.weights_color), + TexMobject("w_n").set_color(self.weights_color), TexMobject("a_n") ) weighted_sum.arrange_submobjects(RIGHT, buff = SMALL_BUFF) @@ -2653,7 +2653,7 @@ class MotivateSquishing(Scene): ] + [ ["\\cdots", "+", "w_n", "a_n"] ])) - weighted_sum.highlight_by_tex("w_", GREEN) + weighted_sum.set_color_by_tex("w_", GREEN) weighted_sum.to_edge(UP) self.add(weighted_sum) self.weighted_sum = weighted_sum @@ -2685,8 +2685,8 @@ class MotivateSquishing(Scene): def show_interval(self): lower_number_line = self.number_line.copy() lower_number_line.shift(2*DOWN) - lower_number_line.highlight(LIGHT_GREY) - lower_number_line.numbers.highlight(WHITE) + lower_number_line.set_color(LIGHT_GREY) + lower_number_line.numbers.set_color(WHITE) interval = Line( lower_number_line.number_to_point(0), lower_number_line.number_to_point(1), @@ -2714,7 +2714,7 @@ class MotivateSquishing(Scene): line.remove(*line.numbers) ghost_line = line.copy() ghost_line.fade(0.5) - ghost_line.highlight(BLUE_E) + ghost_line.set_color(BLUE_E) self.add(ghost_line, line) lower_line = self.lower_number_line @@ -2871,7 +2871,7 @@ class IncludeBias(IntroduceWeights): activation_word = TextMobject("Activation") activation_word.next_to(neuron, RIGHT) arrow = Arrow(neuron, weighted_sum.get_bottom()) - arrow.highlight(WHITE) + arrow.set_color(WHITE) words = TextMobject("How positive is this?") words.next_to(self.weighted_sum, UP, SMALL_BUFF) @@ -2901,7 +2901,7 @@ class IncludeBias(IntroduceWeights): "Only activate meaningfully \\\\ when", "weighted sum", "$> 10$" ) - words.highlight_by_tex("weighted", GREEN) + words.set_color_by_tex("weighted", GREEN) words.next_to(neuron, RIGHT) self.play(Write(words, run_time = 2)) @@ -2926,7 +2926,7 @@ class IncludeBias(IntroduceWeights): rect = SurroundingRectangle(bias, buff = 0.5*SMALL_BUFF) name = TextMobject("``bias''") name.next_to(rect, DOWN) - VGroup(rect, name).highlight(BLUE) + VGroup(rect, name).set_color(BLUE) self.play( ReplacementTransform( @@ -2971,8 +2971,8 @@ class IncludeBias(IntroduceWeights): args += ["\\cdots", "+", "w_n", "a_n"] args += ["\\big)"] weighted_sum = TexMobject(*args) - weighted_sum.highlight_by_tex("w_", GREEN) - weighted_sum.highlight_by_tex("\\big", YELLOW) + weighted_sum.set_color_by_tex("w_", GREEN) + weighted_sum.set_color_by_tex("\\big", YELLOW) weighted_sum.to_edge(UP, LARGE_BUFF) weighted_sum.shift(RIGHT) @@ -2981,7 +2981,7 @@ class IncludeBias(IntroduceWeights): class BiasForInactiviyWords(Scene): def construct(self): words = TextMobject("Bias for inactivity") - words.highlight(BLUE) + words.set_color(BLUE) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(UP) @@ -3320,7 +3320,7 @@ class WhenTheNetworkFails(MoreHonestMNistNetworkPreview): self.feed_in_image(in_vect) wrong = TextMobject("Wrong!") - wrong.highlight(RED) + wrong.set_color(RED) wrong.next_to(self.network_mob.layers[-1], UP+RIGHT) self.play(Write(wrong, run_time = 1)) @@ -3458,7 +3458,7 @@ class IntroduceWeightMatrix(NetworkScene): 0.75, about_point = a1_label.get_left() ) - w_labels.highlight(GREEN) + w_labels.set_color(GREEN) w_labels.shift(0.6*SMALL_BUFF*DOWN) a_labels.target.shift(0.5*SMALL_BUFF*UP) @@ -3491,7 +3491,7 @@ class IntroduceWeightMatrix(NetworkScene): name.scale(0.75) name.next_to(bias, DOWN, MED_LARGE_BUFF) arrow = Arrow(name, bias, buff = SMALL_BUFF) - VGroup(name, arrow, bias).highlight(BLUE) + VGroup(name, arrow, bias).set_color(BLUE) self.play( FadeIn(name), @@ -3519,7 +3519,7 @@ class IntroduceWeightMatrix(NetworkScene): name.next_to(sigma, UP, MED_LARGE_BUFF) arrow = Arrow(name, sigma, buff = SMALL_BUFF) sigmoid_name = VGroup(name, arrow) - VGroup(sigmoid_name, mob).highlight(YELLOW) + VGroup(sigmoid_name, mob).set_color(YELLOW) self.play( FadeIn(mob), @@ -3617,7 +3617,7 @@ class IntroduceWeightMatrix(NetworkScene): for target, mover in zip(last_row, row): mover.move_to(target) if "w" in mover.get_tex_string(): - mover.highlight(GREEN) + mover.set_color(GREEN) row.next_to(last_row, DOWN, buff = 0.45) last_row = row @@ -3669,7 +3669,7 @@ class IntroduceWeightMatrix(NetworkScene): mob = TexMobject("\\vdots") else: # mob = Circle(radius = 0.2, color = YELLOW) - mob = TexMobject("?").scale(1.3).highlight(YELLOW) + mob = TexMobject("?").scale(1.3).set_color(YELLOW) result_terms.add(mob.move_to(a)) VGroup(result_brackets, result_terms).next_to(equals, RIGHT) @@ -3717,7 +3717,7 @@ class IntroduceWeightMatrix(NetworkScene): rect2 = SurroundingRectangle(result_terms[1]) rectk = SurroundingRectangle(result_terms[-1]) - VGroup(rect2, rectk).highlight(WHITE) + VGroup(rect2, rectk).set_color(WHITE) row2 = self.lower_matrix_rows[0] rowk = self.lower_matrix_rows[-1] @@ -3772,7 +3772,7 @@ class IntroduceWeightMatrix(NetworkScene): b_column.scale(0.85) b_column.arrange_submobjects(DOWN, buff = 0.35) b_column.move_to(a_column) - b_column.highlight(BLUE) + b_column.set_color(BLUE) plus.next_to(a_column_brackets, RIGHT) VGroup(b_brackets, b_column).next_to(plus, RIGHT) @@ -3807,7 +3807,7 @@ class IntroduceWeightMatrix(NetworkScene): parens.stretch_to_fit_height(expression_bounds.get_height()) big_lp.next_to(expression_bounds, LEFT, SMALL_BUFF) big_rp.next_to(expression_bounds, RIGHT, SMALL_BUFF) - parens.highlight(YELLOW) + parens.set_color(YELLOW) self.play( sigma.scale, 2, @@ -3832,7 +3832,7 @@ class IntroduceWeightMatrix(NetworkScene): "\\textbf{b}", "\\big)", ) - expression.highlight_by_tex_to_color_map({ + expression.set_color_by_tex_to_color_map({ "sigma" : YELLOW, "big" : YELLOW, "W" : GREEN, @@ -3940,7 +3940,7 @@ class SigmoidAppliedToVector(Scene): range(33, 33+2), [33+3], ) for i in indices: - tex[i].highlight(YELLOW) + tex[i].set_color(YELLOW) self.add(tex) self.wait() @@ -4119,7 +4119,7 @@ class NeuronIsFunction(MoreHonestMNistNetworkPreview): def network_is_a_function(self): neuron_word = self.neuron_word network_word = TextMobject("Network") - network_word.highlight(YELLOW) + network_word.set_color(YELLOW) network_word.move_to(neuron_word) func_tex = TexMobject( @@ -4405,7 +4405,7 @@ class IntroduceReLU(IntroduceSigmoid): cross = Cross(sigmoid_title) old_school = TextMobject("Old school") old_school.to_corner(UP+RIGHT) - old_school.highlight(RED) + old_school.set_color(RED) arrow = Arrow( old_school.get_bottom(), self.equation.get_right(), @@ -4444,7 +4444,7 @@ class IntroduceReLU(IntroduceSigmoid): self.coords_to_point(4, 4), ), ) - graph.highlight(YELLOW) + graph.set_color(YELLOW) char = self.x_axis_label.replace("$", "") equation = TextMobject("ReLU($%s$) = max$(0, %s)$"%(char, char)) equation.shift(FRAME_X_RADIUS*LEFT/2) @@ -4468,21 +4468,21 @@ class IntroduceReLU(IntroduceSigmoid): def label_input_regions(self): l1, l2 = self.ReLU_graph neg_words = TextMobject("Inactive") - neg_words.highlight(RED) + neg_words.set_color(RED) neg_words.next_to(self.coords_to_point(-2, 0), UP) pos_words = TextMobject("Same as $f(a) = a$") - pos_words.highlight(GREEN) + pos_words.set_color(GREEN) pos_words.next_to( self.coords_to_point(1, 1), DOWN+RIGHT ) self.revert_to_original_skipping_status() - self.play(ShowCreation(l1.copy().highlight(RED))) + self.play(ShowCreation(l1.copy().set_color(RED))) self.play(Write(neg_words)) self.wait() - self.play(ShowCreation(l2.copy().highlight(GREEN))) + self.play(ShowCreation(l2.copy().set_color(GREEN))) self.play(Write(pos_words)) self.wait(2) @@ -4495,7 +4495,7 @@ class CompareSigmoidReLUOnDeepNetworks(PiCreatureScene): x_max = 5, ) sigmoid_graph.stretch_to_fit_width(3) - sigmoid_graph.highlight(YELLOW) + sigmoid_graph.set_color(YELLOW) sigmoid_graph.next_to(lisha, UP+LEFT) sigmoid_graph.shift_onto_screen() sigmoid_name = TextMobject("Sigmoid") @@ -4503,7 +4503,7 @@ class CompareSigmoidReLUOnDeepNetworks(PiCreatureScene): sigmoid_graph.add(sigmoid_name) slow_learner = TextMobject("Slow learner") - slow_learner.highlight(YELLOW) + slow_learner.set_color(YELLOW) slow_learner.to_corner(UP+LEFT) slow_arrow = Arrow( slow_learner.get_bottom(), @@ -4514,7 +4514,7 @@ class CompareSigmoidReLUOnDeepNetworks(PiCreatureScene): Line(2*LEFT, ORIGIN), Line(ORIGIN, np.sqrt(2)*(RIGHT+UP)), ) - relu_graph.highlight(BLUE) + relu_graph.set_color(BLUE) relu_graph.next_to(lisha, UP+RIGHT) relu_name = TextMobject("ReLU") relu_name.move_to(relu_graph, UP) diff --git a/old_projects/nn/part2.py b/old_projects/nn/part2.py index f96b33c8..891b0d0b 100644 --- a/old_projects/nn/part2.py +++ b/old_projects/nn/part2.py @@ -57,9 +57,9 @@ def get_decimal_vector(nums, with_dots = True): for num in nums: decimal = DecimalNumber(num) if num > 0: - decimal.highlight(POSITIVE_COLOR) + decimal.set_color(POSITIVE_COLOR) else: - decimal.highlight(NEGATIVE_COLOR) + decimal.set_color(NEGATIVE_COLOR) decimals.add(decimal) contents = VGroup(*decimals) if with_dots: @@ -124,7 +124,7 @@ class ShowPlan(Scene): title = TextMobject("Plan").scale(1.5) title.to_edge(UP) h_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS) - h_line.highlight(WHITE) + h_line.set_color(WHITE) h_line.next_to(title, DOWN) self.add(title, h_line) @@ -345,7 +345,7 @@ class PreviewLearning(NetworkScene): return LaggedStart( ApplyFunction, edges, lambda mob : ( - lambda m : m.rotate_in_place(np.pi/12).highlight(YELLOW), + lambda m : m.rotate_in_place(np.pi/12).set_color(YELLOW), mob ), rate_func = wiggle @@ -419,10 +419,10 @@ class TrainingVsTestData(Scene): for is_correct, test_example in zip(bools, test_examples.target): if is_correct: mark = TexMobject("\\checkmark") - mark.highlight(GREEN) + mark.set_color(GREEN) else: mark = TexMobject("\\times") - mark.highlight(RED) + mark.set_color(RED) mark.next_to(test_example, LEFT) marks.add(mark) @@ -449,7 +449,7 @@ class TrainingVsTestData(Scene): for train_ex, new_ex in zip(training_examples, new_examples): self.remove(train_ex) self.add(new_ex) - new_ex[0][0].highlight(color) + new_ex[0][0].set_color(color) self.wait(1./30) training_examples = new_examples @@ -463,7 +463,7 @@ class MNistDescription(Scene): def construct(self): title = TextMobject("MNIST Database") title.scale(1.5) - title.highlight(BLUE) + title.set_color(BLUE) authors = TextMobject("LeCun, Cortes and Burges") authors.next_to(title, DOWN) link_words = TextMobject("(links in the description)") @@ -471,7 +471,7 @@ class MNistDescription(Scene): arrows = VGroup(*[Vector(DOWN) for x in range(4)]) arrows.arrange_submobjects(RIGHT, buff = LARGE_BUFF) arrows.next_to(link_words, DOWN) - arrows.highlight(BLUE) + arrows.set_color(BLUE) word_group = VGroup(title, authors, link_words, arrows) word_group.center() @@ -690,14 +690,14 @@ class IntroduceCostFunction(PreviewLearning): for tex in "=", "+", "dots" ]) - w_labels.highlight(self.positive_edge_color) - b.highlight(self.bias_color) - sigma.highlight(YELLOW) + w_labels.set_color(self.positive_edge_color) + b.set_color(self.bias_color) + sigma.set_color(YELLOW) formula.next_to(neuron, RIGHT) weights_word = TextMobject("Weights") weights_word.next_to(neuron.edges_in, RIGHT, aligned_edge = UP) - weights_word.highlight(self.positive_edge_color) + weights_word.set_color(self.positive_edge_color) weights_arrow_to_edges = Arrow( weights_word.get_bottom(), neuron.edges_in[0].get_center(), @@ -717,7 +717,7 @@ class IntroduceCostFunction(PreviewLearning): bias_arrow = Vector(DOWN, color = self.bias_color) bias_arrow.next_to(b, UP, SMALL_BUFF) bias_word.next_to(bias_arrow, UP, SMALL_BUFF) - bias_word.highlight(self.bias_color) + bias_word.set_color(self.bias_color) self.play( Transform(layer0, active_layer0), @@ -859,7 +859,7 @@ class IntroduceCostFunction(PreviewLearning): rect = SurroundingRectangle(last_layer) words = TextMobject("Utter trash") words.next_to(rect, DOWN, aligned_edge = LEFT) - VGroup(rect, words).highlight(YELLOW) + VGroup(rect, words).set_color(YELLOW) self.play( ShowCreation(rect), @@ -884,7 +884,7 @@ class IntroduceCostFunction(PreviewLearning): words = TextMobject( "What's the", "``cost''\\\\", "of this difference?", ) - words.highlight_by_tex("cost", RED) + words.set_color_by_tex("cost", RED) words.next_to(layers, UP) words.to_edge(UP) words.shift_onto_screen() @@ -944,7 +944,7 @@ class IntroduceCostFunction(PreviewLearning): image_group = Group(self.image, self.image_rect) image_group.generate_target() image_group.target.scale(0.5) - cost_of = TextMobject("Cost of").highlight(RED) + cost_of = TextMobject("Cost of").set_color(RED) cost_group = VGroup(cost_of, image_group.target) cost_group.arrange_submobjects(RIGHT) brace = Brace(terms, LEFT) @@ -985,7 +985,7 @@ class IntroduceCostFunction(PreviewLearning): Arrow(ORIGIN, LEFT).next_to(d, LEFT, MED_LARGE_BUFF) for d in decimals ]) - arrows.highlight(WHITE) + arrows.set_color(WHITE) def generate_term_update_func(decimal, desired_decimal): return lambda a : (decimal.number - desired_decimal.number)**2 @@ -1006,7 +1006,7 @@ class IntroduceCostFunction(PreviewLearning): sum_term = DecimalNumber(0) sum_term.next_to(brace.target, LEFT) - sum_term.highlight(RED) + sum_term.set_color(RED) def sum_update(alpha): return sum([ (d1.number - d2.number)**2 @@ -1079,7 +1079,7 @@ class IntroduceCostFunction(PreviewLearning): )) words = TextMobject("Average cost of \\\\ all training data...") - words.highlight(BLUE) + words.set_color(BLUE) words.to_corner(UP+LEFT) self.play( @@ -1178,7 +1178,7 @@ class YellAtNetwork(PiCreatureScene, PreviewLearning): desired.arrange_submobjects(RIGHT) desired.to_edge(UP) - q_marks = TexMobject("???").highlight(RED) + q_marks = TexMobject("???").set_color(RED) q_marks.next_to(arrow, UP, SMALL_BUFF) self.play( @@ -1284,7 +1284,7 @@ class EmphasizeComplexityOfCostFunction(IntroduceCostFunction): image = MNistMobject(in_vect) image.scale_to_fit_height(1.5) image_label = TextMobject("Input") - image_label.highlight(input_words[0].get_color()) + image_label.set_color(input_words[0].get_color()) image_label.next_to(image, UP, SMALL_BUFF) arrow = Arrow(LEFT, RIGHT, color = WHITE) @@ -1333,11 +1333,11 @@ class EmphasizeComplexityOfCostFunction(IntroduceCostFunction): network_mob.target.to_edge(UP, buff = LARGE_BUFF) rect = SurroundingRectangle(network_mob.target, color = BLUE) network_label = TextMobject("Input") - network_label.highlight(input_words[0].get_color()) + network_label.set_color(input_words[0].get_color()) network_label.next_to(rect, UP, SMALL_BUFF) new_output_word = TextMobject("1 number", "(the cost)") - new_output_word[1].highlight(RED).scale(0.9) + new_output_word[1].set_color(RED).scale(0.9) new_output_word.move_to(output_words[1], LEFT) new_output_word.shift(0.5*SMALL_BUFF*DOWN) new_parameter_word = TextMobject(""" @@ -1348,13 +1348,13 @@ class EmphasizeComplexityOfCostFunction(IntroduceCostFunction): new_parameter_word.move_to(parameter_words[1], UP+LEFT) new_title = TextMobject("Cost function") - new_title.highlight(RED) + new_title.set_color(RED) new_title.move_to(self.title) arrow = Arrow(UP, DOWN, color = WHITE) arrow.next_to(rect, DOWN) cost = TextMobject("Cost: 5.4") - cost.highlight(RED) + cost.set_color(RED) cost.next_to(arrow, DOWN) training_data, validation_data, test_data = load_data_wrapper() @@ -1409,11 +1409,11 @@ class EmphasizeComplexityOfCostFunction(IntroduceCostFunction): def get_function_description_words(self, w1, w2, w3): input_words = TextMobject("Input:", w1) - input_words[0].highlight(BLUE) + input_words[0].set_color(BLUE) output_words = TextMobject("Output:", w2) - output_words[0].highlight(YELLOW) + output_words[0].set_color(YELLOW) parameter_words = TextMobject("Parameters:", w3) - parameter_words[0].highlight(GREEN) + parameter_words[0].set_color(GREEN) words = VGroup(input_words, output_words, parameter_words) words.arrange_submobjects(DOWN, aligned_edge = LEFT) words.scale(0.9) @@ -1493,7 +1493,7 @@ class SingleVariableCostFunction(GraphScene): cf1 = TexMobject("C(", "w_1, w_2, \\dots, w_{13{,}002}", ")") cf2 = TexMobject("C(", "w", ")") for cf in cf1, cf2: - VGroup(cf[0], cf[2]).highlight(RED) + VGroup(cf[0], cf[2]).set_color(RED) big_brace, lil_brace = [ Brace(cf[1], DOWN) for cf in cf1, cf2 @@ -1502,7 +1502,7 @@ class SingleVariableCostFunction(GraphScene): lil_brace_text = lil_brace.get_text("Single input") name.next_to(cf1, UP, LARGE_BUFF) - name.highlight(RED) + name.set_color(RED) self.add(name, cf1) self.play( @@ -1598,7 +1598,7 @@ class SingleVariableCostFunction(GraphScene): brace = Brace(deriv_group, UP) words = TextMobject("Sometimes \\\\ infeasible") words.next_to(deriv_group, UP) - words.highlight(BLUE) + words.set_color(BLUE) words.next_to(brace, UP) graph = self.get_graph( @@ -1646,7 +1646,7 @@ class SingleVariableCostFunction(GraphScene): for vect, color in (LEFT, BLUE), (RIGHT, GREEN): arrow = Arrow(ORIGIN, vect, buff = SMALL_BUFF) arrow.shift(point + SMALL_BUFF*UP) - arrow.highlight(color) + arrow.set_color(color) arrows.add(arrow) q_mark = TextMobject("?") q_mark.next_to(arrow, UP, buff = 0) @@ -1829,7 +1829,7 @@ class SingleVariableCostFunction(GraphScene): def get_tangent_line(self, x, color = YELLOW): tangent_line = Line(LEFT, RIGHT).scale(3) - tangent_line.highlight(color) + tangent_line.set_color(color) self.make_line_tangent(tangent_line, x) return tangent_line @@ -1883,14 +1883,14 @@ class TwoVariableInputSpace(Scene): Arrow(ORIGIN, vect).shift(point) for vect in compass_directions(8) ]) - arrows.highlight(WHITE) + arrows.set_color(WHITE) question = TextMobject( "Which direction decreases \\\\", "$C(x, y)$", "most quickly?" ) question.scale(0.7) - question.highlight(YELLOW) - question.highlight_by_tex("C(x, y)", RED) + question.set_color(YELLOW) + question.set_color_by_tex("C(x, y)", RED) question.add_background_rectangle() question.next_to(arrows, LEFT) @@ -1916,7 +1916,7 @@ class TwoVariableInputSpace(Scene): buff = 0, color = GREEN ) - new_arrow.highlight(GREEN) + new_arrow.set_color(GREEN) arrow.save_state() gradient = TexMobject("\\nabla C(x, y)") @@ -1928,14 +1928,14 @@ class TwoVariableInputSpace(Scene): "steepest increase" ) gradient_words.scale(0.7) - gradient_words[-1].highlight(GREEN) + gradient_words[-1].set_color(GREEN) gradient_words.next_to(gradient, UP, SMALL_BUFF) gradient_words.add_background_rectangle(opacity = 1) gradient_words.shift(LEFT) anti_arrow = new_arrow.copy() anti_arrow.rotate(np.pi, about_point = dot.get_center()) - anti_arrow.highlight(RED) + anti_arrow.set_color(RED) self.play( Transform(arrow, new_arrow), @@ -1986,7 +1986,7 @@ class GradientDescentAlgorithm(Scene): words.to_corner(DOWN+LEFT) for word in words[:2]: - word[1].highlight(RED) + word[1].set_color(RED) for word in words: self.play(Write(word, run_time = 1)) @@ -1995,7 +1995,7 @@ class GradientDescentAlgorithm(Scene): class GradientDescentName(Scene): def construct(self): words = TextMobject("Gradient descent") - words.highlight(BLUE) + words.set_color(BLUE) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(DOWN) @@ -2016,7 +2016,7 @@ class ShowFullCostFunctionGradient(PreviewLearning): nums = [2.25, -1.57, 1.98, -1.16, 3.82, 1.21] decimals = VGroup(*[ - DecimalNumber(num).highlight( + DecimalNumber(num).set_color( BLUE_D if num > 0 else RED ) for num in nums @@ -2042,7 +2042,7 @@ class ShowFullCostFunctionGradient(PreviewLearning): words.next_to(column_vect, UP) lhs = TexMobject("\\vec{\\textbf{W}}", "=") - lhs[0].highlight(YELLOW) + lhs[0].set_color(YELLOW) lhs.next_to(column_vect, LEFT) self.play( @@ -2069,7 +2069,7 @@ class ShowFullCostFunctionGradient(PreviewLearning): "-", "\\nabla", "C(", "\\vec{\\textbf{W}}", ")", "=" ) lhs.shift(2*RIGHT) - lhs.highlight_by_tex("W", YELLOW) + lhs.set_color_by_tex("W", YELLOW) old_decimals = VGroup(*filter( lambda m : isinstance(m, DecimalNumber), column_vect[1] @@ -2078,7 +2078,7 @@ class ShowFullCostFunctionGradient(PreviewLearning): new_nums = [0.18, 0.45, -0.51, 0.4, -0.32, 0.82] for decimal, new_num in zip(old_decimals, new_nums): new_decimal = DecimalNumber(new_num) - new_decimal.highlight(BLUE if new_num > 0 else RED_B) + new_decimal.set_color(BLUE if new_num > 0 else RED_B) new_decimal.move_to(decimal) new_decimals.add(new_decimal) rhs = VGroup( @@ -2136,7 +2136,7 @@ class HowMinimizingCostMeansBetterTrainingPerformance(IntroduceCostFunction): words = TextMobject("Minimize cost $\\dots$") words.next_to(decimals, UP, MED_LARGE_BUFF) - words.highlight(YELLOW) + words.set_color(YELLOW) # words.shift(LEFT) def generate_update(n1, n2): @@ -2204,7 +2204,7 @@ class NonSpatialGradientIntuition(Scene): def add_vector(self): lhs = TexMobject("\\vec{\\textbf{W}}", "=") - lhs[0].highlight(self.w_color) + lhs[0].set_color(self.w_color) lhs.to_edge(LEFT) ws = VGroup(*[ @@ -2215,7 +2215,7 @@ class NonSpatialGradientIntuition(Scene): ["w_{13{,}00%d}"%d for d in range(3)] ) ]) - ws.highlight(self.w_color) + ws.set_color(self.w_color) ws.arrange_submobjects(DOWN) lb, rb = brackets = TexMobject("\\big[", "\\big]").scale(2) brackets.stretch_to_fit_height(1.2*ws.get_height()) @@ -2241,7 +2241,7 @@ class NonSpatialGradientIntuition(Scene): "-\\nabla", "C(", "\\vec{\\textbf{W}}", ")", "=" ) lhs.next_to(vect, RIGHT, LARGE_BUFF) - lhs.highlight_by_tex("W", self.w_color) + lhs.set_color_by_tex("W", self.w_color) decimals = VGroup() nums = [0.31, 0.03, -1.25, 0.78, -0.37, 0.16] @@ -2249,9 +2249,9 @@ class NonSpatialGradientIntuition(Scene): decimal = DecimalNumber(num) decimal.scale(self.text_scale_value) if num > 0: - decimal.highlight(self.positive_color) + decimal.set_color(self.positive_color) else: - decimal.highlight(self.negative_color) + decimal.set_color(self.negative_color) decimal.move_to(w) decimals.add(decimal) new_dots = dots.copy() @@ -2297,7 +2297,7 @@ class NonSpatialGradientIntuition(Scene): color = self.negative_color phrase = TextMobject("should", verb) phrase.scale(self.text_scale_value) - phrase.highlight_by_tex(verb, color) + phrase.set_color_by_tex(verb, color) w.generate_target() group = VGroup(w.target, phrase) group.arrange_submobjects(RIGHT) @@ -2333,7 +2333,7 @@ class NonSpatialGradientIntuition(Scene): color = WHITE words = TextMobject(adj) words.scale(self.text_scale_value) - words.highlight(color) + words.set_color(color) words.next_to(phrase, RIGHT, SMALL_BUFF) magnitude_words.add(words) @@ -2383,7 +2383,7 @@ class SomeConnectionsMatterMoreThanOthers(PreviewLearning): edge.set_stroke(YELLOW, 4) words = TextMobject("This weight \\\\ matters a lot") words.next_to(layers[-1], UP).to_edge(UP) - words.highlight(YELLOW) + words.set_color(YELLOW) arrow = Arrow(words.get_bottom(), edge.get_center()) self.play( @@ -2400,9 +2400,9 @@ class SomeConnectionsMatterMoreThanOthers(PreviewLearning): words = TextMobject("Who even cares \\\\ about this weight?") words.next_to(self.network_mob.layers[-1], DOWN) words.to_edge(DOWN) - words.highlight(color) + words.set_color(color) arrow = Arrow(words.get_top(), edge.get_center(), buff = SMALL_BUFF) - arrow.highlight(color) + arrow.set_color(color) self.play( ShowCreation(edge), @@ -2507,11 +2507,11 @@ class TwoGradientInterpretationsIn2D(Scene): def point_out_direction(self): coords = self.grad.get_part_by_tex("1, 1").copy() vect = self.vect[1].copy() - coords.highlight(YELLOW) - vect.highlight(GREEN) + coords.set_color(YELLOW) + vect.set_color(GREEN) dot = Dot(self.plane.coords_to_point(1, 1)) - dot.highlight(coords.get_color()) + dot.set_color(coords.get_color()) arrow = Arrow( self.plane.coords_to_point(1, 1), self.plane.coords_to_point(4, 2), @@ -2535,9 +2535,9 @@ class TwoGradientInterpretationsIn2D(Scene): self.wait() self.remove(vect) - self.vect[1].highlight(vect.get_color()) + self.vect[1].set_color(vect.get_color()) self.remove(coords) - self.grad.get_part_by_tex("1, 1").highlight(coords.get_color()) + self.grad.get_part_by_tex("1, 1").set_color(coords.get_color()) self.steepest_words = words self.dot = dot @@ -2553,12 +2553,12 @@ class TwoGradientInterpretationsIn2D(Scene): x_rect = SurroundingRectangle(x_part, color = YELLOW) y_rect = SurroundingRectangle(y_part, color = TEAL) x_words = TextMobject("$x$ has 3 times \\\\ the impact...") - x_words.highlight(x_rect.get_color()) + x_words.set_color(x_rect.get_color()) x_words.add_background_rectangle() x_words.next_to(x_rect, UP) # x_words.to_edge(LEFT) y_words = TextMobject("...as $y$") - y_words.highlight(y_rect.get_color()) + y_words.set_color(y_rect.get_color()) y_words.add_background_rectangle() y_words.next_to(y_rect, DOWN) @@ -2779,9 +2779,9 @@ class ContinuouslyRangingNeuron(PreviewLearning): def update_decimal_color(decimal): if neuron.get_fill_opacity() > 0.8: - decimal.highlight(BLACK) + decimal.set_color(BLACK) else: - decimal.highlight(WHITE) + decimal.set_color(WHITE) decimal_color_anim = UpdateFromFunc(decimal, update_decimal_color) self.play(*map(MoveToTarget, [neuron, decimal])) @@ -2845,7 +2845,7 @@ class TestPerformance(PreviewLearning): "{\\text{Number correct}", "\\over", "\\text{total}}", "=", ) - word_frac[0].highlight(GREEN) + word_frac[0].set_color(GREEN) self.frac = self.get_frac() self.equals = TexMobject("=") fracs = VGroup( @@ -2869,7 +2869,7 @@ class TestPerformance(PreviewLearning): ) ] rect_wrong = TextMobject("Wrong!") - rect_wrong.highlight(RED) + rect_wrong.set_color(RED) num_wrong = rect_wrong.copy() arrow = Arrow(LEFT, RIGHT, color = WHITE) @@ -2944,7 +2944,7 @@ class TestPerformance(PreviewLearning): def get_frac(self): frac = TexMobject("{%d"%self.n_correct, "\\over", "%d}"%self.total) - frac[0].highlight(GREEN) + frac[0].set_color(GREEN) return frac def activate_layers(self, test_in): @@ -2964,14 +2964,14 @@ class ReactToPerformance(TeacherStudentsScene): ) title.arrange_submobjects(RIGHT) title.to_edge(UP) - title[-1][0].highlight(GREEN) + title[-1][0].set_color(GREEN) self.play(Write(title, run_time = 2)) last_words = TextMobject( "State of the art \\\\ is", "99.79\\%" ) - last_words[-1].highlight(GREEN) + last_words[-1].set_color(GREEN) self.teacher_says( "That's pretty", "good!", @@ -3012,7 +3012,7 @@ class NotAtAll(TeacherStudentsScene, PreviewLearning): def construct(self): words = TextMobject("Well...\\\\", "not at all!") - words[1].highlight(BLACK) + words[1].set_color(BLACK) network_mob = self.network_mob network_mob.scale_to_fit_height(4) network_mob.to_corner(UP+LEFT) @@ -3026,7 +3026,7 @@ class NotAtAll(TeacherStudentsScene, PreviewLearning): self.change_student_modes(*["sassy"]*3) self.play( self.teacher.change, "concerned_musician", - words[1].highlight, WHITE + words[1].set_color, WHITE ) self.wait(2) @@ -3080,7 +3080,7 @@ class InterpretFirstWeightMatrixRows(TestPerformance): for pixel_array in pixel_arrays: rect = SurroundingRectangle(pixel_array) - rect.highlight(WHITE) + rect.set_color(WHITE) pixel_array.rect = rect words = TextMobject("What second layer \\\\ neurons look for") @@ -3221,7 +3221,7 @@ class InputRandomData(TestPerformance): neurons[choice], output_labels[choice] )) word = TextMobject("What?!?") - word.highlight(YELLOW) + word.set_color(YELLOW) word.next_to(rect, RIGHT) self.play(ShowCreation(rect)) @@ -3382,7 +3382,7 @@ class SomethingToImproveUpon(PiCreatureScene, TestPerformance): lstm.next_to(line.get_right(), UP) modern_variants = VGroup(cnn, lstm) - modern_variants.highlight(YELLOW) + modern_variants.set_color(YELLOW) self.play( Write(words, run_time = 1), @@ -3443,11 +3443,11 @@ class ShiftingFocus(Scene): how, do, networks, learn = words = TextMobject( "How", "do", "neural networks", "learn?" ) - networks.highlight(BLUE) + networks.set_color(BLUE) cross = Cross(networks) viewers = TextMobject("video viewers") viewers.move_to(networks) - viewers.highlight(YELLOW) + viewers.set_color(YELLOW) cap_do = TextMobject("Do") cap_do.move_to(do, DOWN+LEFT) @@ -3554,7 +3554,7 @@ class RandomlyLabeledImageData(Scene): for label, i in zip(labels, permutation): label.generate_target() label.target.move_to(labels[i], LEFT) - label.target.highlight(YELLOW) + label.target.set_color(YELLOW) self.play(LaggedStart( FadeIn, groups, @@ -3660,7 +3660,7 @@ class CompareLearningCurves(GraphScene): self.setup_axes() self.x_axis_label_mob.to_edge(DOWN) self.y_axis_label_mob.to_edge(LEFT) - self.y_axis_label_mob.highlight(RED) + self.y_axis_label_mob.set_color(RED) slow_decrease = self.get_graph( lambda x : 9 - 0.25*x @@ -3675,17 +3675,17 @@ class CompareLearningCurves(GraphScene): faster_decrease.move_to(slow_decrease, UP+LEFT) slow_label = TextMobject("Randomly-labeled data") - slow_label.highlight(slow_decrease.get_color()) + slow_label.set_color(slow_decrease.get_color()) slow_label.to_corner(UP+RIGHT) slow_line = Line(ORIGIN, RIGHT) slow_line.set_stroke(slow_decrease.get_color(), 5) slow_line.next_to(slow_label, LEFT) fast_label = TextMobject("Properly-labeled data") - fast_label.highlight(faster_decrease.get_color()) + fast_label.set_color(faster_decrease.get_color()) fast_label.next_to(slow_label, DOWN) fast_line = slow_line.copy() - fast_line.highlight(faster_decrease.get_color()) + fast_line.set_color(faster_decrease.get_color()) fast_line.next_to(fast_label, LEFT) self.play(FadeIn(slow_label), ShowCreation(slow_line)) @@ -3714,7 +3714,7 @@ class CompareLearningCurves(GraphScene): rect.replace(line, stretch = True) words = TextMobject("Learns structured data more quickly") - words.highlight(YELLOW) + words.set_color(YELLOW) words.next_to(rect, DOWN) words.add_background_rectangle() diff --git a/old_projects/nn/part3.py b/old_projects/nn/part3.py index d74e05e8..f24e2220 100644 --- a/old_projects/nn/part3.py +++ b/old_projects/nn/part3.py @@ -81,18 +81,18 @@ class InterpretGradientComponents(GradientNudging): def add_cost(self): rect = SurroundingRectangle(self.network_mob) - rect.highlight(RED) + rect.set_color(RED) arrow = Vector(DOWN, color = RED) arrow.shift(rect.get_bottom()) cost = DecimalNumber(self.start_cost) - cost.highlight(RED) + cost.set_color(RED) cost.next_to(arrow, DOWN) cost_expression = TexMobject( "C(", "w_0, w_1, \\dots, w_{13{,}001}", ")", "=" ) for tex in "()": - cost_expression.highlight_by_tex(tex, RED) + cost_expression.set_color_by_tex(tex, RED) cost_expression.next_to(cost, DOWN) cost_group = VGroup(cost_expression, cost) cost_group.arrange_submobjects(RIGHT) @@ -125,7 +125,7 @@ class InterpretGradientComponents(GradientNudging): words = TextMobject( "Direction in \\\\ ${13{,}002}$ dimensions?!?") - words.highlight(YELLOW) + words.set_color(YELLOW) words.move_to(grad_vect).to_edge(DOWN) arrow = Arrow( words.get_top(), @@ -152,7 +152,7 @@ class InterpretGradientComponents(GradientNudging): rects = VGroup() for decimal in self.grad_vect.decimals: rects.add(SurroundingRectangle(VGroup(*decimal[-8:]))) - rects.highlight(WHITE) + rects.set_color(WHITE) self.play(LaggedStart(ShowCreation, rects)) self.play(FadeOut(rects)) @@ -167,8 +167,8 @@ class InterpretGradientComponents(GradientNudging): VGroup(edge1, edge2).set_stroke(width = 4) d1 = DecimalNumber(3.2) d2 = DecimalNumber(0.1) - VGroup(edge1, d1).highlight(YELLOW) - VGroup(edge2, d2).highlight(MAROON_B) + VGroup(edge1, d1).set_color(YELLOW) + VGroup(edge2, d2).set_color(MAROON_B) new_vect_contents = VGroup( TexMobject("\\vdots"), d1, TexMobject("\\vdots"), @@ -181,8 +181,8 @@ class InterpretGradientComponents(GradientNudging): "\\dots", "w_n", "\\dots", "w_k", "\\dots" ) new_w_terms.move_to(w_terms, DOWN) - new_w_terms[1].highlight(d1.get_color()) - new_w_terms[3].highlight(d2.get_color()) + new_w_terms[1].set_color(d1.get_color()) + new_w_terms[3].set_color(d2.get_color()) for d, edge in (d1, edge1), (d2, edge2): d.arrow = Arrow( @@ -236,7 +236,7 @@ class InterpretGradientComponents(GradientNudging): group = VGroup(term.number_line, term.brace) group.next_to(term, UP) term.dot = Dot() - term.dot.highlight(term.get_color()) + term.dot.set_color(term.get_color()) term.dot.move_to(term.number_line.get_center()) term.dot.save_state() term.dot.move_to(term) @@ -369,14 +369,14 @@ class GetLostInNotation(PiCreatureScene): ), ) for equation in equations: - equation.highlight_by_tex_to_color_map({ + equation.set_color_by_tex_to_color_map({ "\\delta" : YELLOW, "C" : RED, "b" : MAROON_B, "w" : BLUE, "z" : TEAL, }) - equation.highlight_by_tex("nabla", WHITE) + equation.set_color_by_tex("nabla", WHITE) equations.arrange_submobjects( DOWN, buff = MED_LARGE_BUFF, aligned_edge = LEFT ) @@ -456,7 +456,7 @@ class ShowAveragingCost(PreviewLearning): UP ) cost_words = brace.get_text("Cost of \\\\ one example") - cost_words.highlight(RED) + cost_words.set_color(RED) self.add(last_layer_copy, double_arrow, brace, cost_words) self.set_variables_as_attrs( @@ -484,7 +484,7 @@ class ShowAveragingCost(PreviewLearning): self.play(LaggedStart( ApplyFunction, edges, lambda edge : ( - lambda m : m.rotate_in_place(np.pi/12).highlight(YELLOW), + lambda m : m.rotate_in_place(np.pi/12).set_color(YELLOW), edge, ), rate_func = lambda t : wiggle(t, 4), @@ -497,7 +497,7 @@ class ShowAveragingCost(PreviewLearning): "$\\dots$theoretically", alignment = "" ) - words.highlight(YELLOW) + words.set_color(YELLOW) words.scale(0.8) words.to_corner(UP+LEFT) @@ -588,7 +588,7 @@ class WalkThroughTwoExample(ShowAveragingCost): return LaggedStart( ApplyFunction, edge_group, lambda edge : ( - lambda m : m.rotate_in_place(np.pi/12).highlight(YELLOW), + lambda m : m.rotate_in_place(np.pi/12).set_color(YELLOW), edge ), rate_func = wiggle, @@ -675,7 +675,7 @@ class WalkThroughTwoExample(ShowAveragingCost): decimal.scale_to_fit_width(0.7*neuron.get_width()) decimal.move_to(neuron) if activation > 0.8: - decimal.highlight(BLACK) + decimal.set_color(BLACK) decimals.add(decimal) self.play(Write(decimals, run_time = 2)) @@ -720,15 +720,15 @@ class WalkThroughTwoExample(ShowAveragingCost): arrow.move_to(neuron.get_right()) arrow.shift(0.175*RIGHT) if i == 2: - arrow.highlight(BLUE) + arrow.set_color(BLUE) arrow.rotate_in_place(np.pi) arrows.add(arrow) rect = SurroundingRectangle(VGroup(neuron, label)) if i == 2: - rect.highlight(BLUE) + rect.set_color(BLUE) else: - rect.highlight(RED) + rect.set_color(RED) rects.add(rect) self.play( @@ -773,7 +773,7 @@ class WalkThroughTwoExample(ShowAveragingCost): self.play(LaggedStart( ApplyFunction, arrows, lambda arrow : ( - lambda m : m.scale_in_place(0.5).highlight(YELLOW), + lambda m : m.scale_in_place(0.5).set_color(YELLOW), arrow, ), rate_func = wiggle @@ -845,9 +845,9 @@ class WalkThroughTwoExample(ShowAveragingCost): b = rhs.get_part_by_tex("b", substring = False) dots = rhs.get_part_by_tex("dots") - w_terms.highlight(BLUE) - b.highlight(MAROON_B) - sigma.highlight(YELLOW) + w_terms.set_color(BLUE) + b.set_color(MAROON_B) + sigma.set_color(YELLOW) rhs.to_corner(UP+RIGHT) sigma.save_state() @@ -910,7 +910,7 @@ class WalkThroughTwoExample(ShowAveragingCost): TextMobject("Change", "$a_i$"), ) for words in increase_words: - words.highlight_by_tex_to_color_map({ + words.set_color_by_tex_to_color_map({ "b" : b.get_color(), "w_" : w_terms.get_color(), "a_" : a_terms.get_color(), @@ -956,7 +956,7 @@ class WalkThroughTwoExample(ShowAveragingCost): increase_words[1], DOWN, 1.5*SMALL_BUFF, LEFT ) - added_words.highlight(YELLOW) + added_words.set_color(YELLOW) terms_rect = SurroundingRectangle( VGroup(w_terms[0], a_terms[0]), @@ -1029,7 +1029,7 @@ class WalkThroughTwoExample(ShowAveragingCost): ]) two_neuron_arrow = Vector(MED_LARGE_BUFF*DOWN) two_neuron_arrow.next_to(two_neuron, UP) - VGroup(neuron_arrows, two_neuron_arrow).highlight(YELLOW) + VGroup(neuron_arrows, two_neuron_arrow).set_color(YELLOW) neuron_rects = VGroup(*map( SurroundingRectangle, bright_neurons @@ -1080,7 +1080,7 @@ class WalkThroughTwoExample(ShowAveragingCost): ), UpdateFromFunc( two_decimal, - lambda m : m.highlight(WHITE if m.number < 0.8 else BLACK), + lambda m : m.set_color(WHITE if m.number < 0.8 else BLACK), ), LaggedStart(ShowCreation, bright_edges), run_time = 2, @@ -1114,7 +1114,7 @@ class WalkThroughTwoExample(ShowAveragingCost): ), UpdateFromFunc( two_decimal, - lambda m : m.highlight(WHITE if m.number < 0.8 else BLACK), + lambda m : m.set_color(WHITE if m.number < 0.8 else BLACK), ), ) @@ -1155,7 +1155,7 @@ class WalkThroughTwoExample(ShowAveragingCost): s_edges.alt_position.to_corner(DOWN+RIGHT, LARGE_BUFF) added_words = TextMobject("in proportion to $w_i$") - added_words.highlight(self.w_terms.get_color()) + added_words.set_color(self.w_terms.get_color()) added_words.next_to( increase_words[-1], DOWN, SMALL_BUFF, aligned_edge = LEFT @@ -1164,7 +1164,7 @@ class WalkThroughTwoExample(ShowAveragingCost): self.play(LaggedStart( ApplyFunction, prev_neurons, lambda neuron : ( - lambda m : m.scale_in_place(0.5).highlight(YELLOW), + lambda m : m.scale_in_place(0.5).set_color(YELLOW), neuron ), rate_func = wiggle @@ -1323,7 +1323,7 @@ class WalkThroughTwoExample(ShowAveragingCost): ## words = TextMobject("Propagate backwards") words.to_edge(UP) - words.highlight(BLUE) + words.set_color(BLUE) target_arrows = prev_neuron_arrows.copy() target_arrows.next_to(prev_neurons, RIGHT, SMALL_BUFF) rect = SurroundingRectangle(VGroup( @@ -1402,7 +1402,7 @@ class NotANeuroScientist(TeacherStudentsScene): self.add(quote) asterisks = TextMobject("***") asterisks.next_to(quote.get_corner(UP+RIGHT), RIGHT, SMALL_BUFF) - asterisks.highlight(BLUE) + asterisks.set_color(BLUE) brain = SVGMobject(file_name = "brain") brain.scale_to_fit_height(1.5) @@ -1428,7 +1428,7 @@ class NotANeuroScientist(TeacherStudentsScene): rect = SurroundingRectangle(group) no_claim_words = TextMobject("No claims here...") no_claim_words.next_to(rect, UP) - no_claim_words.highlight(YELLOW) + no_claim_words.set_color(YELLOW) brain_outline = brain.copy() brain_outline.set_fill(opacity = 0) @@ -1733,7 +1733,7 @@ class ConstructGradientFromAllTrainingExamples(Scene): dots_term = lhs.get_part_by_tex("dots") eta = TexMobject("\\eta") eta.move_to(minus, RIGHT) - eta.highlight(MAROON_B) + eta.set_color(MAROON_B) to_fade = VGroup(*it.chain( self.h_lines, self.v_lines, @@ -1818,9 +1818,9 @@ class ConstructGradientFromAllTrainingExamples(Scene): plus = TexMobject("+") plus.next_to(result, LEFT, SMALL_BUFF) result.add_to_back(plus) - result.highlight(BLUE) + result.set_color(BLUE) else: - result.highlight(RED) + result.set_color(RED) return result def get_look_at_anims(self, mob): @@ -1922,7 +1922,7 @@ class OrganizeDataIntoMiniBatches(Scene): mini_batches_words = TextMobject("``Mini-batches''") mini_batches_words.to_edge(UP) - mini_batches_words.highlight(YELLOW) + mini_batches_words.set_color(YELLOW) self.play( rows.space_out_submobjects, 1.5, @@ -1960,7 +1960,7 @@ class OrganizeDataIntoMiniBatches(Scene): return LaggedStart( ApplyFunction, row, lambda row : ( - lambda m : m.scale_in_place(0.75).highlight(YELLOW), + lambda m : m.scale_in_place(0.75).set_color(YELLOW), row ), rate_func = wiggle @@ -2206,10 +2206,10 @@ class SimplestNetworkExample(PreviewLearning): ")" ) expression.shift(2*UP) - expression.highlight_by_tex("C", RED) + expression.set_color_by_tex("C", RED) w_terms = expression.get_parts_by_tex("w_") for w, edge in zip(w_terms, edges): - w.highlight(edge.get_color()) + w.set_color(edge.get_color()) b_terms = expression.get_parts_by_tex("b_") variables = VGroup(*it.chain(w_terms, b_terms)) other_terms = VGroup(*filter( @@ -2306,7 +2306,7 @@ class SimplestNetworkExample(PreviewLearning): not_exponents = TextMobject("Not exponents") not_exponents.next_to(superscript_rects, DOWN, MED_LARGE_BUFF) - not_exponents.highlight(YELLOW) + not_exponents.set_color(YELLOW) self.play( LaggedStart( @@ -2341,7 +2341,7 @@ class SimplestNetworkExample(PreviewLearning): color = WHITE, buff = SMALL_BUFF ) - VGroup(words, rect, y_label).highlight(self.desired_output_color) + VGroup(words, rect, y_label).set_color(self.desired_output_color) self.play(*map(FadeIn, [neuron, decimal])) self.play( @@ -2376,7 +2376,7 @@ class SimplestNetworkExample(PreviewLearning): cost_equation.get_part_by_tex(tex) for tex in "C_0", "a^{(L)}", "y" ] - y.highlight(YELLOW) + y.set_color(YELLOW) cost_word = TextMobject("Cost") cost_word.next_to(C0[0], LEFT, LARGE_BUFF) @@ -2384,7 +2384,7 @@ class SimplestNetworkExample(PreviewLearning): cost_word, C0, buff = SMALL_BUFF ) - VGroup(C0, cost_word, cost_arrow).highlight(self.cost_color) + VGroup(C0, cost_word, cost_arrow).set_color(self.cost_color) expression = TexMobject( "\\text{For example: }" @@ -2402,7 +2402,7 @@ class SimplestNetworkExample(PreviewLearning): decimals.generate_target() for d, n in zip(decimals.target, numbers): d.replace(n, dim_to_match = 1) - d.highlight(n.get_color()) + d.set_color(n.get_color()) self.play( ReplacementTransform(pre_a, a), @@ -2442,9 +2442,9 @@ class SimplestNetworkExample(PreviewLearning): ) formula.next_to(neuron, UP, MED_LARGE_BUFF, RIGHT) aL, equals, sigma, lp, wL, aLm1, plus, bL, rp = formula - wL.highlight(edge.get_color()) + wL.set_color(edge.get_color()) weight_label = wL.copy() - bL.highlight(MAROON_B) + bL.set_color(MAROON_B) bias_label = bL.copy() sigma_group = VGroup(sigma, lp, rp) sigma_group.save_state() @@ -2486,7 +2486,7 @@ class SimplestNetworkExample(PreviewLearning): z_label = TexMobject("z^{(L)}") z_label.next_to(equals, LEFT) z_label.align_to(terms.target, DOWN) - z_label.highlight(self.z_color) + z_label.set_color(self.z_color) z_label2 = z_label.copy() aL_start = VGroup(*self.formula[:4]) @@ -2555,7 +2555,7 @@ class SimplestNetworkExample(PreviewLearning): ] ] for mob in [top_lines] + all_lines: - yellow_copy = mob.copy().highlight(YELLOW) + yellow_copy = mob.copy().set_color(YELLOW) mob.flash = ShowCreationThenDestruction(yellow_copy) self.play(MoveToTarget(top_terms)) @@ -2612,7 +2612,7 @@ class SimplestNetworkExample(PreviewLearning): else: tex = tex.replace("L", "L-1") new_term = TexMobject(tex) - new_term.highlight(term.get_color()) + new_term.set_color(term.get_color()) new_term.move_to(term) new_terms.add(new_term) new_edges = VGroup( @@ -2712,7 +2712,7 @@ class SimplestNetworkExample(PreviewLearning): tip_length = tip_length, buff = SMALL_BUFF, ) - mob.arrow.highlight(mob.get_color()) + mob.arrow.set_color(mob.get_color()) mob.arrow.set_stroke(width = 5) self.play(ShowCreation( @@ -2772,14 +2772,14 @@ class SimplestNetworkExample(PreviewLearning): del_wL = TexMobject("\\partial w^{(L)}") del_wL.scale(self.derivative_scale_val) del_wL.brace = Brace(wL_line, UP, buff = SMALL_BUFF) - del_wL.highlight(wL.get_color()) + del_wL.set_color(wL.get_color()) del_wL.next_to(del_wL.brace, UP, SMALL_BUFF) C0_line = Line(C0.dot.get_center(), C0.dot.get_center()+MED_SMALL_BUFF*RIGHT) del_C0 = TexMobject("\\partial C_0") del_C0.scale(self.derivative_scale_val) del_C0.brace = Brace(C0_line, UP, buff = SMALL_BUFF) - del_C0.highlight(C0.get_color()) + del_C0.set_color(C0.get_color()) del_C0.next_to(del_C0.brace, UP, SMALL_BUFF) for sym in del_wL, del_C0: @@ -2805,8 +2805,8 @@ class SimplestNetworkExample(PreviewLearning): dC_dw = TexMobject( "{\\partial C_0", "\\over", "\\partial w^{(L)} }" ) - dC_dw[0].highlight(del_C0.get_color()) - dC_dw[2].highlight(del_wL.get_color()) + dC_dw[0].set_color(del_C0.get_color()) + dC_dw[2].set_color(del_wL.get_color()) dC_dw.scale(self.derivative_scale_val) dC_dw.to_edge(UP, buff = MED_SMALL_BUFF) dC_dw.shift(3.5*LEFT) @@ -2815,7 +2815,7 @@ class SimplestNetworkExample(PreviewLearning): full_rect_copy = full_rect.copy() words = TextMobject("What we want") words.next_to(full_rect, RIGHT) - words.highlight(YELLOW) + words.set_color(YELLOW) denom_rect = SurroundingRectangle(dC_dw[2]) numer_rect = SurroundingRectangle(dC_dw[0]) @@ -2860,13 +2860,13 @@ class SimplestNetworkExample(PreviewLearning): zL_line = Line(ORIGIN, MED_LARGE_BUFF*LEFT) zL_line.shift(zL.dot.get_center()) del_zL = TexMobject("\\partial z^{(L)}") - del_zL.highlight(zL.get_color()) + del_zL.set_color(zL.get_color()) del_zL.brace = Brace(zL_line, DOWN, buff = SMALL_BUFF) aL_line = Line(ORIGIN, MED_SMALL_BUFF*LEFT) aL_line.shift(aL.dot.get_center()) del_aL = TexMobject("\\partial a^{(L)}") - del_aL.highlight(aL.get_color()) + del_aL.set_color(aL.get_color()) del_aL.brace = Brace(aL_line, DOWN, buff = SMALL_BUFF) for sym in del_zL, del_aL: @@ -2907,9 +2907,9 @@ class SimplestNetworkExample(PreviewLearning): dC_da = TexMobject( "{\\partial C0}", "\\over", "\\partial a^{(L)}}" ) - dz_dw[2].highlight(self.del_wL.get_color()) - VGroup(dz_dw[0], da_dz[2]).highlight(self.z_color) - dC_da[0].highlight(self.cost_color) + dz_dw[2].set_color(self.del_wL.get_color()) + VGroup(dz_dw[0], da_dz[2]).set_color(self.z_color) + dC_da[0].set_color(self.cost_color) equals = TexMobject("=") group = VGroup(equals, dz_dw, da_dz, dC_da) group.arrange_submobjects(RIGHT, SMALL_BUFF) @@ -2945,7 +2945,7 @@ class SimplestNetworkExample(PreviewLearning): group.generate_target() group.target.to_corner(UP+LEFT) words = TextMobject("Chain rule") - words.highlight(YELLOW) + words.set_color(YELLOW) words.next_to(group.target, DOWN) self.play(ShowCreation(rect)) @@ -3175,7 +3175,7 @@ class SimplestNetworkExample(PreviewLearning): return [ ChangingDecimal(decimal, lambda a : neuron.get_fill_opacity()), UpdateFromFunc( - decimal, lambda m : m.highlight( + decimal, lambda m : m.set_color( WHITE if neuron.get_fill_opacity() < 0.8 \ else BLACK ) @@ -3264,7 +3264,7 @@ class SimplestNetworkExample(PreviewLearning): "=", "\\frac{1}{n}", "\\sum_{k=0}^{n-1}", "{\\partial C_k", "\\over", "\\partial w^{(L)}}" ) - full_derivative.highlight_by_tex_to_color_map({ + full_derivative.set_color_by_tex_to_color_map({ "partial C" : self.cost_color, "partial w" : self.del_wL.get_color() }) @@ -3334,7 +3334,7 @@ class SimplestNetworkExample(PreviewLearning): ) for term in terms: if isinstance(term, TexMobject): - term.highlight_by_tex_to_color_map({ + term.set_color_by_tex_to_color_map({ "partial C" : RED, "partial w" : BLUE, "partial b" : MAROON_B, @@ -3348,7 +3348,7 @@ class SimplestNetworkExample(PreviewLearning): vect = VGroup(lb, terms, rb) vect.scale_to_fit_height(5) lhs = TexMobject("\\nabla C", "=") - lhs[0].highlight(RED) + lhs[0].set_color(RED) lhs.next_to(vect, LEFT) VGroup(lhs, vect).to_corner(DOWN+LEFT, buff = LARGE_BUFF) terms.remove(dC_dw.target) @@ -3401,13 +3401,13 @@ class SimplestNetworkExample(PreviewLearning): del_w = dC0_dw[2] del_b = TexMobject("\\partial b^{(L)}") - del_b.highlight(MAROON_B) + del_b.set_color(MAROON_B) del_b.replace(del_w) dz_db = TexMobject( "{\\partial z^{(L)}", "\\over", "\\partial b^{(L)}}" ) - dz_db.highlight_by_tex_to_color_map({ + dz_db.set_color_by_tex_to_color_map({ "partial z" : self.z_color, "partial b" : MAROON_B }) @@ -3488,7 +3488,7 @@ class SimplestNetworkExample(PreviewLearning): dz_daLm1.scale(0.8) dz_daLm1.next_to(self.chain_rule_equation[1], RIGHT, SMALL_BUFF) dz_daLm1.shift(0.7*SMALL_BUFF*UP) - dz_daLm1[0].highlight(self.z_color) + dz_daLm1[0].set_color(self.z_color) dz_daLm1_rect = SurroundingRectangle(dz_daLm1) wL = self.zL_formula[2].copy() wL.next_to(self.chain_rule_rhs[0], LEFT, SMALL_BUFF) @@ -3730,7 +3730,7 @@ class GeneralFormulas(SimplestNetworkExample): for group in all_labels, all_arrows ] for label in start_labels: - label[0][-1].highlight(BLACK) + label[0][-1].set_color(BLACK) self.add(all_decimals) self.play(*it.chain( @@ -3806,7 +3806,7 @@ class GeneralFormulas(SimplestNetworkExample): neuron.arrow.next_to(neuron, RIGHT) neuron.label = TexMobject("y_%d"%i) neuron.label.next_to(neuron.arrow, RIGHT) - neuron.label.highlight(self.desired_output_color) + neuron.label.set_color(self.desired_output_color) desired_output_decimals.add(decimal) arrows.add(neuron.arrow) @@ -3814,7 +3814,7 @@ class GeneralFormulas(SimplestNetworkExample): rect = SurroundingRectangle(desired_output, buff = 0.5*SMALL_BUFF) words = TextMobject("Desired output") words.next_to(rect, DOWN) - VGroup(words, rect).highlight(self.desired_output_color) + VGroup(words, rect).set_color(self.desired_output_color) self.play( FadeIn(rect), @@ -3844,10 +3844,10 @@ class GeneralFormulas(SimplestNetworkExample): "(", "a^{(L)}_j", "-", "y_j", ")", "^2" ) cost_equation.to_corner(UP+RIGHT) - cost_equation[0].highlight(self.cost_color) + cost_equation[0].set_color(self.cost_color) aj.target = cost_equation.get_part_by_tex("a^{(L)}_j") yj.target = cost_equation.get_part_by_tex("y_j") - yj.target.highlight(self.desired_output_color) + yj.target.set_color(self.desired_output_color) to_fade_in = VGroup(*filter( lambda m : m not in [aj.target, yj.target], cost_equation @@ -3889,7 +3889,7 @@ class GeneralFormulas(SimplestNetworkExample): w_label.next_to(ORIGIN, UP, SMALL_BUFF) w_label.rotate(edge.get_angle()) w_label.shift(edge.get_center()) - w_label.highlight(BLUE) + w_label.set_color(BLUE) edges.save_state() edges.generate_target() @@ -3903,7 +3903,7 @@ class GeneralFormulas(SimplestNetworkExample): self.play(LaggedStart( ApplyFunction, edges, lambda e : ( - lambda m : m.rotate_in_place(np.pi/12).highlight(YELLOW), + lambda m : m.rotate_in_place(np.pi/12).set_color(YELLOW), e ), rate_func = wiggle @@ -3937,7 +3937,7 @@ class GeneralFormulas(SimplestNetworkExample): ) for expression in z_formula, compact_z_formula: expression.to_corner(UP+RIGHT) - expression.highlight_by_tex_to_color_map({ + expression.set_color_by_tex_to_color_map({ "z^" : self.z_color, "w^" : self.w_label.get_color(), "b^" : MAROON_B, @@ -3948,7 +3948,7 @@ class GeneralFormulas(SimplestNetworkExample): a_formula = TexMobject( "a^{(L)}_j", "=", "\\sigma(", "z^{(L)}_j", ")" ) - a_formula.highlight_by_tex("z^", self.z_color) + a_formula.set_color_by_tex("z^", self.z_color) a_formula.next_to(z_formula, DOWN, MED_LARGE_BUFF) a_formula.align_to(self.cost_equation, LEFT) aL_part = a_formula[0] @@ -4080,7 +4080,7 @@ class GeneralFormulas(SimplestNetworkExample): path_line = VMobject() path_line.set_points_as_corners(points) path_lines.add(path_line) - path_lines.highlight(YELLOW) + path_lines.set_color(YELLOW) chain_rule = self.chain_rule n = chain_rule.index_of_part_by_tex("sum") @@ -4209,7 +4209,7 @@ class GeneralFormulas(SimplestNetworkExample): chain_rule = TexMobject(*tex) chain_rule.scale(0.8) chain_rule.to_corner(UP+LEFT) - chain_rule.highlight_by_tex_to_color_map({ + chain_rule.set_color_by_tex_to_color_map({ "C_0" : self.cost_color, "z^" : self.z_color, "w^" : self.w_label.get_color() @@ -4253,7 +4253,7 @@ class LayersOfComplexity(Scene): arrow.next_to(brace, LEFT) gradient = TexMobject("\\nabla C") gradient.scale(2) - gradient.highlight(RED) + gradient.set_color(RED) gradient.next_to(arrow, LEFT) self.play(LaggedStart(FadeIn, chain_rule_equations)) @@ -4299,7 +4299,7 @@ class LayersOfComplexity(Scene): big_rect, a_deriv, or_word, last_a_deriv ) for expression in w_deriv, a_deriv, last_a_deriv: - expression.highlight_by_tex_to_color_map({ + expression.set_color_by_tex_to_color_map({ "C" : RED, "z^" : GREEN, "w^" : BLUE, @@ -4320,7 +4320,7 @@ class SponsorFrame(PiCreatureScene): t_shirt_words = TextMobject("Free T-Shirt") t_shirt_words.scale(1.5) - t_shirt_words.highlight(YELLOW) + t_shirt_words.set_color(YELLOW) t_shirt_words.next_to(morty, UP, aligned_edge = RIGHT) human_in_the_loop = TextMobject("Human-in-the-loop approach") diff --git a/old_projects/patreon.py b/old_projects/patreon.py index f1db051c..4db3b659 100644 --- a/old_projects/patreon.py +++ b/old_projects/patreon.py @@ -72,14 +72,14 @@ class SideGigToFullTime(Scene): for x in range(10) ]) dollar_signs.arrange_submobjects(RIGHT, buff = LARGE_BUFF) - dollar_signs.highlight(BLACK) + dollar_signs.set_color(BLACK) dollar_signs.next_to(morty.eyes, RIGHT, buff = 2*LARGE_BUFF) self.play( morty.change_mode, "happy", morty.look_at, dollar_signs, dollar_signs.shift, LEFT, - dollar_signs.highlight, GREEN + dollar_signs.set_color, GREEN ) for x in range(5): last_sign = dollar_signs[0] @@ -105,7 +105,7 @@ class SideGigToFullTime(Scene): new_title.move_to(self.screen_title) q_mark = TexMobject("?") q_mark.next_to(self.cross) - q_mark.highlight(GREEN) + q_mark.set_color(GREEN) self.play(morty.look_at, q_mark) self.play(Transform(self.screen_title, new_title)) @@ -127,8 +127,8 @@ class TakesTime(Scene): rect = PictureInPictureFrame(height = 4) rect.to_edge(RIGHT, buff = LARGE_BUFF) clock = Clock() - clock.hour_hand.highlight(BLUE_C) - clock.minute_hand.highlight(BLUE_D) + clock.hour_hand.set_color(BLUE_C) + clock.minute_hand.set_color(BLUE_D) clock.next_to(rect, LEFT, buff = LARGE_BUFF) self.add(rect) self.play(ShowCreation(clock)) @@ -222,7 +222,7 @@ class TwoTypesOfVideos(Scene): fridays = TextMobject("Every other friday") when_done = TextMobject("When series is done") for words, vect in (fridays, LEFT), (when_done, RIGHT): - words.highlight(YELLOW) + words.set_color(YELLOW) words.next_to( morty, vect, buff = MED_SMALL_BUFF, @@ -264,7 +264,7 @@ class TwoTypesOfVideos(Scene): self.play(Write(words), run_time = 1) self.play(Blink(morty)) self.wait() - self.play(series_list[1].highlight, BLUE) + self.play(series_list[1].set_color, BLUE) self.wait(2) self.play(Blink(morty)) self.wait() @@ -399,9 +399,9 @@ class GrowRonaksSierpinski(Scene): if choose(n, k)%2 == 0: if choose(n-1, k)%2 == 0: continue - dot.highlight(PINK) + dot.set_color(PINK) else: - dot.highlight(WHITE) + dot.set_color(WHITE) dots.add(dot) return dots @@ -467,7 +467,7 @@ class PythagoreanTransformation(Scene): tri[0].get_start() for tri in [tri1] + copies ]) - big_square.highlight(WHITE) + big_square.set_color(WHITE) a_square = Square(side_length = 2) a_square.shift(1.5*(LEFT+UP)) a_square.set_stroke(width = 0) @@ -559,7 +559,7 @@ class MakeALotOfPiCreaturesHappy(Scene): random.shuffle(pi_list) colors = color_gradient([BLUE_D, GREY_BROWN], len(pi_list)) for pi, color in zip(pi_list, colors): - pi.highlight(color) + pi.set_color(color) pis = VGroup(*pi_list) pis.scale_to_fit_height(6) @@ -569,7 +569,7 @@ class MakeALotOfPiCreaturesHappy(Scene): for pi, color in zip(pis.target, colors): pi.change_mode("hooray") # pi.scale_in_place(1) - pi.highlight(color) + pi.set_color(color) self.play( MoveToTarget( pis, @@ -590,7 +590,7 @@ class IntegrationByParts(Scene): f = lambda t : 4*t g = lambda t : 3*smooth(t) curve = ParametricFunction(lambda t : f(t)*RIGHT + g(t)*DOWN) - curve.highlight(YELLOW) + curve.set_color(YELLOW) curve.center() rect = Rectangle() rect.replace(curve, stretch = True) @@ -611,8 +611,8 @@ class IntegrationByParts(Scene): left_point = curve.points[0][0]*RIGHT + point[1]*UP v_lines.add(Line(top_point, point)) h_lines.add(Line(left_point, point)) - v_lines.highlight(BLUE_E) - h_lines.highlight(GREEN_E) + v_lines.set_color(BLUE_E) + h_lines.set_color(GREEN_E) equation = TexMobject( "\\int_0^1 g\\,df", @@ -620,11 +620,11 @@ class IntegrationByParts(Scene): "= \\big(fg \\big)_0^1" ) equation.to_edge(UP) - equation.highlight_by_tex( + equation.set_color_by_tex( "\\int_0^1 g\\,df", upper_right.get_color() ) - equation.highlight_by_tex( + equation.set_color_by_tex( "+\\int_0^1 f\\,dg", lower_left.get_color() ) @@ -669,7 +669,7 @@ class IntegrationByParts(Scene): lp, lnum, comma, rnum, rp = coords = TexMobject( "\\big(f(", "t", "), g(", "t", ")\\big)" ) - coords.highlight_by_tex("0.00", BLACK) + coords.set_color_by_tex("0.00", BLACK) dot = Dot(radius = 0.1) dot.move_to(curve.points[0]) coords.next_to(dot, UP+RIGHT) diff --git a/old_projects/pi_day.py b/old_projects/pi_day.py index b155abbf..38ab05de 100644 --- a/old_projects/pi_day.py +++ b/old_projects/pi_day.py @@ -122,8 +122,8 @@ class CircleConstants(Scene): self.circle_arc = Arc(angle = 0.004, radius = RADIUS) self.radius = Line(ORIGIN, RADIUS * RIGHT) - self.radius.highlight(RADIUS_COLOR) - self.circle_arc.highlight(CIRCUM_COLOR) + self.radius.set_color(RADIUS_COLOR) + self.circle_arc.set_color(CIRCUM_COLOR) self.pi_equals = TexMobject("\pi\\approx", color = CIRCUM_COLOR) self.decimal = DecimalNumber(0, color = CIRCUM_COLOR) @@ -249,7 +249,7 @@ def get_circle_drawing_terms(radius = 1, positioning_func = lambda m : m.center( circle = Circle(color = YELLOW, radius = 1.25) positioning_func(circle) radius = Line(circle.get_center(), circle.points[0]) - radius.highlight(WHITE) + radius.set_color(WHITE) one = TexMobject("1") one.scale(0.75) one_update = UpdateFromFunc( @@ -297,9 +297,9 @@ class PiTauDebate(PiCreatureScene): self.add(pi, tau) pi_value = TextMobject("3.1415...!") - pi_value.highlight(BLUE) + pi_value.set_color(BLUE) tau_value = TextMobject("6.2831...!") - tau_value.highlight(GREEN) + tau_value.set_color(GREEN) self.play(PiCreatureSays( pi, pi_value, @@ -436,7 +436,7 @@ class ManyFormulas(Scene): circle = Circle(color = YELLOW, radius = 2) circle.to_edge(RIGHT) radius = Line(circle.get_center(), circle.get_right()) - radius.highlight(WHITE) + radius.set_color(WHITE) angle_groups = VGroup() for denom in 5, 4, 3, 2: @@ -525,7 +525,7 @@ class EulerWrites628(Scene): "``Let", "$\\pi$", "be the", "circumference", "of a circle whose", "radius = 1''", ) - words.highlight_by_tex_to_color_map({ + words.set_color_by_tex_to_color_map({ "circumference" : YELLOW, "radius" : GREEN, }) @@ -549,7 +549,7 @@ class EulerWrites628(Scene): "=" ) perimeter.next_to(brace, UP, submobject_to_align = perimeter[1], buff = SMALL_BUFF) - perimeter[0][0].highlight(GREEN) + perimeter[0][0].set_color(GREEN) self.play(FadeInFromDown(image)) self.play( @@ -563,7 +563,7 @@ class EulerWrites628(Scene): self.play( pi.scale, 2, pi.shift, DOWN, - pi.highlight, GREEN + pi.set_color, GREEN ) self.wait() self.play( @@ -599,12 +599,12 @@ class HeroAndVillain(Scene): good_euler_label.next_to(good_euler, DOWN) tau_words = TextMobject("Used 6.2831...") tau_words.next_to(good_euler, UP) - tau_words.highlight(GREEN) + tau_words.set_color(GREEN) bad_euler_label = TextMobject("Also Euler...") bad_euler_label.next_to(bad_euler, DOWN) pi_words = TextMobject("Used 3.1415...") - pi_words.highlight(RED) + pi_words.set_color(RED) pi_words.next_to(bad_euler, UP) self.play( @@ -648,7 +648,7 @@ class AnalysisQuote(Scene): HIGHLIGHT_COLOR= GREEN for mob in text, pi_formula: - mob.highlight_by_tex_to_color_map({ + mob.set_color_by_tex_to_color_map({ "semicircumference" : HIGHLIGHT_COLOR, "3.14" : HIGHLIGHT_COLOR, "\pi" : HIGHLIGHT_COLOR @@ -658,8 +658,8 @@ class AnalysisQuote(Scene): radius = 1, positioning_func = lambda circ : circ.next_to(text, DOWN, LARGE_BUFF) ) - terms[0].highlight(HIGHLIGHT_COLOR) - terms[-1].highlight(HIGHLIGHT_COLOR) + terms[0].set_color(HIGHLIGHT_COLOR) + terms[-1].set_color(HIGHLIGHT_COLOR) pi_formula.next_to(terms, DOWN, buff = 0) pi_formula.align_to(text, alignment_vect = RIGHT) @@ -689,9 +689,9 @@ class QuarterTurn(Scene): self.wait() pi_halves = TexMobject("\\pi", "/2") - pi_halves[0].highlight(RED) + pi_halves[0].set_color(RED) tau_fourths = TexMobject("\\tau", "/4") - tau_fourths[0].highlight(GREEN) + tau_fourths[0].set_color(GREEN) for mob in pi_halves, tau_fourths: mob.next_to(decimal, UP) @@ -717,7 +717,7 @@ class UsingTheta(Scene): radius = Line(ORIGIN, circle.get_right()) arc = Arc(radius = 0.5, angle = TAU, num_anchors = 200) - arc.highlight(GREEN) + arc.set_color(GREEN) start_arc = arc.copy() theta = TexMobject("\\theta", "=") @@ -788,7 +788,7 @@ class EulerThinking(Scene): "Should $\\pi$ represent \\\\", "3.1415...", "or", "6.2831...", "?" ) - pi_vs_tau.highlight_by_tex_to_color_map({ + pi_vs_tau.set_color_by_tex_to_color_map({ "3.14" : GREEN, "6.28" : RED, }) @@ -906,14 +906,14 @@ class AskPuzzle(TeacherStudentsScene): "\\frac{1}{n^2} + \\cdots = ", "\\,???" ) series[0].gradient_highlight(BLUE_C, BLUE_B) - series[1].highlight(YELLOW) + series[1].set_color(YELLOW) question = TextMobject( "How should we think about\\\\", "$\\displaystyle \\sum_{n=1}^\\infty \\frac{1}{n^s}$", "for arbitrary $s$?" ) - question[1].highlight(BLUE) + question[1].set_color(BLUE) question[0].shift(SMALL_BUFF*UP) response = TextMobject( @@ -921,7 +921,7 @@ class AskPuzzle(TeacherStudentsScene): "$\\displaystyle \\sum_{n = 1}^{\\infty}$", "?" ) - response[1].highlight(BLUE) + response[1].set_color(BLUE) self.teacher_says(series) self.change_all_student_modes("pondering", look_at_arg = series) @@ -1000,7 +1000,7 @@ class SpecialThanks(Scene): title = TextMobject("Special thanks to:") title.to_edge(UP, LARGE_BUFF) title.scale(1.5) - title.highlight(BLUE) + title.set_color(BLUE) h_line = Line(LEFT, RIGHT).scale(4) h_line.next_to(title, DOWN) h_line.set_stroke(WHITE, 1) @@ -1030,7 +1030,7 @@ class EndScene(PatreonEndScreen): watch_basel = TextMobject( "One such actual piece of math", "(quite pretty!)", ) - watch_basel[0].highlight(YELLOW) + watch_basel[0].set_color(YELLOW) watch_basel.next_to(basel_screen, DOWN, submobject_to_align = watch_basel[0]) self.add(watch_basel) diff --git a/old_projects/playground_counting_in_binary.py b/old_projects/playground_counting_in_binary.py index ed7cd705..e30383fa 100644 --- a/old_projects/playground_counting_in_binary.py +++ b/old_projects/playground_counting_in_binary.py @@ -130,7 +130,7 @@ class ClearLeftSide(SceneFromVideo): def construct(self, scenename): path = os.path.join(ANIMATIONS_DIR, MOVIE_PREFIX, scenename + ".mp4") SceneFromVideo.construct(self, path) - self.highlight_region_over_time_range( + self.set_color_region_over_time_range( Region(lambda x, y : x < -1, shape = self.shape) ) diff --git a/old_projects/putnam.py b/old_projects/putnam.py index 69ee117e..7bc01b18 100644 --- a/old_projects/putnam.py +++ b/old_projects/putnam.py @@ -42,12 +42,12 @@ class IntroducePutnam(Scene): def construct(self): title = TextMobject("Putnam Competition") title.to_edge(UP, buff = MED_SMALL_BUFF) - title.highlight(BLUE) + title.set_color(BLUE) six_hours = TextMobject("6", "hours") three_hours = TextMobject("3", "hours") for mob in six_hours, three_hours: mob.next_to(title, DOWN, MED_LARGE_BUFF) - # mob.highlight(BLUE) + # mob.set_color(BLUE) three_hours.shift(FRAME_X_RADIUS*LEFT/2) three_hours_copy = three_hours.copy() three_hours_copy.shift(FRAME_X_RADIUS*RIGHT) @@ -74,7 +74,7 @@ class IntroducePutnam(Scene): out_of_tens = VGroup() for question in flat_questions: out_of_ten = TexMobject("/10") - out_of_ten.highlight(GREEN) + out_of_ten.set_color(GREEN) out_of_ten.move_to(question) dist = rects[0].get_width() - 1.2 out_of_ten.shift(dist*RIGHT) @@ -82,13 +82,13 @@ class IntroducePutnam(Scene): out_of_120 = TexMobject("/120") out_of_120.next_to(title, RIGHT, LARGE_BUFF) - out_of_120.highlight(GREEN) + out_of_120.set_color(GREEN) out_of_120.generate_target() out_of_120.target.to_edge(RIGHT, LARGE_BUFF) median = TexMobject("2") median.next_to(out_of_120.target, LEFT, SMALL_BUFF) - median.highlight(RED) + median.set_color(RED) median.align_to(out_of_120[-1]) median_words = TextMobject("Typical median $\\rightarrow$") median_words.next_to(median, LEFT) @@ -109,7 +109,7 @@ class IntroducePutnam(Scene): text = TextMobject("\\dots %s \\dots"%s) text.scale(0.7) text.next_to(question, RIGHT) - text.highlight(color) + text.set_color(color) difficulties.add(text) @@ -186,7 +186,7 @@ class NatureOf5sAnd6s(TeacherStudentsScene): self.teacher.get_corner(UP+LEFT), UP, ) new_words = TextMobject("\\dots Potentially very elegant \\dots") - new_words.highlight(GREEN) + new_words.set_color(GREEN) new_words.scale_to_fit_height(mover.target[1].get_height()) new_words.next_to(mover.target[0], RIGHT, SMALL_BUFF) @@ -235,7 +235,7 @@ class IntroduceTetrahedron(ExternallyAnimatedScene): class IntroduceTetrahedronSupplement(Scene): def construct(self): title = TextMobject("4", "random$^*$ points on sphere") - title.highlight(YELLOW) + title.set_color(YELLOW) question = TextMobject("Probability that this tetrahedron \\\\ contains the sphere's center?") question.next_to(title, DOWN, MED_LARGE_BUFF) group = VGroup(title, question) @@ -245,7 +245,7 @@ class IntroduceTetrahedronSupplement(Scene): for n in range(1, 4): num = TextMobject(str(n)) num.replace(title[0], dim_to_match = 1) - num.highlight(YELLOW) + num.set_color(YELLOW) self.add(num) self.wait(0.7) self.remove(num) @@ -351,7 +351,7 @@ class TwoDCase(Scene): "contains the center", "?", arg_separator = "", ) - question.highlight_by_tex("center", self.center_color) + question.set_color_by_tex("center", self.center_color) question.scale(0.8) question.to_corner(UP+RIGHT) self.question = question @@ -499,7 +499,7 @@ class TwoDCase(Scene): "{\\text{Length of arc}", "\\over", "\\text{Circumference}}" ) - answer.highlight_by_tex("arc", BLUE) + answer.set_color_by_tex("arc", BLUE) answer.scale(0.8) answer.next_to(arrow, RIGHT) equals = TexMobject("=") @@ -550,7 +550,7 @@ class TwoDCase(Scene): ninety_degrees = TexMobject("90^\\circ") ninety_degrees.next_to(elbow, DOWN+RIGHT, buff = 0) proportion = DecimalNumber(0.25) - proportion.highlight(self.center_color) + proportion.set_color(self.center_color) # proportion.next_to(arc.point_from_proportion(0.5), DOWN, MED_LARGE_BUFF) proportion.next_to(self.arc_size_arrow, DOWN) def proportion_update_func(alpha): @@ -629,7 +629,7 @@ class TwoDCase(Scene): triangle = self.triangle one_fourth = TexMobject("1/4") - one_fourth.highlight(BLUE) + one_fourth.set_color(BLUE) one_fourth.next_to(self.question, DOWN) self.triangle_update.update(1) @@ -660,7 +660,7 @@ class TwoDCase(Scene): point_mobs = self.point_mobs = VGroup(*[ Dot().move_to(point) for point in points ]) - point_mobs.highlight(self.point_color) + point_mobs.set_color(self.point_color) return point_mobs def get_point_mob_labels(self): @@ -668,7 +668,7 @@ class TwoDCase(Scene): TexMobject("P_%d"%(i+1)) for i in range(len(self.point_mobs)) ]) - point_labels.highlight(self.point_mobs.get_color()) + point_labels.set_color(self.point_mobs.get_color()) self.point_labels = point_labels return point_labels @@ -686,7 +686,7 @@ class TwoDCase(Scene): ) line.rotate(angle) line.shift(self.center) - line.highlight(self.point_color) + line.set_color(self.point_color) lines.add(line) self.center_lines = lines return lines @@ -706,9 +706,9 @@ class TwoDCase(Scene): points = [pm.get_center() for pm in point_mobs] triangle.set_points_as_corners(points) if self.points_contain_center(points): - triangle.highlight(self.positive_triangle_color) + triangle.set_color(self.positive_triangle_color) else: - triangle.highlight(self.negative_triangle_color) + triangle.set_color(self.negative_triangle_color) return triangle return UpdateFromFunc(triangle, update_triangle) @@ -825,7 +825,7 @@ class AverageSizeOfSphericalTriangleSectionSupplement(Scene): "Average size of \\\\", "this section", "?", arg_separator = "" ) - words.highlight_by_tex("section", GREEN) + words.set_color_by_tex("section", GREEN) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(DOWN) self.play(Write(words)) @@ -888,7 +888,7 @@ class RevisitTwoDCase(TwoDCase): "=", "1/4" ) title.to_edge(UP, buff = MED_SMALL_BUFF) - title.highlight_by_tex("1/4", BLUE) + title.set_color_by_tex("1/4", BLUE) four = title[-1][-1] four_circle = Circle(color = YELLOW) four_circle.replace(four, dim_to_match = 1) @@ -914,8 +914,8 @@ class RevisitTwoDCase(TwoDCase): else: self.n_out += 1 nums = map(Integer, [self.n_in, self.n_in, self.n_out]) - VGroup(*nums[:2]).highlight(self.positive_triangle_color) - VGroup(*nums[2:]).highlight(self.negative_triangle_color) + VGroup(*nums[:2]).set_color(self.positive_triangle_color) + VGroup(*nums[2:]).set_color(self.negative_triangle_color) for num, placeholder, position in zip(nums, placeholders, positions): num.move_to(placeholder, position) decimal = DecimalNumber(float(self.n_in)/(self.n_in + self.n_out)) @@ -1001,7 +1001,7 @@ class RevisitTwoDCase(TwoDCase): words.scale(0.8) words.arrange_submobjects(DOWN, buff = MED_LARGE_BUFF) words.next_to(underline, DOWN) - words[1].highlight(YELLOW) + words[1].set_color(YELLOW) point_label_groups = VGroup() for point_mob, label in zip(self.point_mobs, self.point_labels): @@ -1263,7 +1263,7 @@ class Rewrite3DRandomProcedure(Scene): words.scale(0.8) words.arrange_submobjects(DOWN, buff = MED_LARGE_BUFF) words.next_to(underline, DOWN) - words[1].highlight(YELLOW) + words[1].set_color(YELLOW) cross = Cross(words[0]) cross.set_stroke(RED, 6) @@ -1291,7 +1291,7 @@ class ThreeDAnswer(Scene): ) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(DOWN) - words[1].highlight(BLUE) + words[1].set_color(BLUE) self.play(Write(words)) self.wait(2) @@ -1341,8 +1341,8 @@ class ProblemSolvingTakeaways(Scene): "Try reframing the question \\\\ around new constructs", ] ]) - points[0].highlight(BLUE) - points[1].highlight(YELLOW) + points[0].set_color(BLUE) + points[1].set_color(YELLOW) points.arrange_submobjects( DOWN, buff = LARGE_BUFF, aligned_edge = LEFT @@ -1381,7 +1381,7 @@ class BrilliantPuzzle(PiCreatureScene): arrow.tip.shift(SMALL_BUFF*arrow.get_vector()) arrow.tip.shift(-0.1*SMALL_BUFF*arrow.tip.get_center()) # arrow.shift(-MED_SMALL_BUFF*arrow.get_vector()) - arrow.highlight(RED) + arrow.set_color(RED) arrow.pointing_right = True arrows.add(arrow) s1.arrow = arrow @@ -1449,7 +1449,7 @@ class BrilliantPuzzle(PiCreatureScene): else: target_color = RED target_angle = np.pi + np.pi/4 - arrow.target.highlight(target_color) + arrow.target.set_color(target_color) arrow.target.rotate( target_angle, about_point = arrow.student.get_center() @@ -1533,8 +1533,8 @@ class AddedPromoWords(Scene): ) words.scale_to_fit_width(FRAME_WIDTH - 1) words.to_edge(DOWN) - words.highlight_by_tex("2^8", YELLOW) - words.highlight_by_tex("pi", PINK) + words.set_color_by_tex("2^8", YELLOW) + words.set_color_by_tex("pi", PINK) self.play(Write(words)) self.wait() diff --git a/old_projects/pythagorean_proof.py b/old_projects/pythagorean_proof.py index b8ed1b19..1d1ce49a 100644 --- a/old_projects/pythagorean_proof.py +++ b/old_projects/pythagorean_proof.py @@ -151,7 +151,7 @@ class HighlightEmergentTriangles(AddParallelLines): [(3, 3), (0, 3), (0, 2)], ] for triplet in triplets: - self.highlight_region( + self.set_color_region( region_from_polygon_vertices(*triplet), color = "DARK_BLUE" ) @@ -164,7 +164,7 @@ class IndicateTroublePointFromParallelLines(AddParallelLines): circle.shift(DOWN+RIGHT) vect = DOWN+RIGHT arrow = Arrow(circle.get_center()+2*vect, circle.get_boundary_point(vect)) - arrow.highlight(circle.get_color()) + arrow.set_color(circle.get_color()) self.add_mobjects_among(locals().values()) @@ -211,7 +211,7 @@ class DrawAllThreeSquaresWithMoreTriangles(DrawAllThreeSquares): if n not in to_flip: vertices.reverse() if fill: - self.highlight_region( + self.set_color_region( region_from_polygon_vertices(*vertices), color = DARK_BLUE ) @@ -248,7 +248,7 @@ class FillInAreaOfBigRectangle(DrawAllThreeSquaresWithMoreTriangles): args_list = [(10, False)] color = Color("yellow") color.set_rgb(0.3*np.array(color.get_rgb())) - self.highlight_region( + self.set_color_region( region_from_polygon_vertices( (-3, 3), (-3, -2), @@ -276,14 +276,14 @@ class AddTriangleCopyToABSquares(DrawOnlyABSquares): triangle.rotate(np.pi, UP) triangle.place_hypotenuse_on(3*LEFT+DOWN, 2*DOWN) self.add(triangle) - self.highlight_triangles() + self.set_color_triangles() - def highlight_triangles(self): + def set_color_triangles(self): for mob in self.mobjects: if isinstance(mob, Triangle): vertices = list(mob.get_vertices()) for x in range(2): - self.highlight_region(region_from_polygon_vertices( + self.set_color_region(region_from_polygon_vertices( *vertices ), color = DARK_BLUE) vertices.reverse()#silly hack @@ -296,7 +296,7 @@ class AddAllTrianglesToABSquares(AddTriangleCopyToABSquares): triangle.rotate(np.pi, UP) triangle.place_hypotenuse_on(2*DOWN, 3*LEFT+DOWN) self.add(triangle) - self.highlight_triangles() + self.set_color_triangles() @@ -346,7 +346,7 @@ class HighlightCSquareInBigSquare(DrawCSquareWithAllTraingles): args_list = [tuple([False]*4)] def construct(self, *args): DrawCSquareWithAllTraingles.construct(self, *args) - self.highlight_region(region_from_polygon_vertices( + self.set_color_region(region_from_polygon_vertices( *c_square().center().get_vertices() ), color = YELLOW) @@ -457,7 +457,7 @@ class CompletelyFillLargeSquare(LabelLargeSquare): vertices = [2*(DOWN+LEFT), 2*(DOWN+RIGHT), 2*(UP+RIGHT), 2*(UP+LEFT)] vertices.append(vertices[0]) pairs = zip(vertices, vertices[1:]) - self.highlight_region(region_from_line_boundary(*pairs), color = BLUE) + self.set_color_region(region_from_line_boundary(*pairs), color = BLUE) class FillComponentsOfLargeSquare(LabelLargeSquare): @@ -475,12 +475,12 @@ class FillComponentsOfLargeSquare(LabelLargeSquare): ]) for triplet in [[0, 1, 7], [2, 3, 1], [4, 5, 3], [6, 7, 5]]: triplet.append(triplet[0]) - self.highlight_region(region_from_line_boundary(*[ + self.set_color_region(region_from_line_boundary(*[ [points[i], points[j]] for i, j in zip(triplet, triplet[1:]) ]), color = DARK_BLUE) vertices = points[[1, 3, 5, 7, 1]] - self.highlight_region(region_from_line_boundary(*[ + self.set_color_region(region_from_line_boundary(*[ [p1, p2] for p1, p2 in zip(vertices, vertices[1:]) ]), color = YELLOW) @@ -501,9 +501,9 @@ class ShowRearrangementInBigSquare(DrawCSquareWithAllTraingles): class ShowRearrangementInBigSquareWithRegions(ShowRearrangementInBigSquare): def construct(self): ShowRearrangementInBigSquare.construct(self) - self.highlight_region(region_from_polygon_vertices( + self.set_color_region(region_from_polygon_vertices( 2*(LEFT+UP), 2*LEFT+DOWN, RIGHT+DOWN, RIGHT+2*UP ), color = B_COLOR) - self.highlight_region(region_from_polygon_vertices( + self.set_color_region(region_from_polygon_vertices( RIGHT+DOWN, RIGHT+2*DOWN, 2*RIGHT+2*DOWN, 2*RIGHT+DOWN ), color = A_COLOR) diff --git a/old_projects/tattoo.py b/old_projects/tattoo.py index a41e7a11..4b6e26b4 100644 --- a/old_projects/tattoo.py +++ b/old_projects/tattoo.py @@ -47,7 +47,7 @@ class TrigRepresentationsScene(Scene): self.axes = Axes( unit_size = self.unit_length, ) - self.axes.highlight(self.axes_color) + self.axes.set_color(self.axes_color) self.add(self.axes) def init_circle(self): @@ -76,7 +76,7 @@ class TrigRepresentationsScene(Scene): ) theta = TexMobject("\\theta") theta.shift(1.5*arc.point_from_proportion(0.5)) - theta.highlight(self.theta_color) + theta.set_color(self.theta_color) theta.scale_to_fit_height(self.theta_height) line = Line(ORIGIN, self.get_circle_point()) dot = Dot(line.get_end(), radius = 0.05) @@ -161,13 +161,13 @@ class IntroduceCSC(TrigRepresentationsScene): CSC = TextMobject("C", "S", "C", arg_separator = "") csc_of_theta = TextMobject("c", "s", "c", "(\\theta)", arg_separator = "") csc, of_theta = VGroup(*csc_of_theta[:3]), csc_of_theta[-1] - of_theta[1].highlight(YELLOW) + of_theta[1].set_color(YELLOW) CSC.move_to(csc, DOWN) csc_line = self.get_trig_line("csc") csc_line.set_stroke(width = 8) cot_line = self.get_trig_line("cot") - cot_line.highlight(WHITE) + cot_line.set_color(WHITE) brace = Brace(csc_line, LEFT) self.play(Write(Cam_S_C)) @@ -193,7 +193,7 @@ class IntroduceCSC(TrigRepresentationsScene): self.play(ShowCreation(cot_line)) self.play( ShowCreation(csc_line), - csc.highlight, csc_line.get_color(), + csc.set_color, csc_line.get_color(), ) self.wait(3) @@ -352,7 +352,7 @@ class ExplainTrigFunctionDistances(TrigRepresentationsScene, PiCreatureScene): self.change_mode("pondering") for frac, text in (tan_frac, tan_text), (cot_frac, cot_text): - VGroup(frac[5], frac[-2]).highlight(YELLOW) + VGroup(frac[5], frac[-2]).set_color(YELLOW) frac.scale_in_place(0.7) text.save_state() text.next_to(frac, LEFT) @@ -366,7 +366,7 @@ class ExplainTrigFunctionDistances(TrigRepresentationsScene, PiCreatureScene): self.wait() self.play( - self.theta_group[-1].highlight, YELLOW, + self.theta_group[-1].set_color, YELLOW, ShowCreation(line), self.pi_creature.change_mode, 'pondering' ) @@ -435,7 +435,7 @@ class ExplainTrigFunctionDistances(TrigRepresentationsScene, PiCreatureScene): csc_group.add(csc_dot) for text, frac in (sec_text, sec_frac), (csc_text, csc_frac): - frac[-2].highlight(YELLOW) + frac[-2].set_color(YELLOW) frac.scale_in_place(0.7) text.save_state() text.next_to(frac, LEFT) @@ -532,16 +532,16 @@ class ExplainTrigFunctionDistances(TrigRepresentationsScene, PiCreatureScene): ) frac1 = TexMobject("\\frac{\\sin(\\theta)}{1}") frac1.next_to(opp_over_hyp) - frac1[-4].highlight(YELLOW) + frac1[-4].set_color(YELLOW) frac2 = TexMobject("= \\frac{1}{\\csc(\\theta)}") frac2.next_to(frac1) - frac2[-2].highlight(YELLOW) + frac2[-2].set_color(YELLOW) frac_group = VGroup(opp_over_hyp, frac1, frac2) frac_group.scale_to_fit_width(FRAME_X_RADIUS-1) frac_group.next_to(ORIGIN, RIGHT).to_edge(UP) question = TextMobject("Why is this $\\theta$?") - question.highlight(YELLOW) + question.set_color(YELLOW) question.to_corner(UP+RIGHT) arrow = Arrow(question.get_bottom(), arc_theta) @@ -705,10 +705,10 @@ class ExplainTrigFunctionDistances(TrigRepresentationsScene, PiCreatureScene): ) brace.rotate(angle) brace.shift(line.get_center()) - brace.highlight(line.get_color()) + brace.set_color(line.get_color()) text = TexMobject("\\%s(\\theta)"%func_name) text.scale(0.75) - text[-2].highlight(self.theta_color) + text[-2].set_color(self.theta_color) text.add_background_rectangle() text.next_to(brace.get_center_of_mass(), vect, buff = 1.2*MED_SMALL_BUFF) return VGroup(line, brace, text) @@ -760,11 +760,11 @@ class RenameAllInTermsOfSine(Scene): self.wait() for mob, rhs_mob in zip(mobs, rhs_mobs): rhs_mob.next_to(mob) - rhs_mob.highlight(sin.target_color) + rhs_mob.set_color(sin.target_color) mob.save_state() mob.generate_target() VGroup(mob.target, rhs_mob).move_to(mob) - sin.target.highlight(sin.target_color) + sin.target.set_color(sin.target_color) self.play(*it.chain(*[ map(MoveToTarget, mobs), [Write(rhs_mobs)] @@ -776,13 +776,13 @@ class RenameAllInTermsOfSine(Scene): anims += [ FadeOut(rhs_mob), mob.restore, - mob.highlight, mob.target_color, + mob.set_color, mob.target_color, ] self.play(*anims) self.wait() new_rhs_mobs = [ - TexMobject("=\\frac{1}{\\%s(\\theta)}"%s).highlight(color) + TexMobject("=\\frac{1}{\\%s(\\theta)}"%s).set_color(color) for s, color in [ ("cos", cos.target_color), ("tan", tan.target_color), @@ -824,8 +824,8 @@ class MisMatchOfCoPrefix(TeacherStudentsScene): ) self.random_blink() self.play( - VGroup(*eq1[-9:-7]).highlight, YELLOW, - VGroup(*eq2[:2]).highlight, YELLOW, + VGroup(*eq1[-9:-7]).set_color, YELLOW, + VGroup(*eq2[:2]).set_color, YELLOW, *[ ApplyMethod(pi.change_mode, "confused") for pi in self.get_students() diff --git a/old_projects/tau_poem.py b/old_projects/tau_poem.py index e128b965..4f914908 100644 --- a/old_projects/tau_poem.py +++ b/old_projects/tau_poem.py @@ -81,7 +81,7 @@ class HappyTauDayWords(Scene): words = TextMobject("Happy Tau Day Everybody!").scale(2) tau = TauCreature().move_to(2*LEFT + UP) pi = PiCreature().move_to(2*RIGHT + 3*DOWN) - pi.highlight("red") + pi.set_color("red") self.add(words, tau, pi) self.wait() self.play(BlinkPiCreature(tau)) @@ -180,7 +180,7 @@ class TauPoem(Scene): def line0(self): two, pi = TexMobject(["2", "\\pi"]).scale(2).split() self.add(two, pi) - two_copy = deepcopy(two).rotate(np.pi/10).highlight("yellow") + two_copy = deepcopy(two).rotate(np.pi/10).set_color("yellow") self.play(Transform( two, two_copy, rate_func = squish_rate_func( @@ -197,7 +197,7 @@ class TauPoem(Scene): sphere = Mobject() sphere.interpolate( two_pi, - Sphere().highlight("yellow"), + Sphere().set_color("yellow"), 0.8 ) self.add(two_pi) @@ -224,7 +224,7 @@ class TauPoem(Scene): )) blinked = deepcopy(tau).blink() for eye in blinked.eyes: - eye.highlight("black") + eye.set_color("black") self.add(*set(tau.parts).difference(tau.white_parts)) self.play(*[ Transform(*eyes) @@ -252,7 +252,7 @@ class TauPoem(Scene): def pi_speaking(self, text): pi = PiCreature() - pi.highlight("red").give_straight_face() + pi.set_color("red").give_straight_face() pi.shift(3*DOWN + LEFT) bubble = SpeechBubble().speak_from(pi) bubble.write(text) @@ -263,7 +263,7 @@ class TauPoem(Scene): self.add(pi) self.wait() self.play(Transform( - Point(bubble.tip).highlight("black"), + Point(bubble.tip).set_color("black"), bubble )) @@ -293,7 +293,7 @@ class TauPoem(Scene): def line7(self): bubble = ThoughtBubble() heart = ImageMobject("heart") - heart.scale(0.5).shift(DOWN).highlight("red") + heart.scale(0.5).shift(DOWN).set_color("red") for mob in bubble, heart: mob.sort_points(np.linalg.norm) @@ -319,26 +319,26 @@ class TauPoem(Scene): Transform(pi.left_leg, tau.leg), Transform( pi.right_leg, - Point(pi.right_leg.points[0,:]).highlight("black") + Point(pi.right_leg.points[0,:]).set_color("black") ), Transform(pi.mouth, tau.mouth), CounterclockwiseTransform( two, - Dot(two.get_center()).highlight("black") + Dot(two.get_center()).set_color("black") ) ) def line9(self): tau = TauCreature() - pi = PiCreature().highlight("red").give_straight_face() + pi = PiCreature().set_color("red").give_straight_face() pi.scale(0.2).move_to(tau.arm.points[-1,:]) - point = Point(pi.get_center()).highlight("black") + point = Point(pi.get_center()).set_color("black") vanish_local = 3*(LEFT + UP) new_pi = deepcopy(pi) new_pi.scale(0.01) new_pi.rotate(np.pi) new_pi.shift(vanish_local) - Mobject.highlight(new_pi, "black") + Mobject.set_color(new_pi, "black") self.add(tau) self.wait() @@ -391,12 +391,12 @@ class TauPoem(Scene): grid = Grid(radius = radius).shift(grid_center) circle = Circle().scale(interval_size).shift(grid_center) grid.add(TexMobject("e^{ix}").shift(grid_center+UP+RIGHT)) - circle.highlight("white") + circle.set_color("white") tau_line = Line( *[np.pi*interval_size*vect for vect in LEFT, RIGHT], density = 5*DEFAULT_POINT_DENSITY_1D ) - tau_line.highlight("red") + tau_line.set_color("red") tau = TexMobject("\\tau") tau.shift(tau_line.get_center() + 0.5*UP) @@ -445,7 +445,7 @@ class TauPoem(Scene): ) self.add(pi) self.play( - Transform(Point(bubble.tip).highlight("black"), bubble) + Transform(Point(bubble.tip).set_color("black"), bubble) ) def line15(self): @@ -460,7 +460,7 @@ class TauPoem(Scene): self.add(pi, bubble, *formula) self.wait(2) - self.play(ApplyMethod(half.highlight, "yellow")) + self.play(ApplyMethod(half.set_color, "yellow")) def line16(self): self.add(TexMobject( @@ -495,7 +495,7 @@ class TauPoem(Scene): Line(ORIGIN, DOWN) ] for line in lines: - line.highlight("red") + line.set_color("red") self.play(ApplyFunction(trianglify, circle, run_time = 2.0)) self.add(tau_r, r) @@ -510,7 +510,7 @@ class TauPoem(Scene): tau.shift_eyes() tau.move_to(DOWN) pi = PiCreature() - pi.highlight("red") + pi.set_color("red") pi.move_to(DOWN + 3*LEFT) mad_tau = deepcopy(tau).make_mean() mad_tau.arm.wag(0.5*UP, LEFT, 2.0) diff --git a/old_projects/triangle_of_power/end.py b/old_projects/triangle_of_power/end.py index 7abb3289..3fcf42d6 100644 --- a/old_projects/triangle_of_power/end.py +++ b/old_projects/triangle_of_power/end.py @@ -35,7 +35,7 @@ class DontLearnFromSymbols(Scene): ) equation.arrange_submobjects() q_marks = TextMobject("???") - q_marks.highlight(YELLOW) + q_marks.set_color(YELLOW) q_marks.next_to(randy, UP) self.add(randy) @@ -75,19 +75,19 @@ class AsymmetriesInTheMath(Scene): def construct(self): assyms_of_top = VMobject( TextMobject("Asymmetries of "), - TOP("a", "b", "c", radius = 0.75).highlight(BLUE) + TOP("a", "b", "c", radius = 0.75).set_color(BLUE) ).arrange_submobjects() assyms_of_top.to_edge(UP) assyms_of_math = TextMobject(""" Asymmetries of $\\underbrace{a \\cdot a \\cdots a}_{\\text{$b$ times}} = c$ """) - VMobject(*assyms_of_math.split()[13:]).highlight(YELLOW) + VMobject(*assyms_of_math.split()[13:]).set_color(YELLOW) assyms_of_math.next_to(assyms_of_top, DOWN, buff = 2) rad = TexMobject("\\sqrt{\\quad}").to_edge(LEFT).shift(UP) - rad.highlight(RED) + rad.set_color(RED) log = TexMobject("\\log").next_to(rad, DOWN) - log.highlight(RED) + log.set_color(RED) self.play(FadeIn(assyms_of_top)) self.wait() @@ -105,10 +105,10 @@ class AddedVsOplussed(Scene): right_dot = top.put_in_vertex(2, Dot()) plus = top.put_in_vertex(1, TexMobject("+")) oplus = top.put_in_vertex(1, TexMobject("\\oplus")) - left_times.highlight(YELLOW) - right_times.highlight(YELLOW) - plus.highlight(GREEN) - oplus.highlight(BLUE) + left_times.set_color(YELLOW) + right_times.set_color(YELLOW) + plus.set_color(GREEN) + oplus.set_color(BLUE) self.add(top, left_dot, plus, right_times) self.wait() @@ -130,10 +130,10 @@ class ReciprocalTop(Scene): end_two = top.put_on_vertex(0, 2) x = top.put_on_vertex(1, "x") one_over_x = top.put_on_vertex(1, "\\dfrac{1}{x}") - x.highlight(GREEN) - one_over_x.highlight(BLUE) - start_two.highlight(YELLOW) - end_two.highlight(YELLOW) + x.set_color(GREEN) + one_over_x.set_color(BLUE) + start_two.set_color(YELLOW) + end_two.set_color(YELLOW) self.add(top, start_two, x) self.wait() @@ -194,12 +194,12 @@ class ChangeWeCanBelieveIn(Scene): class TriangleOfPowerIsBetter(Scene): def construct(self): top = TOP("x", "y", "z", radius = 0.75) - top.highlight(BLUE) + top.set_color(BLUE) alts = VMobject(*map(TexMobject, [ "x^y", "\\log_x(z)", "\\sqrt[y]{z}" ])) for mob, color in zip(alts.split(), OPERATION_COLORS): - mob.highlight(color) + mob.set_color(color) alts.arrange_submobjects(DOWN) greater_than = TexMobject(">") top.next_to(greater_than, LEFT) diff --git a/old_projects/triangle_of_power/intro.py b/old_projects/triangle_of_power/intro.py index 11f4ab90..ef81b945 100644 --- a/old_projects/triangle_of_power/intro.py +++ b/old_projects/triangle_of_power/intro.py @@ -165,9 +165,9 @@ class Notation(Scene): for trig_part in new_trig.split() ] trig_anim = TrigAnimation() - sin.highlight(trig_anim.sin_color) - cos.highlight(trig_anim.cos_color) - tan.highlight(trig_anim.tan_color) + sin.set_color(trig_anim.sin_color) + cos.set_color(trig_anim.cos_color) + tan.set_color(trig_anim.tan_color) new_trig.to_corner(UP+RIGHT) sum_lines = self.get_harmonic_sum_lines() @@ -248,7 +248,7 @@ class ThreesomeOfNotation(Scene): words = TextMobject("Artificially unrelated") words.to_corner(UP+RIGHT) - words.highlight(YELLOW) + words.set_color(YELLOW) self.play(Write(words)) self.wait() @@ -314,7 +314,7 @@ class TwoThreeEightExample(Scene): ]) self.wait() self.play(ApplyMethod( - VMobject(rad1, rad2).highlight, RED, + VMobject(rad1, rad2).set_color, RED, rate_func = there_and_back, run_time = 2 )) @@ -340,7 +340,7 @@ class TwoThreeEightExample(Scene): ]) self.wait() self.play(ApplyMethod( - VMobject(l, o, g).highlight, RED, + VMobject(l, o, g).set_color, RED, rate_func = there_and_back, run_time = 2 )) @@ -355,9 +355,9 @@ class WhatTheHell(Scene): "\\sqrt[3]{8} = 2", "\\log_2(8) = 3", ]) - # exp.highlight(BLUE_D) - # rad.highlight(RED_D) - # log.highlight(GREEN_D) + # exp.set_color(BLUE_D) + # rad.set_color(RED_D) + # log.set_color(GREEN_D) arrow1 = DoubleArrow(DOWN, UP) arrow2 = arrow1.copy() last = exp @@ -368,7 +368,7 @@ class WhatTheHell(Scene): TexMobject("?!").next_to(arrow, RIGHT) for arrow in arrow1, arrow2 ]) - q_marks.highlight(RED_D) + q_marks.set_color(RED_D) everyone = VMobject(exp, rad, log, arrow1, arrow2, q_marks) everyone.scale(0.7) everyone.to_corner(UP+RIGHT) @@ -383,7 +383,7 @@ class WhatTheHell(Scene): ] ] for phrase, color in zip(phrases, [BLUE, RED, GREEN]): - phrase.split()[1].highlight(color) + phrase.split()[1].set_color(color) self.play(ApplyMethod(randy.change_mode, "angry")) self.play(FadeIn(VMobject(exp, rad, log))) @@ -456,7 +456,7 @@ class LogarithmProperties(Scene): ] bubble.add_content(props[0]) words = TextMobject("What was it again?") - words.highlight(YELLOW) + words.set_color(YELLOW) words.scale(0.5) words.next_to(props[0], UP) @@ -492,7 +492,7 @@ class HaveToShare(Scene): ] share = VMobject(left_dot, top_dot, bottom_dot, line1, line2) share.next_to(words[1], RIGHT, buff = 1) - share.highlight(RED) + share.set_color(RED) for word in words: self.play(FadeIn(word)) diff --git a/old_projects/triangle_of_power/triangle.py b/old_projects/triangle_of_power/triangle.py index ad1bd7f6..9668e9cc 100644 --- a/old_projects/triangle_of_power/triangle.py +++ b/old_projects/triangle_of_power/triangle.py @@ -37,7 +37,7 @@ def get_equation(index, x = 2, y = 3, z = 8, expression_only = False): tex = tex1 else: tex = tex1+tex2 - return TexMobject(tex).highlight(OPERATION_COLORS[index]) + return TexMobject(tex).set_color(OPERATION_COLORS[index]) def get_inverse_rules(): return map(TexMobject, [ @@ -241,7 +241,7 @@ class ShowRule(Scene): self.wait() self.play( Transform(circle, new_circle), - ApplyMethod(new_top.values[index].highlight, circle.color) + ApplyMethod(new_top.values[index].set_color, circle.color) ) self.wait() @@ -255,7 +255,7 @@ class AllThree(Scene): new_args = list(args) new_args[i] = None top = TOP(*new_args, triangle_height_to_number_height = 2) - # top.highlight(OPERATION_COLORS[i]) + # top.set_color(OPERATION_COLORS[i]) top.shift(i*4.5*LEFT) equation = get_equation(i, expression_only = True) equation.scale(3) @@ -286,9 +286,9 @@ class SixDifferentInverses(Scene): self.wait() for s, color in (rules[:4], GREEN), (rules[4:], RED): mob = VMobject(*s) - self.play(ApplyMethod(mob.highlight, color)) + self.play(ApplyMethod(mob.set_color, color)) self.wait() - self.play(ApplyMethod(mob.highlight, WHITE)) + self.play(ApplyMethod(mob.set_color, WHITE)) self.play( ApplyMethod(VMobject(*rules[::2]).to_edge, LEFT), ApplyMethod(VMobject(*rules[1::2]).to_edge, RIGHT), @@ -310,7 +310,7 @@ class SixDifferentInverses(Scene): original = None for i, (top_rule, rule) in enumerate(zip(top_rules, rules)): rule.center().to_edge(UP) - rule.highlight(GREEN if i < 4 else RED) + rule.set_color(GREEN if i < 4 else RED) self.add(rule) new_top_rule = top_rule.copy().center().scale(1.5) anims = [Transform(top_rule, new_top_rule)] @@ -403,14 +403,14 @@ class AdditiveProperty(Scene): ApplyMethod(log_rule.to_edge, DOWN, 1.5) ) t_exp_rule.next_to(exp_rule, DOWN) - t_exp_rule.highlight(GREEN) + t_exp_rule.set_color(GREEN) t_log_rule.next_to(log_rule, UP) - t_log_rule.highlight(RED) + t_log_rule.set_color(RED) self.play( FadeIn(t_exp_rule), FadeIn(t_log_rule), - ApplyMethod(exp_rule.highlight, GREEN), - ApplyMethod(log_rule.highlight, RED), + ApplyMethod(exp_rule.set_color, GREEN), + ApplyMethod(log_rule.set_color, RED), ) self.wait() all_tops = filter( @@ -418,7 +418,7 @@ class AdditiveProperty(Scene): t_exp_rule.split()+t_log_rule.split() ) self.put_in_circles(all_tops) - self.highlight_appropriate_parts(t_exp_rule, t_log_rule) + self.set_color_appropriate_parts(t_exp_rule, t_log_rule) @@ -476,14 +476,14 @@ class AdditiveProperty(Scene): index = i circle = top.put_on_vertex(index, Circle(color = WHITE)) anims.append( - Transform(top.copy().highlight(YELLOW), circle) + Transform(top.copy().set_color(YELLOW), circle) ) self.add(*[anim.mobject for anim in anims]) self.wait() self.play(*anims) self.wait() - def highlight_appropriate_parts(self, t_exp_rule, t_log_rule): + def set_color_appropriate_parts(self, t_exp_rule, t_log_rule): #Horribly hacky circle1 = t_exp_rule.split()[0].put_on_vertex( 2, Circle() @@ -512,7 +512,7 @@ class AdditiveProperty(Scene): for mobs in mob_lists: copies = VMobject(*mobs).copy() self.play(ApplyMethod( - copies.highlight, YELLOW, + copies.set_color, YELLOW, run_time = 0.5 )) self.play(ApplyMethod( @@ -530,8 +530,8 @@ class DrawInsideTriangle(Scene): dot = top.put_in_vertex(0, Dot()) plus = top.put_in_vertex(1, TexMobject("+")) times = top.put_in_vertex(2, TexMobject("\\times")) - plus.highlight(GREEN) - times.highlight(YELLOW) + plus.set_color(GREEN) + times.set_color(YELLOW) self.add(top) self.wait() @@ -545,8 +545,8 @@ class ConstantOnTop(Scene): dot = top.put_in_vertex(1, Dot()) times1 = top.put_in_vertex(0, TexMobject("\\times")) times2 = top.put_in_vertex(2, TexMobject("\\times")) - times1.highlight(YELLOW) - times2.highlight(YELLOW) + times1.set_color(YELLOW) + times2.set_color(YELLOW) three = top.put_on_vertex(1, "3") lower_left_x = top.put_on_vertex(0, "x") lower_right_x = top.put_on_vertex(2, "x") @@ -579,8 +579,8 @@ def get_const_top_TOP(*args): dot = top.put_in_vertex(1, Dot()) times1 = top.put_in_vertex(0, TexMobject("\\times")) times2 = top.put_in_vertex(2, TexMobject("\\times")) - times1.highlight(YELLOW) - times2.highlight(YELLOW) + times1.set_color(YELLOW) + times2.set_color(YELLOW) top.add(dot, times1, times2) return top @@ -598,10 +598,10 @@ class MultiplyWithConstantTop(Scene): top_exp_equation.arrange_submobjects() old_style_exp = TexMobject("(x^3)(y^3) = (xy)^3") old_style_exp.to_edge(UP) - old_style_exp.highlight(GREEN) + old_style_exp.set_color(GREEN) old_style_rad = TexMobject("\\sqrt[3]{x} \\sqrt[3]{y} = \\sqrt[3]{xy}") old_style_rad.to_edge(UP) - old_style_rad.highlight(RED) + old_style_rad.set_color(RED) self.add(top_exp_equation, old_style_exp) self.wait(3) @@ -643,9 +643,9 @@ class RightStaysConstantQ(Scene): for top in top1, top2, top3 ]) old_style_eq1 = TexMobject("\\sqrt[x]{8} ? \\sqrt[y]{8} = \\sqrt[x?y]{8}") - old_style_eq1.highlight(BLUE) + old_style_eq1.set_color(BLUE) old_style_eq2 = TexMobject("\\log_x(8) ? \\log_y(8) = \\log_{x?y}(8)") - old_style_eq2.highlight(YELLOW) + old_style_eq2.set_color(YELLOW) for eq in old_style_eq1, old_style_eq2: eq.to_edge(UP) @@ -696,9 +696,9 @@ class ConstantLowerRight(Scene): def construct(self): top = TOP() times = top.put_in_vertex(0, TexMobject("\\times")) - times.highlight(YELLOW) + times.set_color(YELLOW) oplus = top.put_in_vertex(1, TexMobject("\\oplus")) - oplus.highlight(BLUE) + oplus.set_color(BLUE) dot = top.put_in_vertex(2, Dot()) eight = top.put_on_vertex(2, TexMobject("8")) @@ -713,7 +713,7 @@ class ConstantLowerRight(Scene): top1, top2, top3 = tops = [ top.copy() for i in range(3) ] - big_oplus = TexMobject("\\oplus").scale(2).highlight(BLUE) + big_oplus = TexMobject("\\oplus").scale(2).set_color(BLUE) equals = TexMobject("=") equation = VMobject( top1, big_oplus, top2, equals, top3 @@ -727,7 +727,7 @@ class ConstantLowerRight(Scene): old_style_eq = TexMobject( "\\dfrac{1}{\\frac{1}{\\log_x(8)} + \\frac{1}{\\log_y(8)}} = \\log_{xy}(8)" ) - old_style_eq.to_edge(UP).highlight(RED) + old_style_eq.to_edge(UP).set_color(RED) triple_top_copy = VMobject(*[ top.copy() for i in range(3) @@ -758,8 +758,8 @@ class ConstantLowerRight(Scene): frac.shift(frac_lower_right - frac.get_corner(DOWN+RIGHT)) new_old_style_eq.submobjects[-4] = frac new_old_style_eq.to_edge(UP) - new_old_style_eq.highlight(RED) - big_times = TexMobject("\\times").highlight(YELLOW) + new_old_style_eq.set_color(RED) + big_times = TexMobject("\\times").set_color(YELLOW) big_times.shift(big_oplus.get_center()) self.play( Transform(old_style_eq, new_old_style_eq), diff --git a/old_projects/triples.py b/old_projects/triples.py index f81f15b8..29100b79 100644 --- a/old_projects/triples.py +++ b/old_projects/triples.py @@ -50,7 +50,7 @@ class IntroduceTriples(TeacherStudentsScene): def construct(self): title = TexMobject("a", "^2", "+", "b", "^2", "=", "c", "^2") for color, char in zip(SIDE_COLORS, "abc"): - title.highlight_by_tex(char, color) + title.set_color_by_tex(char, color) title.to_corner(UP + RIGHT) triples = [ @@ -124,7 +124,7 @@ class IntroduceTriples(TeacherStudentsScene): str(a), "^2", "+", str(b), "^2", "=", str(c), "^2" ) for num, color in zip([a, b, c], SIDE_COLORS): - equation.highlight_by_tex(str(num), color) + equation.set_color_by_tex(str(num), color) equation.next_to(title, DOWN, MED_LARGE_BUFF) equation.shift_onto_screen() @@ -141,14 +141,14 @@ class IntroduceTriples(TeacherStudentsScene): self.play(self.teacher.change_mode, "happy") for start, target in zip([a_square, b_square], c_square_parts): mover = start.copy().set_fill(opacity = 0) - target.highlight(start.get_color()) + target.set_color(start.get_color()) self.play(ReplacementTransform( mover, target, run_time = 2, path_arc = np.pi/2 )) self.play(Write(equation)) - self.play(c_square.highlight, C_COLOR) + self.play(c_square.set_color, C_COLOR) self.wait() self.play(*map(FadeOut, [full_group, equation])) @@ -163,7 +163,7 @@ class CompareToFermatsLastTheorem(TeacherStudentsScene): ] for expression in expressions: for char, color in zip("abc", SIDE_COLORS): - expression.highlight_by_tex(char, color) + expression.set_color_by_tex(char, color) expression.next_to(self.get_pi_creatures(), UP, buff = 1.3) square_expression = expressions[0] low_expression = expressions[1] @@ -176,7 +176,7 @@ class CompareToFermatsLastTheorem(TeacherStudentsScene): low_text = low_brace.get_text( "No integer solutions", buff = SMALL_BUFF ) - low_text.highlight(RED) + low_text.set_color(RED) self.add(square_expression, top_brace, top_text) self.change_student_modes(*["pondering"]*3) @@ -227,7 +227,7 @@ class ShowManyTriples(Scene): titles = VGroup() for i, (a, b, c) in enumerate(triples): triangle = Polygon(ORIGIN, a*RIGHT, a*RIGHT+b*UP) - triangle.highlight(WHITE) + triangle.set_color(WHITE) max_width = max_height = 4 triangle.scale_to_fit_height(max_height) if triangle.get_width() > max_width: @@ -236,7 +236,7 @@ class ShowManyTriples(Scene): num_strings = map(str, (a, b, c)) labels = map(TexMobject, num_strings) for label, color in zip(labels, SIDE_COLORS): - label.highlight(color) + label.set_color(color) labels[0].next_to(triangle, DOWN) labels[1].next_to(triangle, RIGHT) labels[2].next_to(triangle.get_center(), UP+LEFT) @@ -246,7 +246,7 @@ class ShowManyTriples(Scene): str(a), "^2", "+", str(b), "^2", "=", str(c), "^2" ) for num, color in zip([a, b, c], SIDE_COLORS): - title.highlight_by_tex(str(num), color) + title.set_color_by_tex(str(num), color) title.next_to(triangle, UP, LARGE_BUFF) title.generate_target() title.target.scale(0.5) @@ -355,7 +355,7 @@ class PythagoreanProof(Scene): def add_title(self): title = TexMobject("a^2", "+", "b^2", "=", "c^2") for color, char in zip(SIDE_COLORS, "abc"): - title.highlight_by_tex(char, color) + title.set_color_by_tex(char, color) title.to_edge(UP) self.add(title) self.title = title @@ -430,7 +430,7 @@ class PythagoreanProof(Scene): def add_labels_to_squares(self, squares, side_labels): for label, square in zip(side_labels, squares): label.target = TexMobject(label.get_tex_string() + "^2") - label.target.highlight(label.get_color()) + label.target.set_color(label.get_color()) # label.target.scale(0.7) label.target.move_to(square) square.add(label) @@ -440,8 +440,8 @@ class PythagoreanProof(Scene): def add_new_triangles(self, triangle, added_triangles): brace = Brace(added_triangles, DOWN) label = TexMobject("a", "+", "b") - label.highlight_by_tex("a", A_COLOR) - label.highlight_by_tex("b", B_COLOR) + label.set_color_by_tex("a", A_COLOR) + label.set_color_by_tex("b", B_COLOR) label.next_to(brace, DOWN) self.play(ReplacementTransform( @@ -467,7 +467,7 @@ class PythagoreanProof(Scene): def get_triangle_side_labels(self, triangle): a, b, c = map(TexMobject, "abc") for mob, color in zip([a, b, c], SIDE_COLORS): - mob.highlight(color) + mob.set_color(color) a.next_to(triangle, DOWN) b.next_to(triangle, RIGHT) c.next_to(triangle.get_center(), LEFT) @@ -688,7 +688,7 @@ class ReframeOnLattice(PiCreatureScene): tuple_label.add_background_rectangle() tuple_label.next_to(dot, RIGHT, SMALL_BUFF) line = Line(self.plane.get_center_point(), point) - line.highlight(dot.get_color()) + line.set_color(dot.get_color()) distance_labels = VGroup() for tex in "2^2 + 1^2", "5": pre_label = TexMobject("\\sqrt{%s}"%tex) @@ -765,7 +765,7 @@ class ReframeOnLattice(PiCreatureScene): color = MAROON_B ) square_label = TexMobject("z \\to z^2") - square_label.highlight(arrow.get_color()) + square_label.set_color(arrow.get_color()) square_label.add_background_rectangle() square_label.next_to( arrow.point_from_proportion(0.5), @@ -875,7 +875,7 @@ class ReframeOnLattice(PiCreatureScene): example_label = self.example_label distance_label = self.distance_label - alt_line = line.copy().highlight(RED) + alt_line = line.copy().set_color(RED) arc = Arc( angle = line.get_angle(), radius = 0.7, @@ -1036,7 +1036,7 @@ class OneMoreExample(Scene): point = self.plane.coords_to_point(3, 2) dot = Dot(point, color = self.dot_color) line = Line(self.plane.get_center_point(), point) - line.highlight(dot.get_color()) + line.set_color(dot.get_color()) number_label = TexMobject("3+2i") number_label.add_background_rectangle() number_label.next_to(dot, RIGHT, SMALL_BUFF) @@ -1087,19 +1087,19 @@ class OneMoreExample(Scene): top_line = TexMobject("(3+2i)", "(3+2i)") for part in top_line: for i, color in zip([1, 3], [BLUE, YELLOW]): - part[i].highlight(color) + part[i].set_color(color) second_line = TexMobject( "\\big( 3^2 + (2i)^2 \\big) + " + \ "\\big(3 \\cdot 2 + 2 \\cdot 3 \\big)i" ) for i in 1, 12, 18: - second_line[i].highlight(BLUE) + second_line[i].set_color(BLUE) for i in 5, 14, 16: - second_line[i].highlight(YELLOW) + second_line[i].set_color(YELLOW) second_line.scale(0.9) final_line = TexMobject("5 + 12i") for i in 0, 2, 3: - final_line[i].highlight(GREEN) + final_line[i].set_color(GREEN) lines = VGroup(top_line, second_line, final_line) lines.arrange_submobjects(DOWN, buff = MED_LARGE_BUFF) lines.next_to(rect.get_top(), DOWN) @@ -1169,7 +1169,7 @@ class OneMoreExample(Scene): point = self.plane.coords_to_point(5, 12) dot = Dot(point, color = GREEN) line = Line(self.plane.get_center_point(), point) - line.highlight(dot.get_color()) + line.set_color(dot.get_color()) distance_label = TexMobject("13") distance_label.add_background_rectangle() distance_label.next_to(line.get_center(), UP+LEFT, SMALL_BUFF) @@ -1231,7 +1231,7 @@ class GeneralExample(OneMoreExample): zero_point = self.plane.number_to_point(0) dot = Dot(z_point, color = self.dot_color) line = Line(zero_point, z_point) - line.highlight(dot.get_color()) + line.set_color(dot.get_color()) label = TexMobject(complex_string_with_i(z)) label.add_background_rectangle() label.next_to(dot, RIGHT, SMALL_BUFF) @@ -1239,7 +1239,7 @@ class GeneralExample(OneMoreExample): square_point = self.plane.number_to_point(z**2) square_dot = Dot(square_point, color = self.square_color) square_line = Line(zero_point, square_point) - square_line.highlight(square_dot.get_color()) + square_line.set_color(square_dot.get_color()) square_label = TexMobject(complex_string_with_i(z**2)) square_label.add_background_rectangle() square_label.next_to(square_dot, UP+RIGHT, SMALL_BUFF) @@ -1254,10 +1254,10 @@ class GeneralExample(OneMoreExample): # buff = SMALL_BUFF, path_arc = np.pi/2 ) - arrow.highlight(WHITE) + arrow.set_color(WHITE) z_to_z_squared = TexMobject("z", "\\to", "z^2") - z_to_z_squared.highlight_by_tex("z", dot.get_color()) - z_to_z_squared.highlight_by_tex("z^2", square_dot.get_color()) + z_to_z_squared.set_color_by_tex("z", dot.get_color()) + z_to_z_squared.set_color_by_tex("z^2", square_dot.get_color()) z_to_z_squared.next_to( arrow.point_from_proportion(0.5), RIGHT, MED_SMALL_BUFF @@ -1323,7 +1323,7 @@ class BoringExample(GeneralExample): arrow.next_to(self.square_label, RIGHT) triple = TexMobject("0^2 + 8^2 = 8^2") for part, color in zip(triple[::3], SIDE_COLORS): - part.highlight(color) + part.set_color(color) triple.add_background_rectangle() triple.next_to(arrow, RIGHT) @@ -1421,17 +1421,17 @@ class WriteGeneralFormula(GeneralExample): rect.to_corner(UP+LEFT, buff = 0) top_line = TexMobject("(u+vi)(u+vi)") for i in 1, 7: - top_line[i].highlight(U_COLOR) - top_line[i+2].highlight(V_COLOR) + top_line[i].set_color(U_COLOR) + top_line[i+2].set_color(V_COLOR) top_line.next_to(rect.get_top(), DOWN) second_line = TexMobject( "\\big(", "u^2 - v^2", "\\big)", "+", "\\big(", "2uv", "\\big)", "i" ) for i, j in (1, 0), (5, 1): - second_line[i][j].highlight(U_COLOR) + second_line[i][j].set_color(U_COLOR) for i, j in (1, 3), (5, 2): - second_line[i][j].highlight(V_COLOR) + second_line[i][j].set_color(V_COLOR) second_line.next_to(top_line, DOWN, MED_LARGE_BUFF) real_part = second_line[1] imag_part = second_line[5] @@ -1445,7 +1445,7 @@ class WriteGeneralFormula(GeneralExample): real_part_line = Line(zero_point, real_part_point) imag_part_line = Line(real_part_point, square_point) for line in real_part_line, imag_part_line: - line.highlight(self.square_color) + line.set_color(self.square_color) self.play(*map(FadeIn, [rect, top_line, second_line])) @@ -1471,8 +1471,8 @@ class WriteGeneralFormula(GeneralExample): def draw_triangle(self): hyp_length = TexMobject("u", "^2", "+", "v", "^2") - hyp_length.highlight_by_tex("u", U_COLOR) - hyp_length.highlight_by_tex("v", V_COLOR) + hyp_length.set_color_by_tex("u", U_COLOR) + hyp_length.set_color_by_tex("v", V_COLOR) hyp_length.add_background_rectangle() line = self.square_line hyp_length.next_to(line.get_center(), UP, SMALL_BUFF) @@ -1521,8 +1521,8 @@ class WriteGeneralFormula(GeneralExample): for u, v in pairs: a, b, c = u**2 - v**2, 2*u*v, u**2 + v**2 pair_mob = TexMobject("(", str(u), ",", str(v), ")") - pair_mob.highlight_by_tex(str(u), U_COLOR) - pair_mob.highlight_by_tex(str(v), V_COLOR) + pair_mob.set_color_by_tex(str(u), U_COLOR) + pair_mob.set_color_by_tex(str(v), V_COLOR) triple_mob = TexMobject("(%d, %d, %d)"%(a, b, c)) pair_mobs.add(pair_mob) triple_mobs.add(triple_mob) @@ -1614,8 +1614,8 @@ class VisualizeZSquared(Scene): def write_z_to_z_squared(self): z_to_z_squared = TexMobject("z", "\\to", "z^2") - z_to_z_squared.highlight_by_tex("z", YELLOW) - z_to_z_squared.highlight_by_tex("z^2", MAROON_B) + z_to_z_squared.set_color_by_tex("z", YELLOW) + z_to_z_squared.set_color_by_tex("z^2", MAROON_B) z_to_z_squared.add_background_rectangle() z_to_z_squared.to_edge(UP) z_to_z_squared.shift(2*RIGHT) @@ -1956,8 +1956,8 @@ class PointsWeMiss(VisualizeZSquared): TexMobject(complex_string_with_i(z)) for z in z_list ]) - labels.highlight(RED) - labels[2].highlight(GREEN) + labels.set_color(RED) + labels[2].set_color(GREEN) rhss = VGroup() for label, dot in zip(labels, dots): label.add_background_rectangle() @@ -2004,8 +2004,8 @@ class PointsWeMiss(VisualizeZSquared): TexMobject(complex_string_with_i(z)) for z in z_list ]) - labels[0].highlight(RED) - labels[1].highlight(GREEN) + labels[0].set_color(RED) + labels[1].set_color(GREEN) rhss = VGroup() for label, dot in zip(labels, dots): label.add_background_rectangle() @@ -2052,8 +2052,8 @@ class PointsWeMissAreMultiplesOfOnesWeHit(TeacherStudentsScene): "is \\\\ a multiple of one we", "hit" ) - words.highlight_by_tex("miss", RED) - words.highlight_by_tex("hit", GREEN) + words.set_color_by_tex("miss", RED) + words.set_color_by_tex("hit", GREEN) self.teacher_says(words) self.change_student_modes(*["pondering"]*3) self.wait(2) @@ -2079,7 +2079,7 @@ class DrawSingleRadialLine(PointsWeMiss): Dot(self.background_plane.coords_to_point(3*k, 4*k)) for k in 2, 3, 5 ]) - added_dots.highlight(GREEN) + added_dots.set_color(GREEN) self.play(GrowFromCenter(dot)) self.play(Indicate(dot)) @@ -2174,7 +2174,7 @@ class DrawRadialLines(PointsWeMiss): self.play( dot.scale_in_place, 2, - dot.highlight, RED + dot.set_color, RED ) self.play(ReplacementTransform(dot, line)) self.wait() @@ -2192,7 +2192,7 @@ class DrawRadialLines(PointsWeMiss): for dot in seed_dots: dot.generate_target() dot.target.scale_in_place(1.5) - dot.target.highlight(RED) + dot.target.set_color(RED) self.play(LaggedStart( MoveToTarget, seed_dots, @@ -2266,7 +2266,7 @@ class RationalPointsOnUnitCircle(DrawRadialLines): ) dot = Dot(point, color = YELLOW) line = Line(self.plane_center, point) - line.highlight(dot.get_color()) + line.set_color(dot.get_color()) label = TexMobject( "{"+str(x), "\\over", str(int(norm))+"}", "+", @@ -2317,7 +2317,7 @@ class RationalPointsOnUnitCircle(DrawRadialLines): ) circle_label.next_to(second_line, DOWN, MED_LARGE_BUFF) circle_label.shift_onto_screen() - circle_label.highlight_by_tex("x^2", GREEN) + circle_label.set_color_by_tex("x^2", GREEN) circle_label.add_background_rectangle() circle_arrow = Arrow( circle_label.get_bottom(), @@ -2392,7 +2392,7 @@ class RationalPointsOnUnitCircle(DrawRadialLines): ) dot = Dot(point, color = YELLOW) line = Line(self.plane_center, point) - line.highlight(dot.get_color()) + line.set_color(dot.get_color()) x, y = rational_point_group.coords label = TexMobject(str(x), "+", str(y), "i") label.next_to(dot, UP+RIGHT, buff = 0) @@ -2793,8 +2793,8 @@ class FinalProof(RationalPointsOnUnitCircle): color = WHITE ) z_to_z_squared = TexMobject("z", "\\to", "z^2") - z_to_z_squared.highlight_by_tex("z", YELLOW) - z_to_z_squared.highlight_by_tex("z^2", MAROON_B) + z_to_z_squared.set_color_by_tex("z", YELLOW) + z_to_z_squared.set_color_by_tex("z^2", MAROON_B) z_to_z_squared.add_background_rectangle() z_to_z_squared.next_to( z_to_z_squared_arrow.point_from_proportion(0.5), @@ -2974,7 +2974,7 @@ class BitOfCircleGeometry(Scene): ) group = VGroup(line1, line2, dot1, dot2) - group.highlight(color) + group.set_color(color) group.add(arc, label) if len(groups) == 0: self.play(*map(ShowCreation, [dot1, dot2])) diff --git a/old_projects/uncertainty.py b/old_projects/uncertainty.py index 672b48b7..96ae8d02 100644 --- a/old_projects/uncertainty.py +++ b/old_projects/uncertainty.py @@ -212,7 +212,7 @@ class FalconHeavy(SVGMobject): def __init__(self, **kwargs): SVGMobject.__init__(self, **kwargs) self.logo = self[-9:] - self.logo.highlight(self.logo_color) + self.logo.set_color(self.logo_color) class RadarPulseSingleton(ContinualAnimation): CONFIG = { @@ -311,7 +311,7 @@ class Flash(AnimationGroup): digest_config(self, kwargs) original_color = mobject.get_color() on_and_off = UpdateFromAlphaFunc( - mobject.copy(), lambda m, a : m.highlight( + mobject.copy(), lambda m, a : m.set_color( color if a < 0.5 else original_color ), remover = True @@ -323,7 +323,7 @@ class Flash(AnimationGroup): line.rotate(angle, about_point = ORIGIN) lines.add(line) lines.move_to(mobject) - lines.highlight(color) + lines.set_color(color) line_anims = [ ShowCreationThenDestruction( line, rate_func = squish_rate_func(smooth, 0, 0.5) @@ -403,7 +403,7 @@ class MentionUncertaintyPrinciple(TeacherStudentsScene): brace.match_width(gdw, stretch = True) brace.next_to(gdw, vect) text.next_to(brace, vect, buff = SMALL_BUFF) - group.highlight(color) + group.set_color(color) return ContinualUpdateFromFunc(group, update_group) dot_brace_anim = get_brace_text_group_update( @@ -509,7 +509,7 @@ class FourierTradeoff(Scene): frequency_axes.x_axis.get_right(), UP+LEFT, buff = MED_SMALL_BUFF, ) - frequency_label.highlight(FREQUENCY_COLOR) + frequency_label.set_color(FREQUENCY_COLOR) frequency_axes.add(frequency_label) frequency_axes.move_to(time_axes, LEFT) frequency_axes.to_edge(DOWN, buff = LARGE_BUFF) @@ -530,7 +530,7 @@ class FourierTradeoff(Scene): get_wave_packet_function(), num_graph_points = 200, ) - graph.highlight(YELLOW) + graph.set_color(YELLOW) return graph time_radius = 10 @@ -565,7 +565,7 @@ class FourierTradeoff(Scene): fourier_words = TextMobject("Fourier Transform") fourier_words.next_to(arrow, LEFT, buff = MED_LARGE_BUFF) sub_words = TextMobject("(To be explained shortly)") - sub_words.highlight(BLUE) + sub_words.set_color(BLUE) sub_words.scale(0.75) sub_words.next_to(fourier_words, DOWN) @@ -621,7 +621,7 @@ class ShowPlan(PiCreatureScene): words = VGroup() for topic, tradeoff, color in trips: word = TextMobject("Uncertainty for", topic, tradeoff) - word[1:].highlight(color) + word[1:].set_color(color) word[2].scale(0.75) word[2].next_to(word[1], DOWN, buff = 1.5*SMALL_BUFF) words.add(word) @@ -744,7 +744,7 @@ class ShowPlan(PiCreatureScene): def get_checkmark(self, word): checkmark = TexMobject("\\checkmark") - checkmark.highlight(GREEN) + checkmark.set_color(GREEN) checkmark.scale(1.25) checkmark.next_to(word[1], UP+RIGHT, buff = 0) return checkmark @@ -803,7 +803,7 @@ class TwoCarsAtRedLight(Scene): traffic_light, LEFT, buff = LARGE_BUFF, aligned_edge = DOWN ) - car2.pi_creature.highlight(GREY_BROWN) + car2.pi_creature.set_color(GREY_BROWN) car1.start_point = car1.get_corner(DOWN+RIGHT) car1.shift(FRAME_X_RADIUS*LEFT) @@ -850,7 +850,7 @@ class TwoCarsAtRedLight(Scene): x_min = 0.8, x_max = 3.8, ) - graph.highlight(YELLOW) + graph.set_color(YELLOW) #Label short duration brace = Brace(Line( @@ -905,7 +905,7 @@ class TwoCarsAtRedLight(Scene): } ) frequency_axes.next_to(time_axes, DOWN, LARGE_BUFF) - frequency_axes.highlight(LIGHT_GREY) + frequency_axes.set_color(LIGHT_GREY) frequency_label = TextMobject("Frequency") frequency_label.scale(self.text_scale_val) frequency_label.next_to(frequency_axes.x_axis.get_right(), DOWN) @@ -919,7 +919,7 @@ class TwoCarsAtRedLight(Scene): x_min = 0, x_max = 2, ) - frequency_graph.highlight(RED) + frequency_graph.set_color(RED) peak_point = frequency_axes.input_to_graph_point( 1, frequency_graph ) @@ -1142,7 +1142,7 @@ class VariousMusicalNotes(Scene): phrases = VGroup(short_signal_words, long_signal_words) for phrase in phrases: phrase.scale(0.8) - phrase.highlight_by_tex_to_color_map({ + phrase.set_color_by_tex_to_color_map({ "short" : RED, "long" : GREEN, "wide" : GREEN, @@ -1156,7 +1156,7 @@ class VariousMusicalNotes(Scene): x_max = FRAME_WIDTH, num_anchor_points = 1000 ) - long_graph.highlight(BLUE) + long_graph.set_color(BLUE) long_graph.next_to(graph, UP, MED_LARGE_BUFF) self.play( @@ -1169,7 +1169,7 @@ class VariousMusicalNotes(Scene): ) self.play( long_graph.stretch, 0.35, 0, - long_graph.highlight, GREEN, + long_graph.set_color, GREEN, run_time = 5, rate_func = wiggle ) @@ -1180,7 +1180,7 @@ class VariousMusicalNotes(Scene): ) self.play( long_graph.stretch, 0.95, 0, - long_graph.highlight, average_color(GREEN, BLUE), + long_graph.set_color, average_color(GREEN, BLUE), run_time = 4, rate_func = wiggle ) @@ -1253,7 +1253,7 @@ class FourierRecapScene(DrawFrequencyPlot): self.match_winding_to_beat_frequency() self.follow_center_of_mass() self.draw_fourier_plot() - self.highlight_spike() + self.set_color_spike() def setup_axes(self): self.remove(self.pi_creature) @@ -1418,7 +1418,7 @@ class FourierRecapScene(DrawFrequencyPlot): self.fourier_graph_drawing_update_anim = Animation(Mobject()) self.fourier_graph = fourier_graph - def highlight_spike(self): + def set_color_spike(self): spike_point = self.frequency_axes.input_to_graph_point( 5, self.fourier_graph ) @@ -1454,13 +1454,13 @@ class FourierRecapScene(DrawFrequencyPlot): x_min = 0, x_max = width, **kwargs ) - graph.highlight(YELLOW) + graph.set_color(YELLOW) return graph class RealPartOfInsert(Scene): def construct(self): words = TextMobject("(Real part of the)") - words.highlight(RED) + words.set_color(RED) self.add(words) self.play(Write(words)) self.wait(5) @@ -1715,7 +1715,7 @@ class LongAndShortSignalsInWindingMachine(FourierRecapScene): vect = point - axis_point vect *= 1.3/np.linalg.norm(vect) arrow = Arrow(vect, ORIGIN, buff = SMALL_BUFF) - arrow.highlight(YELLOW) + arrow.set_color(YELLOW) arrow.shift(point) dot.arrow = arrow return dots @@ -2023,14 +2023,14 @@ class IntroduceDopplerRadar(Scene): frequency_axes.coords_to_point(9, 0.9*f_max), ), UP, - ).highlight(BLUE) + ).set_color(BLUE) echo_fourier_brace = Brace( Line( frequency_axes.coords_to_point(14, 0.4*f_max), frequency_axes.coords_to_point(18, 0.4*f_max), ), UP, - ).highlight(YELLOW) + ).set_color(YELLOW) # braces = [original_fourier_brace, echo_fourier_brace] # words = ["original signal", "echo"] # for brace, word in zip(braces, words): @@ -2039,7 +2039,7 @@ class IntroduceDopplerRadar(Scene): # fourier_label.next_to(sum_graph.fourier_transform, UP, MED_LARGE_BUFF) fourier_label.next_to(frequency_axes.y_axis, UP, buff = SMALL_BUFF) fourier_label.shift_onto_screen() - fourier_label.highlight(RED) + fourier_label.set_color(RED) #v_lines @@ -2162,8 +2162,8 @@ class DopplerFormulaInsert(Scene): "\\left(1 + \\frac{v}{c}\\right)", "f_{\\text{pulse}}" ) - formula[0].highlight(BLUE) - formula[3].highlight(YELLOW) + formula[0].set_color(BLUE) + formula[3].set_color(YELLOW) randy = Randolph(color = BLUE_C) formula.scale(1.5) @@ -2210,7 +2210,7 @@ class MentionPRFNuance(TeacherStudentsScene): displayed_doppler_shift = TextMobject("How I'm showing the \\\\", "Doppler shift") actual_doppler_shift = TextMobject("Actual\\\\", "Doppler shift") doppler_shift_words = VGroup(displayed_doppler_shift, actual_doppler_shift) - doppler_shift_words.highlight(YELLOW) + doppler_shift_words.set_color(YELLOW) doppler_shift_words.scale(0.75) displayed_doppler_shift.next_to(brace, UP, buff = SMALL_BUFF) actual_doppler_shift.move_to(pulse_graph.peak_point) @@ -2320,7 +2320,7 @@ class TimeAndFrequencyGivePositionAndVelocity(IntroduceDopplerRadar): UP ) frequency = TextMobject("Frequency") - frequency.highlight(YELLOW) + frequency.set_color(YELLOW) frequency.next_to(brace, UP, SMALL_BUFF) time_updown_arrow = TexMobject("\\Updownarrow") @@ -2368,7 +2368,7 @@ class RadarOperatorUncertainty(Scene): dish_words = TextMobject("3b1b industrial \\\\ enterprises") dish_words.scale(0.25) dish_words.set_stroke(BLACK, 0.5) - dish_words.highlight(BLACK) + dish_words.set_color(BLACK) dish_words.move_to(dish, DOWN) dish_words.shift(SMALL_BUFF*(UP+2*LEFT)) dish.add(dish_words) @@ -2636,7 +2636,7 @@ class AmbiguityInLongEchos(IntroduceDopplerRadar, PiCreatureScene): self.curr_graph = sum_graph self.first_echo_graph = graphs[0] - self.first_echo_graph.highlight(YELLOW) + self.first_echo_graph.set_color(YELLOW) def fourier_transform_of_one_pulse(self): frequency_axes = Axes( @@ -2792,7 +2792,7 @@ class AmbiguityInLongEchos(IntroduceDopplerRadar, PiCreatureScene): lambda x : f_max * np.exp(-100*(x-8)**2), num_graph_points = 1000, ) - new_fourier_graph.highlight(PINK) + new_fourier_graph.set_color(PINK) self.play( FadeOut(curr_fourier_graph), @@ -2912,7 +2912,7 @@ class SummarizeFourierTradeoffForDoppler(Scene): time_axes.get_graph(lambda t : np.exp(-5*a*(t-x)**2)) for x in x_values ]) - graphs.highlight(WHITE) + graphs.set_color(WHITE) graphs.color_using_background_image("blue_yellow_gradient") return graphs def get_bottom_graphs(): @@ -2921,7 +2921,7 @@ class SummarizeFourierTradeoffForDoppler(Scene): frequency_axes.get_graph(lambda t : np.exp(-(5./a)*(t-v)**2)) for v in v_values ]) - graphs.highlight(RED) + graphs.set_color(RED) return graphs top_graphs = get_top_graphs() @@ -3070,7 +3070,7 @@ class IntroduceDeBroglie(Scene): axes.match_width(line) axes.shift(line.get_center() - axes.x_axis.get_center()) im_line = line.copy() - im_line.highlight(YELLOW) + im_line.set_color(YELLOW) wave_update_animation = self.get_wave_update_animation( axes, particle, line, im_line ) @@ -3095,10 +3095,10 @@ class IntroduceDeBroglie(Scene): ) if re_line is None: re_line = line.copy() - re_line.highlight(self.wave_colors[0]) + re_line.set_color(self.wave_colors[0]) if im_line is None: im_line = line.copy() - im_line.highlight(self.wave_colors[1]) + im_line.set_color(self.wave_colors[1]) lines = VGroup(im_line, re_line) def update_lines(lines): waves = self.get_wave_pair(axes, particle) @@ -3167,7 +3167,7 @@ class ShowMomentumFormula(IntroduceDeBroglie, TeacherStudentsScene): ) added_p_words = TextMobject("(Classically $m \\times v$)") added_p_words.move_to(p_words, DOWN) - VGroup(p, p_words, added_p_words, p_arrow).highlight(self.p_color) + VGroup(p, p_words, added_p_words, p_arrow).set_color(self.p_color) xi_words = TextMobject("Spatial frequency") added_xi_words = TextMobject("(cycles per unit \\emph{distance})") @@ -3179,7 +3179,7 @@ class ShowMomentumFormula(IntroduceDeBroglie, TeacherStudentsScene): ) added_xi_words.move_to(xi_words, DOWN) added_xi_words.align_to(added_p_words, DOWN) - VGroup(xi, xi_words, added_xi_words, xi_arrow).highlight(self.xi_color) + VGroup(xi, xi_words, added_xi_words, xi_arrow).set_color(self.xi_color) axes = Axes( x_min = 0, x_max = FRAME_WIDTH, @@ -3315,7 +3315,7 @@ class AskPhysicists(PiCreatureScene): def construct(self): morty, physy1, physy2, physy3 = self.pi_creatures formula = TexMobject("p", "=", "h", "\\xi") - formula.highlight_by_tex_to_color_map({ + formula.set_color_by_tex_to_color_map({ "p" : BLUE, "\\xi" : YELLOW, }) @@ -3605,7 +3605,7 @@ class HangingWeightsScene(MovingCameraScene): def introduce(self): arrow = Arrow(4*LEFT, LEFT) arrows = VGroup(arrow, arrow.copy().flip(about_point = ORIGIN)) - arrows.highlight(WHITE) + arrows.set_color(WHITE) self.wait(3) self.play(*map(GrowArrow, arrows)) @@ -3968,7 +3968,7 @@ class FourierTransformOfWaveFunction(Scene): def this_is_momentum(self): formula = TexMobject("p", "=", "h", "\\xi") - formula.highlight_by_tex_to_color_map({ + formula.set_color_by_tex_to_color_map({ "p" : BLUE, "xi" : YELLOW, }) @@ -4066,7 +4066,7 @@ class MusicalNote(AddingPureFrequencies): 0.3*(np.cos(2*TAU*x) + np.cos(3*TAU*x) + np.cos(5*TAU*x)), ), ) - graph.highlight(BLUE) + graph.set_color(BLUE) v_line = DashedLine(ORIGIN, 0.5*UP) v_line_update = UpdateFromFunc( v_line, lambda l : l.put_start_and_end_on_with_projection( @@ -4175,8 +4175,8 @@ class ProbabalisticDetection(FourierTransformOfWaveFunction): self.add(rect, brace, question) - yes = TextMobject("Yes").highlight(GREEN) - no = TextMobject("No").highlight(RED) + yes = TextMobject("Yes").set_color(GREEN) + no = TextMobject("No").set_color(RED) for word in yes, no: word.next_to(rect, DOWN) # word.add_background_rectangle() @@ -4322,14 +4322,14 @@ class BetterTranslation(TeacherStudentsScene): to_german_words.scale(0.5) to_german_arrow = Vector(DOWN, color = WHITE, buff = SMALL_BUFF) to_german_words.next_to(to_german_arrow, RIGHT, SMALL_BUFF) - to_german_words.highlight(YELLOW) + to_german_words.set_color(YELLOW) to_german_group = VGroup(to_german_arrow, to_german_words) translation_words = TextMobject("Literal translation") translation_words.scale(0.5) translation_arrow = Vector(DOWN, color = WHITE, buff = SMALL_BUFF) translation_words.next_to(translation_arrow, LEFT, SMALL_BUFF) - translation_words.highlight(YELLOW) + translation_words.set_color(YELLOW) translation_group = VGroup(translation_arrow, translation_words) english_term.next_to(self.teacher, UP+LEFT) @@ -4424,8 +4424,8 @@ class ThinkOfHeisenbergUncertainty(PiCreatureScene): position, momentum, time, frequency = map(TextMobject, [ "Position", "Momentum", "Time", "Frequency" ]) - VGroup(position, time).highlight(BLUE) - VGroup(momentum, frequency).highlight(YELLOW) + VGroup(position, time).set_color(BLUE) + VGroup(momentum, frequency).set_color(YELLOW) groups = VGroup() for m1, m2 in (position, momentum), (time, frequency): arrow = TexMobject("\\updownarrow").scale(1.5) @@ -4567,7 +4567,7 @@ class Promotion(PiCreatureScene): self.play( LaggedStart( ApplyFunction, aops_logo, - lambda mob : (lambda m : m.shift(0.2*UP).highlight(YELLOW), mob), + lambda mob : (lambda m : m.shift(0.2*UP).set_color(YELLOW), mob), rate_func = there_and_back, run_time = 1, ), @@ -4629,7 +4629,7 @@ class Promotion(PiCreatureScene): self.play(ShowCreation(url_rect)) self.play( FadeOut(url_rect), - url.get_part_by_tex("3b1b").highlight, BLUE, + url.get_part_by_tex("3b1b").set_color, BLUE, ) self.wait(15) @@ -4773,7 +4773,7 @@ class Thumbnail(Scene): is_not.scale(3) is_word.move_to(arrow) # is_word.shift(0.6*UP) - not_word.highlight(RED) + not_word.set_color(RED) not_word.set_stroke(RED, 3) not_word.rotate(10*DEGREES, about_edge = DOWN+LEFT) not_word.next_to(is_word, DOWN, 0.1*SMALL_BUFF) diff --git a/old_projects/waves.py b/old_projects/waves.py index 577ff096..7aa9a15b 100644 --- a/old_projects/waves.py +++ b/old_projects/waves.py @@ -462,7 +462,7 @@ class WantToLearnQM(TeacherStudentsScene): "\\frac{1}{\\sqrt{2}}", "|\\!\\downarrow \\rangle \\\\", "\\text{mean?}\\qquad\\quad" ) - question1.highlight_by_tex_to_color_map({ + question1.set_color_by_tex_to_color_map({ "psi" : BLUE, "uparrow" : GREEN, "downarrow" : RED, @@ -501,7 +501,7 @@ class Goal(PiCreatureScene): randy = self.pi_creature goal = TextMobject("Goal: ") - goal.highlight(YELLOW) + goal.set_color(YELLOW) goal.shift(FRAME_X_RADIUS*LEFT/2 + UP) weirdness = TextMobject("Eye-catching quantum weirdness") weirdness.next_to(goal, RIGHT) @@ -594,7 +594,7 @@ class IntroduceElectricField(PiCreatureScene): title.next_to(morty, UP+LEFT) electric = TextMobject("Electric") electric.next_to(title[-1], LEFT) - electric.highlight(BLUE) + electric.set_color(BLUE) title.save_state() title.shift(DOWN) @@ -605,8 +605,8 @@ class IntroduceElectricField(PiCreatureScene): morty.change, "raise_right_hand", ) self.play( - title[0].highlight, BLUE, - title[1].highlight, YELLOW, + title[0].set_color, BLUE, + title[1].set_color, YELLOW, ) self.wait() self.play( @@ -641,7 +641,7 @@ class IntroduceElectricField(PiCreatureScene): particle.move_to(point) vector = self.get_vector(particle.get_center()) - vector.highlight(RED) + vector.set_color(RED) vector.scale(1.5, about_point = point) vector.shift(SMALL_BUFF*vector.get_vector()) force = TextMobject("Force") @@ -757,7 +757,7 @@ class IntroduceMagneticField(IntroduceElectricField, ThreeDScene): def add_title(self): title = TextMobject("Magnetic", "field") - title[0].highlight(YELLOW) + title[0].set_color(YELLOW) title.scale(1.5) title.to_edge(UP) title.add_background_rectangle() @@ -780,14 +780,14 @@ class IntroduceMagneticField(IntroduceElectricField, ThreeDScene): particle.move_to(point) velocity = Vector(2*RIGHT).shift(particle.get_right()) - velocity.highlight(WHITE) + velocity.set_color(WHITE) velocity_word = TextMobject("Velocity") - velocity_word.highlight(velocity.get_color()) + velocity_word.set_color(velocity.get_color()) velocity_word.add_background_rectangle() velocity_word.next_to(velocity, UP, 0, LEFT) M_vect = self.get_vector(point) - M_vect.highlight(YELLOW) + M_vect.set_color(YELLOW) M_vect.shift(SMALL_BUFF*M_vect.get_vector()) particle.save_state() @@ -815,11 +815,11 @@ class IntroduceMagneticField(IntroduceElectricField, ThreeDScene): F_word = TextMobject("Force") F_word.rotate(np.pi/2, RIGHT) F_word.next_to(F_vect, OUT) - F_word.highlight(F_vect.get_color()) + F_word.set_color(F_vect.get_color()) F_eq = TexMobject( "=","q", "\\textbf{v}", "\\times", "\\textbf{B}" ) - F_eq.highlight_by_tex_to_color_map({ + F_eq.set_color_by_tex_to_color_map({ "q" : RED, "B" : YELLOW, }) @@ -883,7 +883,7 @@ class CurlRelationBetweenFields(ThreeDScene): Vector(0.5*rotate_vector(vect, np.pi/2)).shift(vect) for vect in compass_directions(8) ]) - E_vects.highlight(E_COLOR) + E_vects.set_color(E_COLOR) point = 1.2*RIGHT + 2*UP + OUT E_vects.shift(point) @@ -945,7 +945,7 @@ class CurlRelationBetweenFields(ThreeDScene): Vector(1.5*rotate_vector(vect, np.pi/2)).shift(vect) for vect in compass_directions(8, LEFT)[1:] ]) - E_vects.highlight(E_COLOR) + E_vects.set_color(E_COLOR) point = self.M_circle_center + RIGHT E_vects.shift(point) @@ -978,7 +978,7 @@ class WriteCurlEquations(Scene): eqs.scale_to_fit_height(FRAME_HEIGHT - 1) eqs.to_edge(LEFT) for eq in eqs: - eq.highlight_by_tex_to_color_map({ + eq.set_color_by_tex_to_color_map({ "E" : E_COLOR, "B" : M_COLOR, }) @@ -1011,7 +1011,7 @@ class IntroduceEMWave(ThreeDScene): "Electro", "magnetic", " radiation", arg_separator = "" ) - words.highlight_by_tex_to_color_map({ + words.set_color_by_tex_to_color_map({ "Electro" : E_COLOR, "magnetic" : M_COLOR, }) @@ -1033,7 +1033,7 @@ class ListRelevantWaveIdeas(TeacherStudentsScene): def construct(self): title = TextMobject("Wave","topics") title.to_corner(UP + LEFT, LARGE_BUFF) - title.highlight(BLUE) + title.set_color(BLUE) h_line = Line(title.get_left(), title.get_right()) h_line.next_to(title, DOWN, SMALL_BUFF) @@ -1047,7 +1047,7 @@ class ListRelevantWaveIdeas(TeacherStudentsScene): topics.next_to(h_line, DOWN, aligned_edge = LEFT) quantum = TextMobject("Quantum") - quantum.highlight(GREEN) + quantum.set_color(GREEN) quantum.move_to(title[0], LEFT) wave_point = self.teacher.get_corner(UP+LEFT) + 2*UP @@ -1204,7 +1204,7 @@ class ShowVectorEquation(Scene): E, equals = E_equals = TexMobject( "\\vec{\\textbf{E}}", "=" ) - E.highlight(E_COLOR) + E.set_color(E_COLOR) E_equals.next_to(brackets, LEFT) E_equals.add_background_rectangle() brackets.add_background_rectangle() @@ -1217,7 +1217,7 @@ class ShowVectorEquation(Scene): x_without_phi = TexMobject("\\cos(", "2\\pi", "f_x", "t", ")") x_without_phi.move_to(x) for mob in x, x_without_phi: - mob.highlight_by_tex_to_color_map({ + mob.set_color_by_tex_to_color_map({ "f_x" : self.f_color, "phi_x" : self.phi_color, }) @@ -1279,7 +1279,7 @@ class ShowVectorEquation(Scene): fx_equals_fourth = TexMobject("f_x", "= 0.25") fx_group = VGroup(fx_equals_1, fx_equals_fourth) for fx in fx_group: - fx[0].highlight(self.f_color) + fx[0].set_color(self.f_color) fx.move_to(axes, UP+RIGHT) high_f_graph, low_f_graph = graphs = VGroup(*[ FunctionGraph( @@ -1355,7 +1355,7 @@ class ShowVectorEquation(Scene): def add_phi(self): corner_cos = self.corner_cos corner_phi = TexMobject("+", "\\phi_x") - corner_phi.highlight_by_tex("phi", self.phi_color) + corner_phi.set_color_by_tex("phi", self.phi_color) corner_phi.scale(0.8) corner_phi.next_to(corner_cos[-2], RIGHT, SMALL_BUFF) @@ -1364,10 +1364,10 @@ class ShowVectorEquation(Scene): words = TextMobject("``Phase shift''") words.next_to(ORIGIN, UP+LEFT) - words.highlight(self.phi_color) + words.set_color(self.phi_color) words.add_background_rectangle() arrow = Arrow(words.get_top(), x[-2]) - arrow.highlight(WHITE) + arrow.set_color(WHITE) self.play( ReplacementTransform( @@ -1397,7 +1397,7 @@ class ShowVectorEquation(Scene): graph_y_axis = self.graph_axes.y_axis A = TexMobject("A_x") - A.highlight(self.A_color) + A.set_color(self.A_color) A.move_to(x.get_left()) corner_A = A.copy() corner_A.scale(0.8) @@ -1410,7 +1410,7 @@ class ShowVectorEquation(Scene): ), LEFT, buff = SMALL_BUFF) for brace in h_brace, v_brace: brace.A = brace.get_tex("A_x") - brace.A.highlight(self.A_color) + brace.A.set_color(self.A_color) v_brace.A.scale(0.5, about_point = v_brace.get_center()) all_As = VGroup(A, corner_A, h_brace.A, v_brace.A) @@ -1457,7 +1457,7 @@ class ShowVectorEquation(Scene): right_ket = TexMobject("|\\rightarrow\\rangle") up_ket = TexMobject("|\\uparrow\\rangle") kets = VGroup(right_ket, up_ket) - kets.highlight(YELLOW) + kets.set_color(YELLOW) for ket in kets: ket.add_background_rectangle() plus = TextMobject("+") @@ -1479,7 +1479,7 @@ class ShowVectorEquation(Scene): for ket in kets ]) ket_rects = VGroup(*map(SurroundingRectangle, kets)) - ket_rects.highlight(WHITE) + ket_rects.set_color(WHITE) unit_vectors = VGroup(*[Vector(2*vect) for vect in RIGHT, UP]) unit_vectors.set_fill(YELLOW) @@ -1514,7 +1514,7 @@ class ShowVectorEquation(Scene): y.target = TexMobject( "A_y", "\\cos(", "2\\pi", "f_y", "t", "+", "\\phi_y", ")" ) - y.target.highlight_by_tex_to_color_map({ + y.target.set_color_by_tex_to_color_map({ "A" : self.A_color, "f" : self.f_color, "phi" : self.phi_color, @@ -1672,7 +1672,7 @@ class ShowTipToTailSum(ShowVectorEquation): for s in "right", "up" ]) for ket in kets: - ket.highlight_by_tex_to_color_map({ + ket.set_color_by_tex_to_color_map({ "f" : self.f_color, "rangle" : YELLOW, }) @@ -1739,7 +1739,7 @@ class ShowTipToTailSum(ShowVectorEquation): "$|\\!\\uparrow\\rangle$", ) superposition_words.scale(0.8) - superposition_words.highlight_by_tex("rangle", YELLOW) + superposition_words.set_color_by_tex("rangle", YELLOW) superposition_words.add_background_rectangle() superposition_words.to_corner(UP+LEFT) ket_sum = self.ket_sum @@ -1751,7 +1751,7 @@ class ShowTipToTailSum(ShowVectorEquation): weighted_sum_word = TextMobject("Weighted", "sum") for word in sum_word, weighted_sum_word: word.scale(0.8) - word.highlight(GREEN) + word.set_color(GREEN) word.add_background_rectangle() word.move_to(superposition_words.get_part_by_tex("Super")) @@ -1781,7 +1781,7 @@ class ShowTipToTailSum(ShowVectorEquation): for A in [h_A, v_A] ]) A_mobs.scale(0.8) - A_mobs.highlight(GREEN) + A_mobs.set_color(GREEN) h_A_mob.move_to(h_ket, LEFT) VGroup(h_ket.target, plus.target).next_to( h_A_mob, RIGHT, SMALL_BUFF @@ -1817,7 +1817,7 @@ class ShowTipToTailSum(ShowVectorEquation): h_ket, plus, v_ket = self.ket_sum plus_phi = TexMobject("+", "\\pi/2") - plus_phi.highlight_by_tex("pi", self.phi_color) + plus_phi.set_color_by_tex("pi", self.phi_color) plus_phi.scale(0.8) plus_phi.next_to(v_ket.get_part_by_tex("t"), RIGHT, SMALL_BUFF) v_ket.generate_target() @@ -1831,7 +1831,7 @@ class ShowTipToTailSum(ShowVectorEquation): ellipse = Circle() ellipse.stretch_to_fit_height(2) ellipse.stretch_to_fit_width(8) - ellipse.highlight(self.phi_color) + ellipse.set_color(self.phi_color) h_A_mob, v_A_mob = self.A_mobs new_h_A_mob = v_A_mob.copy() @@ -1900,13 +1900,13 @@ class FromBracketFootnote(Scene): "From, ``Bra", "ket", "''", arg_separator = "" ) - words.highlight_by_tex("ket", YELLOW) + words.set_color_by_tex("ket", YELLOW) words.scale_to_fit_width(FRAME_WIDTH - 1) self.add(words) class Ay(Scene): def construct(self): - sym = TexMobject("A_y").highlight(GREEN) + sym = TexMobject("A_y").set_color(GREEN) sym.scale(5) self.add(sym) @@ -1949,8 +1949,8 @@ class AlternateBasis(ShowTipToTailSum): for s1, s2 in ("right", "up"), ("ne", "nw") ] for superposition in superpositions: - superposition.highlight_by_tex("rangle", YELLOW) - superposition.highlight_by_tex("E", E_COLOR) + superposition.set_color_by_tex("rangle", YELLOW) + superposition.set_color_by_tex("E", E_COLOR) superposition.add_background_rectangle(opacity = 1) superposition.to_edge(UP) self.add(self.hv_superposition) @@ -2057,7 +2057,7 @@ class ShowPolarizingFilter(DirectionOfPolarizationScene): def mention_energy_absorption(self): words = TextMobject("Absorbs horizontal \\\\ energy") - words.highlight(RED) + words.set_color(RED) words.next_to(ORIGIN, UP+RIGHT, MED_LARGE_BUFF) words.rotate(np.pi/2, RIGHT) words.rotate(np.pi/2, OUT) @@ -2154,9 +2154,9 @@ class ShowPolarizingFilter(DirectionOfPolarizationScene): A_y.move_to(superposition[8]) superposition.submobjects[0] = A_x superposition.submobjects[8] = A_y - VGroup(A_x, A_y).highlight(GREEN) - superposition.highlight_by_tex("f", RED) - superposition.highlight_by_tex("rangle", YELLOW) + VGroup(A_x, A_y).set_color(GREEN) + superposition.set_color_by_tex("f", RED) + superposition.set_color_by_tex("rangle", YELLOW) plus = superposition.get_part_by_tex("+") plus.add_to_back(BackgroundRectangle(plus)) @@ -2180,7 +2180,7 @@ class ShowPolarizingFilter(DirectionOfPolarizationScene): new_decimal.rotate(self.camera.get_theta(), OUT) new_decimal.scale_to_fit_depth(decimal.get_depth()) new_decimal.move_to(decimal, UP) - new_decimal.highlight(decimal.get_color()) + new_decimal.set_color(decimal.get_color()) decimal.align_data(new_decimal) families = [ mob.family_members_with_points() @@ -2235,7 +2235,7 @@ class EnergyOfWavesWavePortion(DirectWaveOutOfScreen): brace.rotate(np.pi/4, OUT) brace.A = brace.get_tex("A", buff = MED_SMALL_BUFF) brace.A.scale_in_place(2) - brace.A.highlight(GREEN) + brace.A.set_color(GREEN) brace_group = VGroup(brace, brace.A) self.position_brace_group(brace_group) self.play(Write(brace_group, run_time = 1)) @@ -2258,14 +2258,14 @@ class EnergyOfWavesWavePortion(DirectWaveOutOfScreen): for brace, c in (h_brace, "x"), (v_brace, "y"): brace.A = brace.get_tex("A_%s"%c, buff = MED_LARGE_BUFF) brace.A.scale_in_place(2) - brace.A.highlight(GREEN) + brace.A.set_color(GREEN) brace_group = VGroup(h_brace, h_brace.A, v_brace, v_brace.A) self.position_brace_group(brace_group) rhs = TexMobject("= \\sqrt{A_x^2 + A_y^2}") rhs.scale(2) for i in 3, 5, 7, 9: - rhs[i].highlight(GREEN) + rhs[i].set_color(GREEN) rhs.rotate(np.pi/2, RIGHT) rhs.rotate(np.pi/2, OUT) @@ -2357,7 +2357,7 @@ class EnergyOfWavesTeacherPortion(TeacherStudentsScene): "=", "\\epsilon_0", "A", "^2" ) - energy.highlight_by_tex("A", GREEN) + energy.set_color_by_tex("A", GREEN) energy.to_corner(UP+LEFT) component_energy = TexMobject( @@ -2365,8 +2365,8 @@ class EnergyOfWavesTeacherPortion(TeacherStudentsScene): "+", "\\epsilon_0", "A_y", "^2", ) for i in 2, 6: - component_energy[i][0].highlight(GREEN) - component_energy[i+1].highlight(GREEN) + component_energy[i][0].set_color(GREEN) + component_energy[i+1].set_color(GREEN) component_energy.next_to(energy[1], DOWN, MED_LARGE_BUFF, LEFT) self.play( @@ -2477,11 +2477,11 @@ class DescribePhoton(ThreeDScene): "\\beta", "|\\!\\uparrow \\rangle", ) equation.to_edge(UP) - equation.highlight_by_tex("psi", E_COLOR) - equation.highlight_by_tex("alpha", self.x_color) - equation.highlight_by_tex("beta", self.y_color) + equation.set_color_by_tex("psi", E_COLOR) + equation.set_color_by_tex("alpha", self.x_color) + equation.set_color_by_tex("beta", self.y_color) rect = SurroundingRectangle(equation.get_part_by_tex("psi")) - rect.highlight(E_COLOR) + rect.set_color(E_COLOR) words = TextMobject("Polarization\\\\", "state") words.next_to(rect, DOWN) for part in words: @@ -2588,13 +2588,13 @@ class DescribePhoton(ThreeDScene): A_word.add_background_rectangle() A_word.next_to(A_rect, DOWN, aligned_edge = LEFT) A_group = VGroup(A_rect, A_word) - A_group.highlight(YELLOW) + A_group.set_color(YELLOW) phase_rect = SurroundingRectangle(VGroup(*rhs[4:]), buff = 0.5*SMALL_BUFF) phase_word = TextMobject("Phase") phase_word.add_background_rectangle() phase_word.next_to(phase_rect, UP) phase_group = VGroup(phase_word, phase_rect) - phase_group.highlight(MAROON_B) + phase_group.set_color(MAROON_B) rhs.add_background_rectangle() group = VGroup(rhs, A_group, phase_group) @@ -2636,8 +2636,8 @@ class DescribePhoton(ThreeDScene): "\\gamma", "|\\! \\nearrow \\rangle", "+", "\\delta", "|\\! \\nwarrow \\rangle", ) - superposition.target.highlight_by_tex("gamma", TEAL_D) - superposition.target.highlight_by_tex("delta", MAROON) + superposition.target.set_color_by_tex("gamma", TEAL_D) + superposition.target.set_color_by_tex("delta", MAROON) for part in superposition.target.get_parts_by_tex("rangle"): part[1].rotate_in_place(-np.pi/12) superposition.target.rotate(np.pi/2, RIGHT) @@ -2725,7 +2725,7 @@ class DescribePhoton(ThreeDScene): for brace, tex, color in zip(braces, tex, colors): brace.label = brace.get_tex(tex, buff = SMALL_BUFF) brace.label.add_background_rectangle() - brace.label.highlight(color) + brace.label.set_color(color) group.add(brace.label) group.rotate(np.pi/2, RIGHT) @@ -2761,10 +2761,10 @@ class DescribePhoton(ThreeDScene): ) energy.scale(0.8) one = energy.get_part_by_tex("1", substring = False) - one.highlight(BLUE) + one.set_color(BLUE) halves = energy.get_parts_by_tex("1/2") - halves[0].highlight(self.x_color) - halves[1].highlight(self.y_color) + halves[0].set_color(self.x_color) + halves[1].set_color(self.y_color) indices = [0, 3, 6, len(energy)] parts = VGroup(*[ VGroup(*energy[i1:i2]) @@ -2863,7 +2863,7 @@ class DescribePhoton(ThreeDScene): component.rotate(np.pi/2, DOWN) cross = Cross(component) VGroup(component, cross).rotate(np.pi/2, UP) - cross.highlight("#ff0000") + cross.set_color("#ff0000") self.play(ShowCreation(cross)) bubble.remove(bubble.content) self.play( @@ -2958,10 +2958,10 @@ class ShootPhotonThroughFilter(DirectionOfPolarizationScene): "(\\sqrt{1/2})", "|\\!\\uparrow \\rangle", ) superposition_tex.scale(0.9) - superposition_tex[0].highlight(E_COLOR) + superposition_tex[0].set_color(E_COLOR) halves = superposition_tex.get_parts_by_tex("1/2") for half, color in zip(halves, [RED, GREEN]): - half.highlight(color) + half.set_color(color) h_rect = SurroundingRectangle(VGroup(*superposition_tex[2:4])) v_rect = SurroundingRectangle(VGroup(*superposition_tex[5:7])) @@ -2983,7 +2983,7 @@ class ShootPhotonThroughFilter(DirectionOfPolarizationScene): ) question = TextMobject("What's going to happen?") question.add_background_rectangle() - question.highlight(YELLOW) + question.set_color(YELLOW) question.rotate(np.pi/2, RIGHT) question.next_to(self.superposition_tex, IN) @@ -3013,7 +3013,7 @@ class ShootPhotonThroughFilter(DirectionOfPolarizationScene): def expect_half_energy_to_be_absorbed(self): words = TextMobject("Absorbs horizontal \\\\ energy") - words.highlight(RED) + words.set_color(RED) words.next_to(ORIGIN, UP+RIGHT, MED_LARGE_BUFF) words.rotate(np.pi/2, RIGHT) words.rotate(np.pi/2, OUT) @@ -3083,7 +3083,7 @@ class ShootPhotonThroughFilter(DirectionOfPolarizationScene): self.pol_filter, self.get_blocked_photon() ) prob = TexMobject("P(", "\\text{pass}", ")", "=", "1/2") - prob.highlight_by_tex("pass", GREEN) + prob.set_color_by_tex("pass", GREEN) prob.rotate(np.pi/2, RIGHT) prob.next_to(self.superposition_tex, IN, MED_SMALL_BUFF, RIGHT) @@ -3117,8 +3117,8 @@ class ShootPhotonThroughFilter(DirectionOfPolarizationScene): "``Collapses'' \\\\ from", "$|\\!\\nearrow\\rangle$", "to", "$|\\!\\uparrow\\rangle$" ) - words.highlight_by_tex("nearrow", E_COLOR) - words.highlight_by_tex("uparrow", GREEN) + words.set_color_by_tex("nearrow", E_COLOR) + words.set_color_by_tex("uparrow", GREEN) words.next_to(ORIGIN, RIGHT, MED_LARGE_BUFF) words.shift(2*UP) words.rotate(np.pi/2, RIGHT) @@ -3229,7 +3229,7 @@ class ThreeFilters(ShootPhotonThroughFilter): group = VGroup(arrow, label) group.rotate(np.pi/2, RIGHT) group.next_to(self.pol_filters[1], OUT, buff = 0) - group.highlight(BLUE) + group.set_color(BLUE) l1, l2, l3 = self.lines_group[:3] pf1, pf2, pf3 = self.pol_filters @@ -3273,7 +3273,7 @@ class ThreeFilters(ShootPhotonThroughFilter): "Changed to", "$|\\!\\nearrow\\rangle$" ) - label.highlight_by_tex("rangle", BLUE) + label.set_color_by_tex("rangle", BLUE) group = VGroup(brace, label) group.rotate(np.pi/2, RIGHT) group.shift(2*RIGHT + 0.5*IN) @@ -3374,7 +3374,7 @@ class ThreeFilters(ShootPhotonThroughFilter): group = VGroup(arrow, labels) group.rotate(np.pi/2, RIGHT) group.shift(2*LEFT + IN) - group.highlight(GREEN) + group.set_color(GREEN) self.remove(l2, l3) self.play( @@ -3526,7 +3526,7 @@ class PhotonAtSlightAngle(ThreeFilters): ) h_label = TexMobject("\\sin(22.5^\\circ)") h_label.scale(0.7) - h_label.highlight(RED) + h_label.set_color(RED) h_label.next_to(h_arrow.get_center(), DOWN, aligned_edge = LEFT) v_arrow = Vector( @@ -3536,7 +3536,7 @@ class PhotonAtSlightAngle(ThreeFilters): v_arrow.shift(h_arrow.get_vector()) v_label = TexMobject("\\cos(22.5^\\circ)") v_label.scale(0.7) - v_label.highlight(GREEN) + v_label.set_color(GREEN) v_label.next_to(v_arrow, RIGHT, SMALL_BUFF) state = TexMobject( @@ -3544,7 +3544,7 @@ class PhotonAtSlightAngle(ThreeFilters): "=", "\\sin(22.5^\\circ)", "|\\!\\rightarrow\\rangle", "+", "\\cos(22.5^\\circ)", "|\\!\\uparrow\\rangle", ) - state.highlight_by_tex_to_color_map({ + state.set_color_by_tex_to_color_map({ "psi" : BLUE, "rightarrow" : RED, "uparrow" : GREEN, @@ -3642,14 +3642,14 @@ class PhotonAtSlightAngle(ThreeFilters): "0.38", "^2", "=& 15\\%", "\\text{ of energy}\\\\", "&\\text{absorbed}", "", "", ) - h_content.highlight_by_tex("rightarrow", RED) - alt_h_content.highlight_by_tex("rightarrow", RED) + h_content.set_color_by_tex("rightarrow", RED) + alt_h_content.set_color_by_tex("rightarrow", RED) alt_h_content.scale(0.8) v_content = TexMobject( "0.92", "^2", "= 0.85", "\\text{ energy}\\\\", "\\text{in the }", "\\uparrow", "\\text{ direction}" ) - v_content.highlight_by_tex("uparrow", GREEN) + v_content.set_color_by_tex("uparrow", GREEN) bubble.add_content(h_content) bubble.resize_to_content() @@ -3660,7 +3660,7 @@ class PhotonAtSlightAngle(ThreeFilters): classically = TextMobject("Classically...") classically.next_to(bubble[-1], UP) - classically.highlight(YELLOW) + classically.set_color(YELLOW) alt_h_content.next_to(classically, DOWN) group = VGroup(randy, bubble_group, classically, alt_h_content) @@ -3749,7 +3749,7 @@ class PhotonAtSlightAngle(ThreeFilters): def rewrite_15_percent_meaning(self): self.classically.rotate(np.pi/2, LEFT) cross = Cross(self.classically) - cross.highlight("#ff0000") + cross.set_color("#ff0000") VGroup(self.classically, cross).rotate(np.pi/2, RIGHT) new_conception = TextMobject( @@ -3776,7 +3776,7 @@ class PhotonAtSlightAngle(ThreeFilters): self.play( finish_photon, ApplyMethod( - self.pol_filter.highlight, RED, + self.pol_filter.set_color, RED, rate_func = squish_rate_func(there_and_back, 0, 0.3), run_time = finish_photon.run_time ) @@ -3813,7 +3813,7 @@ class PhotonAtSlightAngle(ThreeFilters): label = TexMobject("15\\% \\text{ absorbed}") label.next_to(arrow, DOWN) group = VGroup(arrow, label) - group.highlight(RED) + group.set_color(RED) group.rotate(np.pi/2, RIGHT) group.shift(3*RIGHT + 1.5*IN) @@ -3870,7 +3870,7 @@ class CompareWaveEquations(TeacherStudentsScene): "=", "\\alpha", "|\\!\\rightarrow\\rangle", "+", "\\beta", "|\\!\\uparrow\\rangle", ) - equation.highlight_by_tex_to_color_map({ + equation.set_color_by_tex_to_color_map({ "psi" : BLUE, "rightarrow" : RED, "uparrow" : GREEN, @@ -3879,9 +3879,9 @@ class CompareWaveEquations(TeacherStudentsScene): equation.to_edge(UP) psi_rect = SurroundingRectangle(equation.get_part_by_tex("psi")) - psi_rect.highlight(WHITE) + psi_rect.set_color(WHITE) state_words = TextMobject("Polarization \\\\ state") - state_words.highlight(BLUE) + state_words.set_color(BLUE) state_words.scale(0.8) state_words.next_to(psi_rect, DOWN) @@ -3937,9 +3937,9 @@ class CompareWaveEquations(TeacherStudentsScene): for x, color in (-0.5, RED), (0.5, GREEN) ] new_alpha.target.next_to(alpha_dot, UP+LEFT, 0.5*SMALL_BUFF) - new_alpha.target.highlight(RED) + new_alpha.target.set_color(RED) new_beta.target.next_to(beta_dot, UP+RIGHT, 0.5*SMALL_BUFF) - new_beta.target.highlight(GREEN) + new_beta.target.set_color(GREEN) rhs = TexMobject( "=", "A_y", "e", "^{i(", @@ -3948,7 +3948,7 @@ class CompareWaveEquations(TeacherStudentsScene): rhs.scale(0.7) rhs.next_to(new_beta.target, RIGHT, SMALL_BUFF) rhs.shift(0.5*SMALL_BUFF*UP) - rhs.highlight_by_tex_to_color_map({ + rhs.set_color_by_tex_to_color_map({ "A_y" : GREEN, "phi" : MAROON_B, }) @@ -4003,7 +4003,7 @@ class CompareWaveEquations(TeacherStudentsScene): "\\text{ direction}", ) for words in c_words, qm_words: - words.highlight_by_tex_to_color_map({ + words.set_color_by_tex_to_color_map({ "Classically" : YELLOW, "Quantum" : BLUE, "{all}" : BLUE, @@ -4078,7 +4078,7 @@ class CircularPhotons(ShootPhotonThroughFilter): "=", "\\frac{1}{\\sqrt{2}}", "|\\!\\rightarrow\\rangle", "+", "\\frac{i}{\\sqrt{2}}", "|\\!\\uparrow\\rangle", ) - equation.highlight_by_tex_to_color_map({ + equation.set_color_by_tex_to_color_map({ "circlearrowright" : BLUE, "rightarrow" : RED, "uparrow" : GREEN, @@ -4088,7 +4088,7 @@ class CircularPhotons(ShootPhotonThroughFilter): rect = SurroundingRectangle(equation.get_part_by_tex("frac{i}")) words = TextMobject("Phase shift") words.next_to(rect, DOWN) - words.highlight(YELLOW) + words.set_color(YELLOW) group = VGroup(equation, rect, words) group.rotate(np.pi/2, RIGHT) @@ -4126,7 +4126,7 @@ class CircularPhotons(ShootPhotonThroughFilter): "=", "\\frac{i}{\\sqrt{2}}", "|\\!\\circlearrowleft \\rangle", "+", "\\frac{-i}{\\sqrt{2}}", "|\\!\\circlearrowright \\rangle", ) - equation.highlight_by_tex_to_color_map({ + equation.set_color_by_tex_to_color_map({ "circlearrowright" : BLUE, "frac{-i}" : BLUE, "circlearrowleft" : YELLOW, @@ -4140,7 +4140,7 @@ class CircularPhotons(ShootPhotonThroughFilter): "P(", "\\text{passing}", ")", "=", "\\left(", "\\frac{-i}{\\sqrt{2}}", "\\right)^2" ) - prob.highlight_by_tex("sqrt{2}", BLUE) + prob.set_color_by_tex("sqrt{2}", BLUE) prob.next_to(equation, DOWN) group = VGroup(equation, prob) @@ -4200,8 +4200,8 @@ class ClockwisePhotonInsert(Scene): eq = TexMobject( "\\left| \\frac{-i}{\\sqrt{2}} \\right|^2" ) - eq.highlight(BLUE) - VGroup(*it.chain(eq[:4], eq[-5:])).highlight(WHITE) + eq.set_color(BLUE) + VGroup(*it.chain(eq[:4], eq[-5:])).set_color(WHITE) eq.scale_to_fit_height(FRAME_HEIGHT - 1) eq.to_edge(LEFT) self.add(eq) diff --git a/old_projects/wcat.py b/old_projects/wcat.py index a8d31b24..d3f608b7 100644 --- a/old_projects/wcat.py +++ b/old_projects/wcat.py @@ -81,7 +81,7 @@ class ClosedLoopScene(Scene): else: vertices = self.rect_vertices dots = VGroup(*[Dot(v) for v in vertices]) - dots.highlight(self.dot_color) + dots.set_color(self.dot_color) return dots def get_rect_alphas(self, square = False): @@ -125,10 +125,10 @@ class ClosedLoopScene(Scene): l.end_dot.get_center() ) ) - line.highlight(d1.get_color()) + line.set_color(d1.get_color()) self.connecting_lines.add(line) if cyclic: - self.connecting_lines.highlight(self.connecting_lines_color) + self.connecting_lines.set_color(self.connecting_lines_color) self.connecting_lines.set_stroke(width = 6) self.add(self.connecting_lines, self.dots) @@ -199,10 +199,10 @@ class ClosedLoopScene(Scene): **kwargs ) - def highlight_dots_by_pair(self): + def set_color_dots_by_pair(self): n_pairs = len(list(self.dots))/2 for d1, d2, c in zip(self.dots[:n_pairs], self.dots[n_pairs:], self.pair_colors): - VGroup(d1, d2).highlight(c) + VGroup(d1, d2).set_color(c) def find_square(self): alpha_quads = list(it.combinations( @@ -531,7 +531,7 @@ class DefineInscribedSquareProblem(ClosedLoopScene): morty.to_edge(RIGHT) new_title = TextMobject("Inscribed", "rectangle", "problem") - new_title.highlight_by_tex("rectangle", YELLOW) + new_title.set_color_by_tex("rectangle", YELLOW) new_title.to_edge(UP) rect_dots = self.get_rect_vertex_dots() rect_alphas = self.get_dot_alphas(rect_dots) @@ -561,7 +561,7 @@ class DefineInscribedSquareProblem(ClosedLoopScene): for pair, line in zip(dot_pairs, diag_lines): self.play( FadeIn(line), - pair.highlight, line.get_color(), + pair.set_color, line.get_color(), ) class RectangleProperties(Scene): @@ -604,7 +604,7 @@ class RectangleProperties(Scene): ] for color, mob_list in zip(colors, mob_lists): self.play(*[ - ApplyMethod(mob.highlight, color) + ApplyMethod(mob.set_color, color) for mob in mob_list ]) self.wait() @@ -631,7 +631,7 @@ class PairOfPairBecomeRectangle(Scene): label = TexMobject(char) y_coord = dot.get_center()[1] label.next_to(dot, np.sign(dot.get_center()[1])*UP) - label.highlight(dot.get_color()) + label.set_color(dot.get_color()) labels.add(label) lines = [ Line( @@ -655,7 +655,7 @@ class PairOfPairBecomeRectangle(Scene): ])) words.arrange_submobjects(DOWN) words.to_edge(RIGHT) - words[-1].highlight(BLUE) + words[-1].set_color(BLUE) self.play( ShowCreation(dots), @@ -691,7 +691,7 @@ class PairOfPairBecomeRectangle(Scene): dots[i].get_center() for i in 0, 2, 1, 3 ]) - rectangle.highlight(BLUE) + rectangle.set_color(BLUE) self.play( ShowCreation(rectangle), Animation(dots) @@ -702,7 +702,7 @@ class PairOfPairBecomeRectangle(Scene): class SearchForRectangleOnLoop(ClosedLoopScene): def construct(self): self.add_dots_at_alphas(*np.linspace(0.2, 0.8, 4)) - self.highlight_dots_by_pair() + self.set_color_dots_by_pair() rect_alphas = self.get_rect_alphas() self.play(ShowCreation(self.dots)) @@ -739,7 +739,7 @@ class SearchForRectangleOnLoop(ClosedLoopScene): class DeclareFunction(ClosedLoopScene): def construct(self): self.add_dots_at_alphas(0.2, 0.8) - self.highlight_dots_by_pair() + self.set_color_dots_by_pair() self.add_connecting_lines() VGroup( self.loop, self.dots, self.connecting_lines @@ -760,7 +760,7 @@ class DeclareFunction(ClosedLoopScene): ab_brace.add(ab_brace.get_text("Pair of points on the loop")) xyz_brace.add(xyz_brace.get_text("Point in 3d space")) ab_brace.gradient_highlight(MAROON_B, PURPLE_B) - xyz_brace.highlight(BLUE) + xyz_brace.set_color(BLUE) self.add(tex) self.play(Write(ab_brace)) @@ -775,7 +775,7 @@ class DefinePairTo3dFunction(Scene): class LabelMidpoint(Scene): def construct(self): words = TextMobject("Midpoint $M$") - words.highlight(RED) + words.set_color(RED) words.scale(2) self.play(Write(words, run_time = 1)) self.wait() @@ -783,7 +783,7 @@ class LabelMidpoint(Scene): class LabelDistance(Scene): def construct(self): words = TextMobject("Distance $d$") - words.highlight(MAROON_B) + words.set_color(MAROON_B) words.scale(2) self.play(Write(words, run_time = 1)) self.wait() @@ -803,7 +803,7 @@ class PointPairApprocahingEachother3D(Scene): class InputPairToFunction(Scene): def construct(self): tex = TexMobject("f(X, X)", "=X") - tex.highlight_by_tex("=X", BLUE) + tex.set_color_by_tex("=X", BLUE) tex.scale(2) self.play(Write(tex[0])) self.wait(2) @@ -826,7 +826,7 @@ class DistinctPairCollisionOnSurface(Scene): class PairsOfPointsOnLoop(ClosedLoopScene): def construct(self): self.add_dots_at_alphas(0.2, 0.5) - self.dots.highlight(MAROON_B) + self.dots.set_color(MAROON_B) self.add_connecting_lines() self.let_dots_wonder(run_time = 10) @@ -839,7 +839,7 @@ class PairOfRealsToPlane(Scene): dot.move_to(number*RIGHT) pair_label = TexMobject("(", str(r1), ",", str(r2), ")") for number, color in zip(numbers, colors): - pair_label.highlight_by_tex(str(number), color) + pair_label.set_color_by_tex(str(number), color) pair_label.next_to(dots, UP, buff = 2) arrows = VGroup(*[ Arrow(pair_label[i], dot, color = dot.get_color()) @@ -879,7 +879,7 @@ class SeekSurfaceForPairs(ClosedLoopScene): def construct(self): self.loop.to_edge(LEFT) self.add_dots_at_alphas(0.2, 0.3) - self.highlight_dots_by_pair() + self.set_color_dots_by_pair() self.add_connecting_lines() arrow = Arrow(LEFT, RIGHT).next_to(self.loop) @@ -924,16 +924,16 @@ class DefineOrderedPair(ClosedLoopScene): subtitle.next_to(title, DOWN) colors = GREEN, RED for char, color in zip("ab", colors): - subtitle.highlight_by_tex(char, color) + subtitle.set_color_by_tex(char, color) self.loop.next_to(subtitle, DOWN) self.add(title, subtitle) self.add_dots_at_alphas(0.5, 0.6) dots = self.dots for dot, color, char in zip(dots, colors, "ab"): - dot.highlight(color) + dot.set_color(color) label = TexMobject(char) - label.highlight(color) + label.set_color(color) label.next_to(dot, RIGHT, buff = SMALL_BUFF) dot.label = label self.dots[1].label.shift(0.3*UP) @@ -966,13 +966,13 @@ class DefineUnorderedPair(ClosedLoopScene): ) subtitle.next_to(title, DOWN) for char in "ab": - subtitle.highlight_by_tex(char, PURPLE_B) + subtitle.set_color_by_tex(char, PURPLE_B) self.loop.next_to(subtitle, DOWN) self.add(title, subtitle) self.add_dots_at_alphas(0.5, 0.6) dots = self.dots - dots.highlight(PURPLE_B) + dots.set_color(PURPLE_B) labels = VGroup(*[subtitle[i].copy() for i in 0, 2]) for label, vect in zip(labels, [LEFT, RIGHT]): @@ -1231,7 +1231,7 @@ class EdgesOfSquare(Scene): ) for vect in DOWN, UP ]) - y_edges.highlight(BLUE) + y_edges.set_color(BLUE) x_edges = VGroup(*[ Line( square.get_corner(vect+DOWN), @@ -1239,7 +1239,7 @@ class EdgesOfSquare(Scene): ) for vect in LEFT, RIGHT ]) - x_edges.highlight(MAROON_B) + x_edges.set_color(MAROON_B) return x_edges, y_edges def get_coordinate_labels(self, square): @@ -1266,7 +1266,7 @@ class EdgesOfSquare(Scene): ] for dot_group, label_group in zip(dot_groups, label_groups): for dot, label in zip(dot_group, label_group): - label[1].highlight(MAROON_B) + label[1].set_color(MAROON_B) label.next_to(dot, RIGHT*np.sign(dot.get_center()[0])) label.add(dot) return label_groups @@ -1284,7 +1284,7 @@ class EdgesOfSquare(Scene): for a1, a2 in zip(alpha_range, alpha_range[1:]) ]) for edge in edges - ]).highlight(edges.get_color()) + ]).set_color(edges.get_color()) for edges in x_edges, y_edges ] @@ -1307,7 +1307,7 @@ class EndpointsGluedTogether(ClosedLoopScene): Dot(line.get_critical_point(vect)) for vect in LEFT, RIGHT ]) - dots.highlight(BLUE) + dots.set_color(BLUE) self.add(interval, dots) self.play(dots.rotate_in_place, np.pi/20, rate_func = wiggle) @@ -1368,7 +1368,7 @@ class WigglingPairOfPoints(ClosedLoopScene): self.add_dots_at_alphas(*alpha_pairs[-1]) self.add_connecting_lines() self.dots.gradient_highlight(GREEN, RED) - self.connecting_lines.highlight(YELLOW) + self.connecting_lines.set_color(YELLOW) for x, pair in zip(range(20), it.cycle(alpha_pairs)): self.move_dots_to_alphas(pair, run_time = 0.3) @@ -1392,9 +1392,9 @@ class TrivialPairCollision(ClosedLoopScene): self.dots.gradient_highlight(BLUE, YELLOW) a, b = self.dots a_label = TexMobject("a").next_to(a, RIGHT) - a_label.highlight(a.get_color()) + a_label.set_color(a.get_color()) b_label = TexMobject("b").next_to(b, LEFT) - b_label.highlight(b.get_color()) + b_label.set_color(b.get_color()) line = Line( a.get_corner(DOWN+LEFT), b.get_corner(UP+RIGHT), @@ -1507,7 +1507,7 @@ class FoldUnitSquare(EdgesOfSquare): self.add(start_arrows, end_arrows) self.start_arrows = start_arrows self.end_arrows = VGroup(*list(end_arrows[3:])+list(end_arrows[:3])).copy() - self.end_arrows.highlight( + self.end_arrows.set_color( color_gradient([MAROON_B, BLUE], 3)[1] ) @@ -1523,7 +1523,7 @@ class FoldUnitSquare(EdgesOfSquare): for (a, b) in (x, y), (y, x): point = self.get_point_from_coords(a, b) dot = Dot(point) - dot.highlight(color) + dot.set_color(color) if color == colors[-1]: s = "(x, y)" if a < b else "(y, x)" label = TexMobject(s) @@ -1535,8 +1535,8 @@ class FoldUnitSquare(EdgesOfSquare): self.play(*map(FadeIn, [dot, label])) x_line = Line(point+a*unit*LEFT, point) y_line = Line(point+b*unit*DOWN, point) - x_line.highlight(GREEN) - y_line.highlight(RED) + x_line.set_color(GREEN) + y_line.set_color(RED) if old_x_line is None: self.play(ShowCreation(x_line), Animation(dot)) self.play(ShowCreation(y_line), Animation(dot)) @@ -1584,7 +1584,7 @@ class FoldUnitSquare(EdgesOfSquare): else: label = TexMobject("(%.1f, %.1f)"%(x, x)) label.next_to(dot, UP+LEFT, buff = SMALL_BUFF) - VGroup(dot, label).highlight(RED) + VGroup(dot, label).set_color(RED) if old_label is None: self.play( ShowCreation(dot), @@ -1646,14 +1646,14 @@ class FoldUnitSquare(EdgesOfSquare): dots.scale(0.6) dots.shift(4*RIGHT + UP) for dot in dots[:2]: - dot.highlight(YELLOW) + dot.set_color(YELLOW) self.play( ShowCreation(dot), self.randy.look_at, dot ) self.wait() for dot in dots[2:]: - dot.highlight(MAROON_B) + dot.set_color(MAROON_B) self.play( ShowCreation(dot), self.randy.look_at, dot @@ -1782,7 +1782,7 @@ class MobiusPlaneAnalogy(ClosedLoopScene): self.loop.next_to(top_arrow, RIGHT) self.loop.shift_onto_screen() self.add_dots_at_alphas(0.3, 0.5) - self.dots.highlight(PURPLE_B) + self.dots.set_color(PURPLE_B) plane = NumberPlane() plane.scale(0.3).next_to(low_arrow, LEFT) @@ -1823,7 +1823,7 @@ class MobiusToPairToSurface(ClosedLoopScene): self.loop.next_to(ORIGIN, RIGHT) self.loop.to_edge(UP) self.add_dots_at_alphas(0.4, 0.6) - self.dots.highlight(MAROON_B) + self.dots.set_color(MAROON_B) self.add_connecting_lines() strip_dot = Dot().next_to(self.loop, LEFT, buff = 2*LARGE_BUFF) surface_dot = Dot().next_to(self.loop, DOWN, buff = 2*LARGE_BUFF) @@ -1968,7 +1968,7 @@ class PatreonThanks(Scene): n_patrons = len(self.specific_patrons) special_thanks = TextMobject("Special thanks to:") - special_thanks.highlight(YELLOW) + special_thanks.set_color(YELLOW) special_thanks.shift(2*UP) left_patrons = VGroup(*map(TextMobject, diff --git a/old_projects/zeta.py b/old_projects/zeta.py index b76be713..b3d0d6af 100644 --- a/old_projects/zeta.py +++ b/old_projects/zeta.py @@ -137,7 +137,7 @@ class ZetaTransformationScene(ComplexTransformationScene): reflected_plane = self.plane.copy() reflected_plane.rotate(np.pi, UP, about_point = RIGHT) for mob in reflected_plane.family_members_with_points(): - mob.highlight( + mob.set_color( Color(rgb = 1-0.5*color_to_rgb(mob.get_color())) ) self.prepare_for_transformation(reflected_plane) @@ -248,7 +248,7 @@ class WhyPeopleMayKnowIt(TeacherStudentsScene): ) divergent_sum.arrange_submobjects(DOWN) divergent_sum[0].gradient_highlight(YELLOW, MAROON_B) - divergent_sum[1].highlight(BLACK) + divergent_sum[1].set_color(BLACK) #Thoughts self.play(*it.chain(*[ @@ -279,7 +279,7 @@ class WhyPeopleMayKnowIt(TeacherStudentsScene): ])) self.wait() self.random_blink() - divergent_sum[1].highlight(WHITE) + divergent_sum[1].set_color(WHITE) self.play(Write(divergent_sum[1])) self.random_blink() self.wait() @@ -315,11 +315,11 @@ class ComplexValuedFunctions(ComplexTransformationScene): z_in = Dot(UP+RIGHT, color = YELLOW) z_out = Dot(4*RIGHT + 2*UP, color = MAROON_B) arrow = Arrow(z_in, z_out, buff = 0.1) - arrow.highlight(WHITE) + arrow.set_color(WHITE) z = TexMobject("z").next_to(z_in, DOWN+LEFT, buff = SMALL_BUFF) - z.highlight(z_in.get_color()) + z.set_color(z_in.get_color()) f_z = TexMobject("f(z)").next_to(z_out, UP+RIGHT, buff = SMALL_BUFF) - f_z.highlight(z_out.get_color()) + f_z.set_color(z_out.get_color()) self.add(z_in, z) self.wait() @@ -353,7 +353,7 @@ class PreviewZetaAndContinuation(ZetaTransformationScene): ] ] for mob in titles: - mob[1].highlight(YELLOW) + mob[1].set_color(YELLOW) mob.to_corner(UP+LEFT, buff = 0.7) mob.add_background_rectangle() @@ -386,8 +386,8 @@ class AssumeKnowledgeOfComplexNumbers(ComplexTransformationScene): complex_number_label = TexMobject( "%d+%di"%(int(z.real), int(z.imag)) ) - complex_number_label[0].highlight(x_line.get_color()) - complex_number_label[2].highlight(y_line.get_color()) + complex_number_label[0].set_color(x_line.get_color()) + complex_number_label[2].set_color(y_line.get_color()) complex_number_label.next_to(dot, UP) text = VGroup( @@ -400,7 +400,7 @@ class AssumeKnowledgeOfComplexNumbers(ComplexTransformationScene): for words in text: words.add_background_rectangle() text[0].shift(LEFT) - text[-1].highlight(PINK) + text[-1].set_color(PINK) text.to_corner(UP+LEFT) self.play(Write(text[0])) @@ -475,7 +475,7 @@ class DefineForRealS(PiCreatureScene): for d, brace in enumerate(braces) ]) for frac, brace, line in zip(fracs, braces, lines): - frac.highlight(line.get_color()) + frac.set_color(line.get_color()) frac.next_to(brace, UP, buff = SMALL_BUFF) if frac is fracs[-1]: frac.shift(0.5*RIGHT + 0.2*UP) @@ -484,7 +484,7 @@ class DefineForRealS(PiCreatureScene): tip_length = 0.1, buff = 0.1 ) - arrow.highlight(line.get_color()) + arrow.set_color(line.get_color()) frac.add(arrow) pi_term = TexMobject("= \\frac{\\pi^2}{6}") @@ -640,7 +640,7 @@ class DefineForRealS(PiCreatureScene): sigma.next_to(brace, UP) inputs.add(*sigma[-n_input_chars:]) - inputs.highlight(input_color) + inputs.set_color(input_color) group = VGroup(zeta_s_eq, sum_terms, brace, sigma) return group, inputs @@ -658,8 +658,8 @@ class DefineForRealS(PiCreatureScene): lines.set_stroke(width = line_thickness) # VGroup(*lines[:4]).gradient_highlight(RED, GREEN_B) # VGroup(*lines[4:]).gradient_highlight(GREEN_B, MAROON_B) - VGroup(*lines[::2]).highlight(MAROON_B) - VGroup(*lines[1::2]).highlight(RED) + VGroup(*lines[::2]).set_color(MAROON_B) + VGroup(*lines[1::2]).set_color(RED) braces = VGroup(*[ Brace(line, UP) @@ -704,12 +704,12 @@ class ReadIntoZetaFunction(Scene): randy.shift(3*LEFT+DOWN) paper = Rectangle(width = 4, height = 5) paper.next_to(randy, RIGHT, aligned_edge = DOWN) - paper.highlight(WHITE) + paper.set_color(WHITE) max_width = 0.8*paper.get_width() title = TextMobject("$\\zeta(s)$ manual") title.next_to(paper.get_top(), DOWN) - title.highlight(YELLOW) + title.set_color(YELLOW) paper.add(title) paragraph_lines = VGroup( Line(LEFT, RIGHT), @@ -728,7 +728,7 @@ class ReadIntoZetaFunction(Scene): statement.scale_to_fit_height(max_height) statement.next_to(paragraph_lines, DOWN) - statement.highlight(GREEN_B) + statement.set_color(GREEN_B) paper.add(paragraph_lines.copy().next_to(statement, DOWN, MED_LARGE_BUFF)) randy.look_at(statement) @@ -758,7 +758,7 @@ class IgnoreNegatives(TeacherStudentsScene): definition = TexMobject(""" \\zeta(s) = \\sum_{n=1}^{\\infty} \\frac{1}{n^s} """) - VGroup(definition[2], definition[-1]).highlight(YELLOW) + VGroup(definition[2], definition[-1]).set_color(YELLOW) definition.to_corner(UP+LEFT) self.add(definition) brace = Brace(definition, DOWN) @@ -766,7 +766,7 @@ class IgnoreNegatives(TeacherStudentsScene): Only defined for $s > 1$ """) - only_s_gt_1[-3].highlight(YELLOW) + only_s_gt_1[-3].set_color(YELLOW) self.change_student_modes(*["confused"]*3) @@ -774,10 +774,10 @@ class IgnoreNegatives(TeacherStudentsScene): "Ignore $s \\le 1$ \\dots \\\\", "For now." ) - words[0][6].highlight(YELLOW) - words[1].highlight(BLACK) + words[0][6].set_color(YELLOW) + words[1].set_color(BLACK) self.teacher_says(words) - self.play(words[1].highlight, WHITE) + self.play(words[1].set_color, WHITE) self.change_student_modes(*["happy"]*3) self.play( GrowFromCenter(brace), @@ -820,7 +820,7 @@ class RiemannFatherOfComplex(ComplexTransformationScene): dot.label = TexMobject(tex) dot.label.add_background_rectangle() dot.label.next_to(dot, DOWN+RIGHT, buff = SMALL_BUFF) - dot.label.highlight(dot.get_color()) + dot.label.set_color(dot.get_color()) self.play( ShowCreation(input_dot), @@ -869,10 +869,10 @@ class FromRealToComplex(ComplexTransformationScene): ) number_line.add_numbers() input_dot = Dot(number_line.number_to_point(2)) - input_dot.highlight(YELLOW) + input_dot.set_color(YELLOW) output_dot = Dot(number_line.number_to_point(np.pi**2/6)) - output_dot.highlight(self.output_color) + output_dot.set_color(self.output_color) arc = Arc( 2*np.pi/3, start_angle = np.pi/6, @@ -919,7 +919,7 @@ class FromRealToComplex(ComplexTransformationScene): self.background.num_pair_to_point((2, 1)) ) input_label = TexMobject("2+i") - input_label.highlight(YELLOW) + input_label.set_color(YELLOW) input_label.next_to(input_dot.target, DOWN+RIGHT, buff = SMALL_BUFF) input_label.add_background_rectangle() input_label.save_state() @@ -955,14 +955,14 @@ class FromRealToComplex(ComplexTransformationScene): new_frac = TexMobject( "\\Big(", "\\frac{1}{2}", "\\Big)", "^{2+i}" ) - new_frac[-1].highlight(YELLOW) + new_frac[-1].set_color(YELLOW) new_frac.scale(frac_scale_factor) new_frac.move_to(frac.target) new_frac.shift(LEFT+0.2*UP) words = TextMobject("Not repeated \\\\", " multiplication") words.scale(0.8) - words.highlight(RED) + words.set_color(RED) words.next_to(new_frac, RIGHT) new_words = TextMobject("Not \\emph{super} \\\\", "crucial to know...") @@ -1048,7 +1048,7 @@ class FromRealToComplex(ComplexTransformationScene): def vary_complex_input(self): zeta = self.get_zeta_definition("s", "") - zeta[3].highlight(BLACK) + zeta[3].set_color(BLACK) self.play(Transform(self.zeta, zeta)) self.play(FadeOut(self.input_label)) self.wait(2) @@ -1143,7 +1143,7 @@ class FromRealToComplex(ComplexTransformationScene): ]) ) arrow = Arrow(self.input_dot, self.output_dot, buff = SMALL_BUFF) - arrow.highlight(WHITE) + arrow.set_color(WHITE) self.play(ShowCreation(arrow)) self.play(Blink(morty)) self.wait() @@ -1178,9 +1178,9 @@ class FromRealToComplex(ComplexTransformationScene): output = TexMobject("= \\," + output_string) output.next_to(sum_terms, RIGHT) - output.highlight(self.output_color) + output.set_color(self.output_color) - inputs.highlight(input_color) + inputs.set_color(input_color) group = VGroup(zeta_s_eq, sum_terms, output) group.to_edge(UP) group.add_to_back(BackgroundRectangle(group)) @@ -1199,8 +1199,8 @@ class FromRealToComplex(ComplexTransformationScene): widths = np.linspace(line_thickness, 0, len(list(lines))) for line, width in zip(lines, widths): line.set_stroke(width = width) - VGroup(*lines[::2]).highlight(MAROON_B) - VGroup(*lines[1::2]).highlight(RED) + VGroup(*lines[::2]).set_color(MAROON_B) + VGroup(*lines[1::2]).set_color(RED) final_dot = Dot( # self.z_to_point(power_sums[-1]), @@ -1214,14 +1214,14 @@ class TerritoryOfExponents(ComplexTransformationScene): def construct(self): self.add_title() familiar_territory = TextMobject("Familiar territory") - familiar_territory.highlight(YELLOW) + familiar_territory.set_color(YELLOW) familiar_territory.next_to(ORIGIN, UP+RIGHT) familiar_territory.shift(2*UP) real_line = Line(LEFT, RIGHT).scale(FRAME_X_RADIUS) - real_line.highlight(YELLOW) + real_line.set_color(YELLOW) arrow1 = Arrow(familiar_territory.get_bottom(), real_line.get_left()) arrow2 = Arrow(familiar_territory.get_bottom(), real_line.get_right()) - VGroup(arrow1, arrow2).highlight(WHITE) + VGroup(arrow1, arrow2).set_color(WHITE) extended_realm = TextMobject("Extended realm") extended_realm.move_to(familiar_territory) @@ -1249,7 +1249,7 @@ class TerritoryOfExponents(ComplexTransformationScene): exponent = TexMobject( "\\left(\\frac{1}{2}\\right)^s" ) - exponent[-1].highlight(YELLOW) + exponent[-1].set_color(YELLOW) exponent.next_to(ORIGIN, LEFT, MED_LARGE_BUFF).to_edge(UP) self.add_foreground_mobjects(exponent) @@ -1267,7 +1267,7 @@ class ComplexExponentiation(Scene): "\\left(\\frac{1}{2}\\right)", "^{2}", "\\left(\\frac{1}{2}\\right)", "^{i}", ) - VGroup(original[-1], split[1], split[3]).highlight(YELLOW) + VGroup(original[-1], split[1], split[3]).set_color(YELLOW) VGroup(original, split).shift(UP) real_part = VGroup(*split[:2]) imag_part = VGroup(*split[2:]) @@ -1276,7 +1276,7 @@ class ComplexExponentiation(Scene): we_understand = brace.get_text( "We understand this" ) - VGroup(brace, we_understand).highlight(GREEN_B) + VGroup(brace, we_understand).set_color(GREEN_B) self.add(original) self.wait() @@ -1295,7 +1295,7 @@ class ComplexExponentiation(Scene): self.play( GrowFromCenter(brace), FadeIn(we_understand), - real_part.highlight, GREEN_B + real_part.set_color, GREEN_B ) self.wait() self.play( @@ -1309,23 +1309,23 @@ class ComplexExponentiation(Scene): left_plane = NumberPlane(x_radius = (FRAME_X_RADIUS-1)/2) left_plane.to_edge(LEFT, buff = 0) imag_line = Line(DOWN, UP).scale(FRAME_Y_RADIUS) - imag_line.highlight(YELLOW).fade(0.3) + imag_line.set_color(YELLOW).fade(0.3) imag_line.move_to(left_plane.get_center()) left_plane.add(imag_line) left_title = TextMobject("Input space") left_title.add_background_rectangle() - left_title.highlight(YELLOW) + left_title.set_color(YELLOW) left_title.next_to(left_plane.get_top(), DOWN) right_plane = NumberPlane(x_radius = (FRAME_X_RADIUS-1)/2) right_plane.to_edge(RIGHT, buff = 0) unit_circle = Circle() - unit_circle.highlight(MAROON_B).fade(0.3) + unit_circle.set_color(MAROON_B).fade(0.3) unit_circle.shift(right_plane.get_center()) right_plane.add(unit_circle) right_title = TextMobject("Output space") right_title.add_background_rectangle() - right_title.highlight(MAROON_B) + right_title.set_color(MAROON_B) right_title.next_to(right_plane.get_top(), DOWN) for plane in left_plane, right_plane: @@ -1368,13 +1368,13 @@ class ComplexExponentiation(Scene): def show_imaginary_powers(self): i = complex(0, 1) input_dot = Dot(self.z_to_point(i)) - input_dot.highlight(YELLOW) + input_dot.set_color(YELLOW) output_dot = Dot(self.z_to_point(0.5**(i), is_input = False)) - output_dot.highlight(MAROON_B) + output_dot.set_color(MAROON_B) output_dot.save_state() output_dot.move_to(input_dot) - output_dot.highlight(input_dot.get_color()) + output_dot.set_color(input_dot.get_color()) curr_base = 0.5 def output_dot_update(ouput_dot): @@ -1394,12 +1394,12 @@ class ComplexExponentiation(Scene): exp = self.imag_exponent[-1] new_exp = TexMobject("ti") - new_exp.highlight(exp.get_color()) + new_exp.set_color(exp.get_color()) new_exp.scale_to_fit_height(exp.get_height()) new_exp.move_to(exp, LEFT) nine = TexMobject("9") - nine.highlight(BLUE) + nine.set_color(BLUE) denom = self.imag_exponent[0][3] denom.save_state() nine.replace(denom) @@ -1433,7 +1433,7 @@ class SizeAndRotationBreakdown(Scene): "\\left(\\frac{1}{2}\\right)", "^{2}", "\\left(\\frac{1}{2}\\right)", "^{i}", ) - VGroup(original[-1], split[1], split[3]).highlight(YELLOW) + VGroup(original[-1], split[1], split[3]).set_color(YELLOW) VGroup(original, split).shift(UP) real_part = VGroup(*split[:2]) imag_part = VGroup(*split[2:]) @@ -1489,7 +1489,7 @@ class ShowMultiplicationOfRealAndImaginaryExponentialParts(FromRealToComplex): "\\left(\\frac{1}{2}\\right)", "^{2}", "\\left(\\frac{1}{2}\\right)", "^{i}", ) - VGroup(original[-1], split[1], split[3]).highlight(YELLOW) + VGroup(original[-1], split[1], split[3]).set_color(YELLOW) VGroup(original, split).to_corner(UP+LEFT) rect = BackgroundRectangle(split) real_part = VGroup(*split[:2]) @@ -1523,19 +1523,19 @@ class ShowMultiplicationOfRealAndImaginaryExponentialParts(FromRealToComplex): brace = Brace(fourth_line, UP, buff = SMALL_BUFF) fourth_dot = Dot(fourth_point) fourth_group = VGroup(fourth_line, brace, fourth_dot) - fourth_group.highlight(RED) + fourth_group.set_color(RED) circle = Circle(radius = 2, color = MAROON_B) circle.fade(0.3) imag_power_point = self.z_to_point(0.5**complex(0, 1)) imag_power_dot = Dot(imag_power_point) imag_power_line = Line(ORIGIN, imag_power_point) - VGroup(imag_power_dot, imag_power_line).highlight(MAROON_B) + VGroup(imag_power_dot, imag_power_line).set_color(MAROON_B) full_power_tex = TexMobject( "\\left(\\frac{1}{2}\\right)", "^{2+i}" ) - full_power_tex[-1].highlight(YELLOW) + full_power_tex[-1].set_color(YELLOW) full_power_tex.add_background_rectangle() full_power_tex.scale(0.7) full_power_tex.next_to( @@ -1612,24 +1612,24 @@ class ComplexFunctionsAsTransformations(ComplexTransformationScene): RIGHT+2*UP, ] input_dots = VGroup(*map(Dot, input_points)) - input_dots.highlight(YELLOW) + input_dots.set_color(YELLOW) output_dots = VGroup(*[ Dot(ip + on) for ip, on in zip(input_points, output_nudges) ]) - output_dots.highlight(MAROON_B) + output_dots.set_color(MAROON_B) arrows = VGroup(*[ Arrow(in_dot, out_dot, buff = 0.1, color = WHITE) for in_dot, out_dot, in zip(input_dots, output_dots) ]) for i, dot in enumerate(input_dots): label = TexMobject("s_%d"%i) - label.highlight(dot.get_color()) + label.set_color(dot.get_color()) label.next_to(dot, DOWN+LEFT, buff = SMALL_BUFF) dot.add(label) for i, dot in enumerate(output_dots): label = TexMobject("f(s_%d)"%i) - label.highlight(dot.get_color()) + label.set_color(dot.get_color()) label.next_to(dot, UP+RIGHT, buff = SMALL_BUFF) dot.add(label) return input_dots, output_dots, arrows @@ -1648,7 +1648,7 @@ class VisualizingSSquared(ComplexTransformationScene): def add_title(self): title = TexMobject("f(", "s", ") = ", "s", "^2") - title.highlight_by_tex("s", YELLOW) + title.set_color_by_tex("s", YELLOW) title.add_background_rectangle() title.scale(1.5) title.to_corner(UP+LEFT) @@ -1688,7 +1688,7 @@ class VisualizingSSquared(ComplexTransformationScene): ) arrow.add(stand_in_arrow.tip) arrows.add(arrow) - arrows.highlight(WHITE) + arrows.set_color(WHITE) for input_dot, output_dot, arrow in zip(input_dots, output_dots, arrows): input_dot.save_state() @@ -1761,7 +1761,7 @@ class ShowZetaOnHalfPlane(ZetaTransformationScene): self.initial_transformation() self.react_to_transformation() self.show_cutoff() - self.highlight_i_line() + self.set_color_i_line() self.show_continuation() self.emphsize_sum_doesnt_make_sense() @@ -1774,9 +1774,9 @@ class ShowZetaOnHalfPlane(ZetaTransformationScene): for d in range(1, 5) ] + ["\\cdots"] ) - zeta[1].highlight(YELLOW) + zeta[1].set_color(YELLOW) for mob in zeta[3:3+4]: - mob[-2].highlight(YELLOW) + mob[-2].set_color(YELLOW) zeta.add_background_rectangle() zeta.scale(0.8) zeta.to_corner(UP+LEFT) @@ -1827,7 +1827,7 @@ class ShowZetaOnHalfPlane(ZetaTransformationScene): complex(np.euler_gamma, u*FRAME_Y_RADIUS) for u in 1, -1 ])) - line.highlight(YELLOW) + line.set_color(YELLOW) arrows = [ Arrow(words.get_right(), point) for point in line.get_start_and_end() @@ -1844,7 +1844,7 @@ class ShowZetaOnHalfPlane(ZetaTransformationScene): self.wait(2) self.play(*map(FadeOut, [words, line])) - def highlight_i_line(self): + def set_color_i_line(self): right_i_lines, left_i_lines = [ VGroup(*[ Line( @@ -1855,8 +1855,8 @@ class ShowZetaOnHalfPlane(ZetaTransformationScene): ]) for horiz_vect in RIGHT, LEFT ] - right_i_lines.highlight(YELLOW) - left_i_lines.highlight(BLUE) + right_i_lines.set_color(YELLOW) + left_i_lines.set_color(BLUE) for lines in right_i_lines, left_i_lines: self.prepare_for_transformation(lines) @@ -1932,9 +1932,9 @@ class ShowZetaOnHalfPlane(ZetaTransformationScene): class ShowConditionalDefinition(Scene): def construct(self): zeta = TexMobject("\\zeta(s)=") - zeta[2].highlight(YELLOW) + zeta[2].set_color(YELLOW) sigma = TexMobject("\\sum_{n=1}^\\infty \\frac{1}{n^s}") - sigma[-1].highlight(YELLOW) + sigma[-1].set_color(YELLOW) something_else = TextMobject("Something else...") conditions = VGroup(*[ TextMobject("if Re$(s) %s 1$"%s) @@ -1964,12 +1964,12 @@ class ShowConditionalDefinition(Scene): question = underbrace.get_text(""" What to put here? """) - VGroup(underbrace, question).highlight(GREEN_B) + VGroup(underbrace, question).set_color(GREEN_B) self.play( GrowFromCenter(underbrace), Write(question), - something_else.highlight, GREEN_B + something_else.set_color, GREEN_B ) self.wait(2) @@ -2014,7 +2014,7 @@ class SquiggleOnExtensions(ZetaTransformationScene): def note_point(self, z, label_tex): dot = Dot(self.z_to_point(z)) - dot.highlight(YELLOW) + dot.set_color(YELLOW) label = TexMobject(label_tex) label.add_background_rectangle() label.next_to(dot, UP+LEFT, buff = SMALL_BUFF) @@ -2107,7 +2107,7 @@ class SquiggleOnExtensions(ZetaTransformationScene): alignment = "" ) words.to_corner(UP+LEFT) - words.highlight_by_tex("\\emph{derivative}", YELLOW) + words.set_color_by_tex("\\emph{derivative}", YELLOW) words.add_background_rectangle() self.play(Write(words)) @@ -2159,7 +2159,7 @@ class IntroduceAnglePreservation(VisualizingSSquared): def add_title(self): title = TexMobject("f(", "s", ")=", "s", "^2") - title.highlight_by_tex("s", YELLOW) + title.set_color_by_tex("s", YELLOW) title.scale(1.5) title.to_corner(UP+LEFT) title.add_background_rectangle() @@ -2188,7 +2188,7 @@ class IntroduceAnglePreservation(VisualizingSSquared): pi.bubble.resize_to_content() pi.bubble.pin_to(pi) for index in 3, 7: - randy.bubble.content[index].highlight(YELLOW) + randy.bubble.content[index].set_color(YELLOW) self.play(*map(FadeIn, [randy, morty])) self.play( @@ -2257,8 +2257,8 @@ class IntroduceAnglePreservation(VisualizingSSquared): for text in equiv, kind_of: text.scale(1.2) text.add_background_rectangle() - equiv.highlight(YELLOW) - kind_of.highlight(RED) + equiv.set_color(YELLOW) + kind_of.set_color(RED) kind_of.next_to(equiv, RIGHT) VGroup(equiv, kind_of).next_to(ORIGIN, UP, buff = 1) @@ -2313,7 +2313,7 @@ class IntroduceAnglePreservation(VisualizingSSquared): angle_tex = TexMobject( "%d^\\circ"%abs(int((angle2-angle1)*180/np.pi)) ) - angle_tex.highlight(arc.get_color()) + angle_tex.set_color(arc.get_color()) angle_tex.add_background_rectangle() self.put_angle_tex_next_to_arc(angle_tex, arc) angle_arrow = Arrow( @@ -2339,7 +2339,7 @@ class IntroduceAnglePreservation(VisualizingSSquared): ]) self.put_angle_tex_next_to_arc(angle_tex, arc) arrow = Arrow(angle_tex, arc, buff = 0.1) - arrow.highlight(arc.get_color()) + arrow.set_color(arc.get_color()) self.play( Write(angle_tex), ShowCreation(arrow) @@ -2365,7 +2365,7 @@ class IntroduceAnglePreservation(VisualizingSSquared): ) brackets.scale(0.15) brackets.set_stroke(width = 2) - brackets.highlight(YELLOW) + brackets.set_color(YELLOW) brackets.shift(0.02*UP) ##Why??? brackets.rotate(rotation, about_point = ORIGIN) brackets.shift(self.z_to_point(output_z)) @@ -2388,12 +2388,12 @@ class AngleAtZeroDerivativePoints(IntroduceAnglePreservation): def add_title(self): title = TexMobject("f(", "s", ")=", "s", "^2") - title.highlight_by_tex("s", YELLOW) + title.set_color_by_tex("s", YELLOW) title.scale(1.5) title.to_corner(UP+LEFT) title.add_background_rectangle() derivative = TexMobject("f'(0) = 0") - derivative.highlight(RED) + derivative.set_color(RED) derivative.scale(1.2) derivative.add_background_rectangle() derivative.next_to(title, DOWN) @@ -2407,7 +2407,7 @@ class AngleAtZeroDerivativePoints(IntroduceAnglePreservation): ) if not self.is_before_transformation: two_dot = TexMobject("2 \\times ") - two_dot.highlight(angle_tex.get_color()) + two_dot.set_color(angle_tex.get_color()) two_dot.next_to(angle_tex, LEFT, buff = SMALL_BUFF) two_dot.add_background_rectangle() center = angle_tex.get_center() @@ -2455,7 +2455,7 @@ class AnglePreservationAtAnyPairOfPoints(IntroduceAnglePreservation): def show_example_analytic_functions(self): words = TextMobject("Examples of analytic functions:") words.shift(2*UP) - words.highlight(YELLOW) + words.set_color(YELLOW) words.add_background_rectangle() words.next_to(UP, UP).to_edge(LEFT) functions = TextMobject( @@ -2489,8 +2489,8 @@ class NoteZetaFunctionAnalyticOnRightHalf(ZetaTransformationScene): title = TexMobject( "\\zeta(s) = \\sum_{n=1}^\\infty \\frac{1}{n^s}" ) - title[2].highlight(YELLOW) - title[-1].highlight(YELLOW) + title[2].set_color(YELLOW) + title[-1].set_color(YELLOW) title.add_background_rectangle() title.to_corner(UP+LEFT) self.add_foreground_mobjects(title) @@ -2520,7 +2520,7 @@ class NoteZetaFunctionAnalyticOnRightHalf(ZetaTransformationScene): ) brackets.scale(0.1) brackets.set_stroke(width = 2) - brackets.highlight(YELLOW) + brackets.set_color(YELLOW) brackets.rotate(rotation, about_point = ORIGIN) brackets.shift(self.z_to_point(output_z)) return brackets @@ -2567,7 +2567,7 @@ class InfiniteContinuousJigsawPuzzle(ZetaTransformationScene): def name_analytic_continuation(self): words = TextMobject("``Analytic continuation''") - words.highlight(YELLOW) + words.set_color(YELLOW) words.scale(1.5) words.next_to(self.title, DOWN, buff = LARGE_BUFF) words.add_background_rectangle() @@ -2588,7 +2588,7 @@ class ThatsHowZetaIsDefined(TeacherStudentsScene): zeta = TexMobject( "\\zeta(s) = \\sum_{n=1}^\\infty \\frac{1}{n^s}" ) - VGroup(zeta[2], zeta[-1]).highlight(YELLOW) + VGroup(zeta[2], zeta[-1]).set_color(YELLOW) zeta.to_corner(UP+LEFT) self.add(zeta) @@ -2610,7 +2610,7 @@ class ManyIntersectingLinesPreZeta(ZetaTransformationScene): lines = VGroup(line, line.copy().rotate(self.angle)) arc = Arc(start_angle = line.get_angle(), angle = self.angle) arc.scale(self.arc_scale_factor) - arc.highlight(YELLOW) + arc.set_color(YELLOW) lines.add(arc) # lines.set_stroke(WHITE, width = 5) lines.shift(self.lines_center + self.nudge_size*RIGHT) @@ -2775,7 +2775,7 @@ class DiscussZeros(ZetaTransformationScene): for alpha in np.arange(3*np.pi/20, 2*np.pi, 2*np.pi/5) for nudge in [random.random()*np.pi/6] ]) - dots.highlight(YELLOW) + dots.set_color(YELLOW) q_marks = VGroup(*[ TexMobject("?").next_to(dot, UP) for dot in dots @@ -2875,7 +2875,7 @@ class DiscussZeros(ZetaTransformationScene): Dot(0.5*RIGHT + y*UP) for y in np.linspace(-2.5, 3.2, 5) ]) - new_dots.highlight(YELLOW) + new_dots.set_color(YELLOW) critical_line = Line( 0.5*RIGHT+FRAME_Y_RADIUS*DOWN, 0.5*RIGHT+FRAME_Y_RADIUS*UP, @@ -2998,7 +2998,7 @@ class HighlightCriticalLineAgain(DiscussZeros): def construct(self): self.establish_plane() title = TexMobject("\\zeta(", "s", ") = 0") - title.highlight_by_tex("s", YELLOW) + title.set_color_by_tex("s", YELLOW) title.add_background_rectangle() title.to_corner(UP+LEFT) self.add(title) @@ -3017,7 +3017,7 @@ class HighlightCriticalLineAgain(DiscussZeros): ) randy = Randolph().to_corner(DOWN+LEFT) million = TexMobject("\\$1{,}000{,}000") - million.highlight(GREEN_B) + million.set_color(GREEN_B) million.next_to(ORIGIN, UP+LEFT) million.shift(2*LEFT) arrow1 = Arrow(million.get_right(), line.get_top()) @@ -3051,7 +3051,7 @@ class DiscussSumOfNaturals(Scene): title = TexMobject( "\\zeta(s) = \\sum_{n=1}^\\infty \\frac{1}{n^s}" ) - VGroup(title[2], title[-1]).highlight(YELLOW) + VGroup(title[2], title[-1]).set_color(YELLOW) title.to_corner(UP+LEFT) neg_twelfth, eq, zeta_neg_1, sum_naturals = equation = TexMobject( @@ -3060,10 +3060,10 @@ class DiscussSumOfNaturals(Scene): "\\zeta(-1)", "= 1 + 2 + 3 + 4 + \\cdots" ) - neg_twelfth.highlight(GREEN_B) - VGroup(*zeta_neg_1[2:4]).highlight(YELLOW) + neg_twelfth.set_color(GREEN_B) + VGroup(*zeta_neg_1[2:4]).set_color(YELLOW) q_mark = TexMobject("?").next_to(sum_naturals[0], UP) - q_mark.highlight(RED) + q_mark.set_color(RED) randy = Randolph() randy.to_corner(DOWN+LEFT) analytic_continuation = TextMobject("Analytic continuation") @@ -3074,7 +3074,7 @@ class DiscussSumOfNaturals(Scene): ac_to_zeta = Arrow(analytic_continuation.get_bottom(), zeta_neg_1.get_top()) cross = TexMobject("\\times") cross.scale(2) - cross.highlight(RED) + cross.set_color(RED) cross.rotate(np.pi/6) cross.move_to(sum_to_zeta.get_center()) @@ -3183,7 +3183,7 @@ class PatreonThanks(Scene): n_patrons = len(self.specific_patrons) special_thanks = TextMobject("Special thanks to:") - special_thanks.highlight(YELLOW) + special_thanks.set_color(YELLOW) special_thanks.shift(3*UP) patreon_logo = ImageMobject("patreon", invert = False) patreon_logo.scale_to_fit_height(1.5) @@ -3273,7 +3273,7 @@ class FinalAnimation(ZetaTransformationScene): self.add_extra_plane_lines_for_zeta() self.add_reflected_plane() title = TexMobject("s", "\\to \\frac{d\\zeta}{ds}(", "s", ")") - title.highlight_by_tex("s", YELLOW) + title.set_color_by_tex("s", YELLOW) title.add_background_rectangle() title.scale(1.5) title.to_corner(UP+LEFT) @@ -3298,7 +3298,7 @@ class Thumbnail(ZetaTransformationScene): div_sum = TexMobject("-\\frac{1}{12} = ", "1+2+3+4+\\cdots") div_sum.scale_to_fit_width(FRAME_WIDTH-1) div_sum.to_edge(DOWN) - div_sum.highlight(YELLOW) + div_sum.set_color(YELLOW) for mob in div_sum.submobjects: mob.add_to_back(BackgroundRectangle(mob)) @@ -3309,7 +3309,7 @@ class Thumbnail(ZetaTransformationScene): million = TexMobject("\\$1{,}000{,}000") million.scale_to_fit_width(FRAME_X_RADIUS+1) million.to_edge(UP+RIGHT) - million.highlight(GREEN_B) + million.set_color(GREEN_B) million.add_background_rectangle() self.add(div_sum, million, zeta) @@ -3332,7 +3332,7 @@ class ZetaPartialSums(ZetaTransformationScene): sigmas = [] for N in N_list + ["\\infty"]: tex = TexMobject(str(N)) - tex.highlight(YELLOW) + tex.set_color(YELLOW) new_sigma = sigma.copy() top = new_sigma[0] tex.move_to(top, DOWN) @@ -3352,7 +3352,7 @@ class ZetaPartialSums(ZetaTransformationScene): interim_planes.append(self.plane.copy().apply_complex_function(zeta)) symbol = VGroup(TexMobject("s")) symbol.scale(2) - symbol.highlight(YELLOW) + symbol.set_color(YELLOW) symbol.to_corner(UP+LEFT) for plane, sigma in zip(interim_planes, sigmas): self.play( diff --git a/topics/characters.py b/topics/characters.py index 5b16a538..5e534e8b 100644 --- a/topics/characters.py +++ b/topics/characters.py @@ -94,7 +94,7 @@ class PiCreature(SVGMobject): copy_mobject.name_parts() return copy_mobject - def highlight(self, color): + def set_color(self, color): self.body.set_fill(color) return self diff --git a/topics/combinatorics.py b/topics/combinatorics.py index 8f02aa37..f7895da7 100644 --- a/topics/combinatorics.py +++ b/topics/combinatorics.py @@ -48,9 +48,9 @@ class CountingScene(Scene): self.add(num_mob) if mode == "highlight": original_color = mob.color - mob.highlight(color) + mob.set_color(color) self.wait(frame_time) - mob.highlight(original_color) + mob.set_color(original_color) if mode == "show_creation": self.play(ShowCreation(mob, run_time = frame_time)) if mode == "show": @@ -75,7 +75,7 @@ class CountingScene(Scene): num_mob = TexMobject(str(count)) num_mob.center().shift(num_offset) self.add(num_mob) - self.highlight_region(region) + self.set_color_region(region) self.wait(frame_time) if mode == "one_at_a_time": self.reset_background() diff --git a/topics/common_scenes.py b/topics/common_scenes.py index b82d75b2..ddb9c128 100644 --- a/topics/common_scenes.py +++ b/topics/common_scenes.py @@ -49,8 +49,8 @@ class OpeningQuote(Scene): if self.quote_arg_separator == " ": quote[0].shift(0.2*RIGHT) quote[-1].shift(0.2*LEFT) - for term, color in self.highlighted_quote_terms.items(): - quote.highlight_by_tex(term, color) + for term, color in self.set_colored_quote_terms.items(): + quote.set_color_by_tex(term, color) quote.to_edge(UP) if quote.get_width() > max_width: quote.scale_to_fit_width(max_width) @@ -59,7 +59,7 @@ class OpeningQuote(Scene): def get_author(self, quote): author = TextMobject("\\Large -" + self.author) author.next_to(quote, DOWN) - author.highlight(YELLOW) + author.set_color(YELLOW) return author class PatreonThanks(Scene): diff --git a/topics/counting.py b/topics/counting.py index 855dcdf3..a0d77951 100644 --- a/topics/counting.py +++ b/topics/counting.py @@ -162,7 +162,7 @@ class CountingScene(Scene): digit = TexMobject(str(self.get_place_num(num, place))) if place >= len(self.digit_place_colors): self.digit_place_colors += self.digit_place_colors - digit.highlight(self.digit_place_colors[place]) + digit.set_color(self.digit_place_colors[place]) digit.scale(self.num_scale_factor) digit.next_to(result, LEFT, buff = SMALL_BUFF, aligned_edge = DOWN) result.add(digit) diff --git a/topics/fractals.py b/topics/fractals.py index c81c52a1..c191ce81 100644 --- a/topics/fractals.py +++ b/topics/fractals.py @@ -156,7 +156,7 @@ class PentagonalPiCreatureFractal(PentagonalFractal): for pi, color in zip(internal_pis, colors): pi.init_colors() pi.body.set_stroke(color, width = 0.5) - pi.highlight(color) + pi.set_color(color) def get_seed_shape(self): return Randolph(mode = "shruggie") @@ -190,7 +190,7 @@ class PiCreatureFractal(VMobject): random.seed(self.random_seed) for pi in reversed(internal_pis): color = random.choice(self.colors) - pi.highlight(color) + pi.set_color(color) pi.set_stroke(color, width = 0) diff --git a/topics/geometry.py b/topics/geometry.py index 0b55c195..1e5fe191 100644 --- a/topics/geometry.py +++ b/topics/geometry.py @@ -69,7 +69,7 @@ class Arc(VMobject): - self.highlight(self.get_color()) + self.set_color(self.get_color()) return self diff --git a/topics/graph_scene.py b/topics/graph_scene.py index 054efa29..b1663984 100644 --- a/topics/graph_scene.py +++ b/topics/graph_scene.py @@ -183,7 +183,7 @@ class GraphScene(Scene): ): label = TexMobject(label) color = color or graph.get_color() - label.highlight(color) + label.set_color(color) if x_val is None: #Search from right to left for x in np.linspace(self.x_max, self.x_min, 100): @@ -384,7 +384,7 @@ class GraphScene(Scene): np.sign(dx)*DOWN, buff = group.dx_label.get_height()/2 ) - group.dx_label.highlight(group.dx_line.get_color()) + group.dx_label.set_color(group.dx_line.get_color()) if df_label is not None: group.df_label.next_to( @@ -392,7 +392,7 @@ class GraphScene(Scene): np.sign(dx)*RIGHT, buff = group.df_label.get_height()/2 ) - group.df_label.highlight(group.df_line.get_color()) + group.df_label.set_color(group.df_line.get_color()) if include_secant_line: secant_line_color = secant_line_color or self.default_derivative_color diff --git a/topics/graph_theory.py b/topics/graph_theory.py index e38864b0..bf09dd5f 100644 --- a/topics/graph_theory.py +++ b/topics/graph_theory.py @@ -276,7 +276,7 @@ class GraphScene(Scene): next_in_cycle = it.cycle(cycle) next_in_cycle.next()#jump one ahead self.traced_cycle = Mobject(*[ - Line(self.points[i], self.points[j]).highlight(color) + Line(self.points[i], self.points[j]).set_color(color) for i, j in zip(cycle, next_in_cycle) ]) self.play( @@ -303,7 +303,7 @@ class GraphScene(Scene): Line( self.points[pair[0]], self.points[pair[1]] - ).highlight(color) + ).set_color(color) for pair in self.spanning_tree_index_pairs ]) @@ -362,7 +362,7 @@ class GraphScene(Scene): for index in indices ] self.treeified_spanning_tree = Mobject(*[ - Line(new_points[i], new_points[j]).highlight(color) + Line(new_points[i], new_points[j]).set_color(color) for i, j in self.spanning_tree_index_pairs ]) @@ -377,7 +377,7 @@ class GraphScene(Scene): for cycle in cycles ] self.dual_vertices = [ - Dot(point).highlight("green") + Dot(point).set_color("green") for point in self.dual_points ] self.dual_vertices[-1] = Circle().scale(FRAME_X_RADIUS + FRAME_Y_RADIUS) @@ -405,7 +405,7 @@ class GraphScene(Scene): new_point += FRAME_X_RADIUS*vect/np.linalg.norm(vect) dual_point_pair[i] = new_point self.dual_edges.append( - Line(*dual_point_pair).highlight() + Line(*dual_point_pair).set_color() ) diff --git a/topics/matrix.py b/topics/matrix.py index 362fbbc4..2da9d0d0 100644 --- a/topics/matrix.py +++ b/topics/matrix.py @@ -47,7 +47,7 @@ def vector_coordinate_label(vector_mob, integer_labels = True, else: #Pointing left shift_dir -= label.get_right() + DEFAULT_MOBJECT_TO_MOBJECT_BUFFER*RIGHT label.shift(shift_dir) - label.highlight(color) + label.set_color(color) label.rect = BackgroundRectangle(label) label.add_to_back(label.rect) return label @@ -108,9 +108,9 @@ class Matrix(VMobject): self.brackets = VMobject(l_bracket, r_bracket) return self - def highlight_columns(self, *colors): + def set_color_columns(self, *colors): for i, color in enumerate(colors): - VMobject(*self.mob_matrix[:,i]).highlight(color) + VMobject(*self.mob_matrix[:,i]).set_color(color) return self def add_background_to_entries(self): @@ -217,13 +217,13 @@ class NumericalMatrixMultiplication(Scene): ]) (m, k), n = l_matrix.shape, r_matrix.shape[1] for mob in result_matrix.flatten(): - mob.highlight(BLACK) + mob.set_color(BLACK) lagging_anims = [] for a in range(m): for b in range(n): for c in range(k): - l_matrix[a][c].highlight(YELLOW) - r_matrix[c][b].highlight(YELLOW) + l_matrix[a][c].set_color(YELLOW) + r_matrix[c][b].set_color(YELLOW) for c in range(k): start_parts = VMobject( l_matrix[a][c].copy(), @@ -239,21 +239,21 @@ class NumericalMatrixMultiplication(Scene): self.play( Transform( start_parts, - result_entry.copy().highlight(YELLOW), + result_entry.copy().set_color(YELLOW), path_arc = -np.pi/2, submobject_mode = "all_at_once", ), *lagging_anims ) - result_entry.highlight(YELLOW) + result_entry.set_color(YELLOW) self.remove(start_parts) lagging_anims = [ - ApplyMethod(result_entry.highlight, WHITE) + ApplyMethod(result_entry.set_color, WHITE) ] for c in range(k): - l_matrix[a][c].highlight(WHITE) - r_matrix[c][b].highlight(WHITE) + l_matrix[a][c].set_color(WHITE) + r_matrix[c][b].set_color(WHITE) self.play(FadeOut(circles), *lagging_anims) self.wait() diff --git a/topics/number_line.py b/topics/number_line.py index 3671dbc3..4e005d7b 100644 --- a/topics/number_line.py +++ b/topics/number_line.py @@ -135,7 +135,7 @@ class NumberLine(VMobject): vect = (end - start)/np.linalg.norm(end-start) arrow = Arrow(start, end + MED_SMALL_BUFF*vect, buff = 0) tip = arrow.tip - tip.highlight(self.color) + tip.set_color(self.color) self.tip = tip self.add(tip) diff --git a/topics/objects.py b/topics/objects.py index 3cda2409..8ef74865 100644 --- a/topics/objects.py +++ b/topics/objects.py @@ -173,7 +173,7 @@ class PartyHat(SVGMobject): self.dots = VGroup(*self[self.NUM_FRILLS+1:]) self.frills.gradient_highlight(*self.frills_colors) - self.cone.highlight(self.cone_color) + self.cone.set_color(self.cone_color) self.dots.gradient_highlight(*self.dots_colors) class Laptop(VGroup): diff --git a/topics/probability.py b/topics/probability.py index 36dc35b0..d4179f3d 100644 --- a/topics/probability.py +++ b/topics/probability.py @@ -577,7 +577,7 @@ class PlayingCard(VGroup): self.get_corner(UP+LEFT), DOWN+RIGHT, buff = MED_LARGE_BUFF*width ) - value_mob.highlight(symbol.get_color()) + value_mob.set_color(symbol.get_color()) corner_symbol = symbol.copy() corner_symbol.scale_to_fit_width(width) corner_symbol.next_to( diff --git a/topics/vector_space_scene.py b/topics/vector_space_scene.py index a3724e2b..65da4900 100644 --- a/topics/vector_space_scene.py +++ b/topics/vector_space_scene.py @@ -43,7 +43,7 @@ class VectorScene(Scene): plane = self.add_plane() axes = plane.get_axes() plane.fade(dimness) - axes.highlight(WHITE) + axes.set_color(WHITE) axes.fade(axes_dimness) self.add(axes) self.freeze_background() @@ -98,7 +98,7 @@ class VectorScene(Scene): label = TexMobject(label) if color is None: color = vector.get_color() - label.highlight(color) + label.set_color(color) label.scale(label_scale_factor) label.add_background_rectangle() @@ -122,12 +122,12 @@ class VectorScene(Scene): def position_x_coordinate(self, x_coord, x_line, vector): x_coord.next_to(x_line, -np.sign(vector[1])*UP) - x_coord.highlight(X_COLOR) + x_coord.set_color(X_COLOR) return x_coord def position_y_coordinate(self, y_coord, y_line, vector): y_coord.next_to(y_line, np.sign(vector[0])*RIGHT) - y_coord.highlight(Y_COLOR) + y_coord.set_color(Y_COLOR) return y_coord def coords_to_vector(self, vector, coords_start = 2*RIGHT+2*UP, clean_up = True): @@ -137,8 +137,8 @@ class VectorScene(Scene): arrow = Vector(vector) x_line = Line(ORIGIN, vector[0]*RIGHT) y_line = Line(x_line.get_end(), arrow.get_end()) - x_line.highlight(X_COLOR) - y_line.highlight(Y_COLOR) + x_line.set_color(X_COLOR) + y_line.set_color(Y_COLOR) x_coord, y_coord = array.get_mob_matrix().flatten() self.play(Write(array, run_time = 1)) @@ -175,8 +175,8 @@ class VectorScene(Scene): array = vector_coordinate_label(arrow, integer_labels = integer_labels) x_line = Line(ORIGIN, vector[0]*RIGHT) y_line = Line(x_line.get_end(), arrow.get_end()) - x_line.highlight(X_COLOR) - y_line.highlight(Y_COLOR) + x_line.set_color(X_COLOR) + y_line.set_color(Y_COLOR) x_coord, y_coord = array.get_mob_matrix().flatten() x_coord_start = self.position_x_coordinate( x_coord.copy(), x_line, vector