A community-maintained Python framework for creating mathematical animations.
Merge branch 'lighthouse2' into lighthouse-grant
Grant Sandersonfeac46e83b65
diff --cc active_projects/basel.pyindex 5d72c415b,d85ee9265..6af405deb--- a/active_projects/basel.py+++ b/active_projects/basel.py@@@ -406,7 -406,7 +406,6 @@@ class IntroScene(PiCreatureScene)self.ellipsis = TexMobject("\cdots")self.ellipsis.scale(0.4)--for i in range(5, max_n1):if i == 5:@@@ -421,7 -421,7 +420,6 @@@GrowFromPoint(self.rects[i], self.euler_sum[10].get_center(),run_time = 0.5))--for i in range(max_n1, max_n2):self.play(GrowFromPoint(self.rects[i], self.euler_sum[10].get_center(),@@@ -908,100 -908,42 +906,100 @@@ class SingleLighthouseScene(PiCreatureS### but it doesn't work- def morph_lighthouse_into_sun(self):+class MorphIntoSunScene(PiCreatureScene):+ def construct(self):+ self.setup_elements()+ self.morph_lighthouse_into_sun()- sun_position = [-100,0,0]+ def setup_elements(self):++ self.remove(self.get_primary_pi_creature())++ SCREEN_SIZE = 3.0+ DISTANCE_FROM_LIGHTHOUSE = 10.0+ source_point = [-DISTANCE_FROM_LIGHTHOUSE/2,0,0]+ observer_point = [DISTANCE_FROM_LIGHTHOUSE/2,0,0]++ # Light source++ self.light_source = LightSource(+ opacity_function = inverse_quadratic(1,SPOTLIGHT_SCALE,1),+ num_levels = NUM_LEVELS,+ radius = 10,+ max_opacity_ambient = AMBIENT_FULL,+ max_opacity_spotlight = SPOTLIGHT_FULL,- self.play(- FadeOut(self.angle_arc),- FadeOut(self.angle_indicator))+ self.wait()- self.sun = self.light_source.deepcopy()+ self.light_source.move_source_to(source_point)+++ # Pi Creature++ morty = self.get_primary_pi_creature()+ morty.scale(0.5)+ morty.move_to(observer_point)+ morty.shift(2*OUT)+ self.add_foreground_mobject(morty)- #self.sun.num_levels = NUM_LEVELS,- #self.sun.set_radius(150)- #self.sun.set_max_opacity_ambient(AMBIENT_FULL)+ self.add(self.light_source.lighthouse,self.light_source.ambient_light)+ # Screen- self.sun.spotlight.change_opacity_function(lambda r: 0.5)- self.sun.set_radius(150)- self.sun.move_source_to(sun_position)+ self.screen = Rectangle(+ width = 0.06,+ height = 2,+ mark_paths_closed = True,+ fill_color = WHITE,+ fill_opacity = 1.0,+ stroke_width = 0.0+ )-+ self.screen.next_to(morty,LEFT)++ self.light_source.set_screen(self.screen)+ self.add(self.screen,self.light_source.shadow)++ self.add_foreground_mobject(self.light_source.shadow)+ self.add_foreground_mobject(morty)++ self.light_source.dim_ambient+ self.add(self.light_source.spotlight)- #self.sun.update()+ self.screen_tracker = ScreenTracker(self.light_source)+ self.add(self.screen_tracker)- #self.add(self.sun)self.wait()- # temporarily remove the screen tracker while we move the source- #self.remove(self.screen_tracker)- #print self.sun.spotlight.get_source_point()++ def morph_lighthouse_into_sun(self):++ sun_position = np.array([-100,0,0])+++++ # Why does none of this change the opacity function???++ self.sun = self.light_source.copy()++ self.sun.change_spotlight_opacity_function(lambda r: 0.1)+ # self.sun.spotlight.opacity_function = lambda r: 0.1+ # for submob in self.sun.spotlight.submobjects:+ # submob.set_fill(opacity = 0.1)++ #self.sun.move_source_to(sun_position)+ #self.sun.set_radius(120)++ self.sun.spotlight.generate_points()++ self.wait()self.play(- #self.light_source.spotlight.move_source_to,sun_position,Transform(self.light_source,self.sun))