diff --git a/eoc/chapter1.py b/eoc/chapter1.py index 65869fc9..483bb780 100644 --- a/eoc/chapter1.py +++ b/eoc/chapter1.py @@ -229,59 +229,6 @@ class PatronsOnly(Scene): self.play(Blink(morty)) self.dither() -class OpeningQuote(Scene): - CONFIG = { - "quote" : [ - """The art of doing mathematics is finding - that """, "special case", - """that contains all the - germs of generality.""" - ], - "highlighted_quote_terms" : { - "special case" : BLUE - }, - "author" : "David Hilbert", - "fade_in_kwargs" : { - "submobject_mode" : "lagged_start", - "rate_func" : None, - "lag_factor" : 3, - "run_time" : 5, - }, - } - def construct(self): - quote = self.get_quote() - author = self.get_author(quote) - - self.play(FadeIn(quote, **self.fade_in_kwargs)) - self.dither(2) - self.play(Write(author, run_time = 3)) - self.dither() - - def get_quote(self, max_width = 2*SPACE_WIDTH-1): - if isinstance(self.quote, str): - quote = TextMobject( - "``%s''"%self.quote.strip(), - alignment = "", - ) - else: - words = ["``"] + list(self.quote) + ["''"] - quote = TextMobject(*words, alignment = "") - ##TODO, make less hacky - 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) - quote.to_edge(UP) - if quote.get_width() > max_width: - quote.scale_to_fit_width(max_width) - return quote - - def get_author(self, quote): - author = TextMobject("-" + self.author) - author.next_to(quote, DOWN) - author.highlight(YELLOW) - return author - class Introduction(TeacherStudentsScene): def construct(self): self.show_series() @@ -2570,85 +2517,6 @@ class CalculusInANutshell(CircleScene): ) self.dither() -class PatreonThanks(Scene): - CONFIG = { - "specific_patrons" : [ - "Ali Yahya", - "Cryptic Swarm", - "Juan Batiz-Benet", - "Yu Jun", - "Othman Alikhan", - "Joseph John Cox", - "Luc Ritchie", - "Einar Johansen", - "Rish Kundalia", - "Achille Brighton", - "Kirk Werklund", - "Ripta Pasay", - "Felipe Diniz", - ], - "max_patrons_height" : 2*SPACE_HEIGHT - 1, - } - def construct(self): - morty = Mortimer() - morty.next_to(ORIGIN, DOWN) - - n_patrons = len(self.specific_patrons) - special_thanks = TextMobject("Special thanks") - special_thanks.highlight(YELLOW) - special_thanks.to_edge(UP) - - patreon_logo = PatreonLogo() - patreon_logo.next_to(morty, UP, buff = MED_LARGE_BUFF) - - left_patrons = VGroup(*map(TextMobject, - self.specific_patrons[:n_patrons/2] - )) - right_patrons = VGroup(*map(TextMobject, - self.specific_patrons[n_patrons/2:] - )) - for patrons in left_patrons, right_patrons: - patrons.arrange_submobjects( - DOWN, aligned_edge = LEFT, - buff = 1.5*MED_SMALL_BUFF - ) - all_patrons = VGroup(left_patrons, right_patrons) - if all_patrons.get_height() > self.max_patrons_height: - all_patrons.scale_to_fit_height(self.max_patrons_height) - for patrons, vect in (left_patrons, LEFT), (right_patrons, RIGHT): - patrons.to_edge(vect, buff = MED_SMALL_BUFF) - - # shift_distance = max( - # 0, 1-SPACE_HEIGHT-all_patrons.get_bottom()[1] - # ) - # velocity = shift_distance/8 - # def get_shift_anim(): - # return ApplyMethod( - # all_patrons.shift, velocity*UP, - # rate_func = None - # ) - - self.play( - morty.change_mode, "gracious", - DrawBorderThenFill(patreon_logo) - ) - self.play(Write(special_thanks, run_time = 1)) - self.play( - Write(left_patrons), - morty.look_at, left_patrons - ) - self.play( - Write(right_patrons), - morty.look_at, right_patrons - ) - self.play(Blink(morty)) - for patrons in left_patrons, right_patrons: - for index in 0, -1: - self.play( - morty.look_at, patrons[index], - ) - self.dither() - class Thumbnail(CircleScene): CONFIG = { "radius" : 2, diff --git a/eoc/chapter2.py b/eoc/chapter2.py index ee2f4ba7..6769fa5a 100644 --- a/eoc/chapter2.py +++ b/eoc/chapter2.py @@ -24,7 +24,7 @@ from camera import Camera from mobject.svg_mobject import * from mobject.tex_mobject import * -from eoc.chapter1 import OpeningQuote, PatreonThanks +from topics.common_scenes import OpeningQuote, PatreonThanks from eoc.graph_scene import * DISTANCE_COLOR = BLUE diff --git a/eoc/chapter3.py b/eoc/chapter3.py index bcc9e0e2..cd0fe64d 100644 --- a/eoc/chapter3.py +++ b/eoc/chapter3.py @@ -24,7 +24,8 @@ from camera import Camera from mobject.svg_mobject import * from mobject.tex_mobject import * -from eoc.chapter1 import OpeningQuote, PatreonThanks + +from topics.common_scenes import OpeningQuote, PatreonThanks from eoc.chapter2 import DISTANCE_COLOR, TIME_COLOR, \ VELOCITY_COLOR, Car, MoveCar from eoc.graph_scene import * diff --git a/eoc/chapter4.py b/eoc/chapter4.py index f5e3f82a..4892559e 100644 --- a/eoc/chapter4.py +++ b/eoc/chapter4.py @@ -25,7 +25,8 @@ from camera import Camera from mobject.svg_mobject import * from mobject.tex_mobject import * -from eoc.chapter1 import OpeningQuote, PatreonThanks + +from topics.common_scenes import OpeningQuote, PatreonThanks from eoc.graph_scene import * SINE_COLOR = BLUE diff --git a/old_projects/borsuk.py b/old_projects/borsuk.py index 4b4e2041..faa904e0 100644 --- a/old_projects/borsuk.py +++ b/old_projects/borsuk.py @@ -544,7 +544,7 @@ class SixJewelCase(FiveJewelCase): class DiscussApplicability(TeacherStudentsScene): def construct(self): self.teacher_says(""" - Minize sharding, + Minimize sharding, allocate resources evenly """) self.change_student_modes(*["pondering"]*3) @@ -2413,8 +2413,8 @@ class JewelPairPlane(GraphScene): dot = Dot(point, color = WHITE) coord_pair = TexMobject( "\\big(", - "\\text{Theif %d }"%self.thief_number, "X", ",", - "\\text{Theif %d }"%self.thief_number, "X", + "\\text{Thief %d }"%self.thief_number, "X", ",", + "\\text{Thief %d }"%self.thief_number, "X", "\\big)" ) # coord_pair.scale(1.5) diff --git a/old_projects/efvgt.py b/old_projects/efvgt.py index fa310beb..4564accc 100644 --- a/old_projects/efvgt.py +++ b/old_projects/efvgt.py @@ -26,7 +26,8 @@ from camera import Camera from mobject.svg_mobject import * from mobject.tex_mobject import * -from eoc.chapter1 import PatreonThanks + +from topics.common_scenes import PatreonThanks ADDER_COLOR = GREEN MULTIPLIER_COLOR = YELLOW diff --git a/topics/common_scenes.py b/topics/common_scenes.py new file mode 100644 index 00000000..2ff6fb76 --- /dev/null +++ b/topics/common_scenes.py @@ -0,0 +1,178 @@ + +from helpers import * + +from scene.scene import Scene +from animation.simple_animations import Write, DrawBorderThenFill +from animation.transform import FadeIn +from mobject.vectorized_mobject import VGroup +from mobject.tex_mobject import TexMobject, TextMobject +from topics.characters import Mortimer, Blink +from topics.objects import PatreonLogo + + +class OpeningQuote(Scene): + CONFIG = { + "quote" : [ + """The art of doing mathematics is finding + that """, "special case", + """that contains all the + germs of generality.""" + ], + "highlighted_quote_terms" : { + "special case" : BLUE + }, + "author" : "David Hilbert", + "fade_in_kwargs" : { + "submobject_mode" : "lagged_start", + "rate_func" : None, + "lag_factor" : 3, + "run_time" : 5, + }, + } + def construct(self): + quote = self.get_quote() + author = self.get_author(quote) + + self.play(FadeIn(quote, **self.fade_in_kwargs)) + self.dither(2) + self.play(Write(author, run_time = 3)) + self.dither() + + def get_quote(self, max_width = 2*SPACE_WIDTH-1): + if isinstance(self.quote, str): + quote = TextMobject( + "``%s''"%self.quote.strip(), + alignment = "", + ) + else: + words = ["``"] + list(self.quote) + ["''"] + quote = TextMobject(*words, alignment = "") + ##TODO, make less hacky + 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) + quote.to_edge(UP) + if quote.get_width() > max_width: + quote.scale_to_fit_width(max_width) + return quote + + def get_author(self, quote): + author = TextMobject("-" + self.author) + author.next_to(quote, DOWN) + author.highlight(YELLOW) + return author + +class PatreonThanks(Scene): + CONFIG = { + "specific_patrons" : [ + "Ali Yahya", + "Meshal Alshammari", + "CrypticSwarm ", + "Justin Helps", + "Ankit Agarwal", + "Yu Jun", + "Shelby Doolittle", + "Dave Nicponski", + "Damion Kistler", + "Juan Benet", + "Othman Alikhan", + "Markus Persson", + "Dan Buchoff", + "Derek Dai", + "Joseph John Cox", + "Luc Ritchie", + "Nils Schneider", + "Mathew Bramson", + "Guido Gambardella", + "Jerry Ling", + "Mark Govea", + "Vecht", + "Shimin Kuang", + "Rish Kundalia", + "Achille Brighton", + "Kirk Werklund", + "Ripta Pasay", + "Felipe Diniz", + ], + "max_patrons_height" : 2*SPACE_HEIGHT - 1, + } + def construct(self): + morty = Mortimer() + morty.next_to(ORIGIN, DOWN) + + n_patrons = len(self.specific_patrons) + special_thanks = TextMobject("Special thanks") + special_thanks.highlight(YELLOW) + special_thanks.to_edge(UP) + + patreon_logo = PatreonLogo() + patreon_logo.next_to(morty, UP, buff = MED_LARGE_BUFF) + + left_patrons = VGroup(*map(TextMobject, + self.specific_patrons[:n_patrons/2] + )) + right_patrons = VGroup(*map(TextMobject, + self.specific_patrons[n_patrons/2:] + )) + for patrons in left_patrons, right_patrons: + patrons.arrange_submobjects( + DOWN, aligned_edge = LEFT, + buff = 1.5*MED_SMALL_BUFF + ) + all_patrons = VGroup(left_patrons, right_patrons) + if all_patrons.get_height() > self.max_patrons_height: + all_patrons.scale_to_fit_height(self.max_patrons_height) + for patrons, vect in (left_patrons, LEFT), (right_patrons, RIGHT): + patrons.to_edge(vect, buff = MED_SMALL_BUFF) + + # shift_distance = max( + # 0, 1-SPACE_HEIGHT-all_patrons.get_bottom()[1] + # ) + # velocity = shift_distance/8 + # def get_shift_anim(): + # return ApplyMethod( + # all_patrons.shift, velocity*UP, + # rate_func = None + # ) + + self.play( + morty.change_mode, "gracious", + DrawBorderThenFill(patreon_logo) + ) + self.play(Write(special_thanks, run_time = 1)) + self.play( + Write(left_patrons), + morty.look_at, left_patrons + ) + self.play( + Write(right_patrons), + morty.look_at, right_patrons + ) + self.play(Blink(morty)) + for patrons in left_patrons, right_patrons: + for index in 0, -1: + self.play( + morty.look_at, patrons[index], + ) + self.dither() + + + + + + + + + + + + + + + + + + + +