22
33NEW_BLUE = "#68a8e1"
44
5+
56class Thumbnail (GraphScene ):
67 CONFIG = {
78 "y_max" : 8 ,
@@ -13,13 +14,15 @@ def construct(self):
1314
1415 def show_function_graph (self ):
1516 self .setup_axes (animate = False )
17+
1618 def func (x ):
17- return 0.1 * (x + 3 - 5 ) * (x - 3 - 5 ) * (x - 5 ) + 5
19+ return 0.1 * (x + 3 - 5 ) * (x - 3 - 5 ) * (x - 5 ) + 5
1820
1921 def rect (x ):
20- return 2.775 * (x - 1.5 )+ 3.862
21- recta = self .get_graph (rect ,x_min = - 1 ,x_max = 5 )
22- graph = self .get_graph (func ,x_min = 0.2 ,x_max = 9 )
22+ return 2.775 * (x - 1.5 ) + 3.862
23+
24+ recta = self .get_graph (rect , x_min = - 1 , x_max = 5 )
25+ graph = self .get_graph (func , x_min = 0.2 , x_max = 9 )
2326 graph .set_color (NEW_BLUE )
2427 input_tracker_p1 = ValueTracker (1.5 )
2528 input_tracker_p2 = ValueTracker (3.5 )
@@ -37,29 +40,40 @@ def get_y_point(input_tracker):
3740 return self .coords_to_point (0 , get_y_value (input_tracker ))
3841
3942 def get_graph_point (input_tracker ):
40- return self .coords_to_point (get_x_value (input_tracker ), get_y_value (input_tracker ))
43+ return self .coords_to_point (
44+ get_x_value (input_tracker ), get_y_value (input_tracker )
45+ )
4146
4247 def get_v_line (input_tracker ):
43- return DashedLine (get_x_point (input_tracker ), get_graph_point (input_tracker ), stroke_width = 2 )
48+ return DashedLine (
49+ get_x_point (input_tracker ),
50+ get_graph_point (input_tracker ),
51+ stroke_width = 2 ,
52+ )
4453
4554 def get_h_line (input_tracker ):
46- return DashedLine (get_graph_point (input_tracker ), get_y_point (input_tracker ), stroke_width = 2 )
47- #
55+ return DashedLine (
56+ get_graph_point (input_tracker ),
57+ get_y_point (input_tracker ),
58+ stroke_width = 2 ,
59+ )
60+
61+ #
4862 input_triangle_p1 = RegularPolygon (n = 3 , start_angle = TAU / 4 )
4963 output_triangle_p1 = RegularPolygon (n = 3 , start_angle = 0 )
5064 for triangle in input_triangle_p1 , output_triangle_p1 :
5165 triangle .set_fill (WHITE , 1 )
5266 triangle .set_stroke (width = 0 )
5367 triangle .scale (0.1 )
54- #
68+ #
5569 input_triangle_p2 = RegularPolygon (n = 3 , start_angle = TAU / 4 )
5670 output_triangle_p2 = RegularPolygon (n = 3 , start_angle = 0 )
5771 for triangle in input_triangle_p2 , output_triangle_p2 :
5872 triangle .set_fill (WHITE , 1 )
5973 triangle .set_stroke (width = 0 )
6074 triangle .scale (0.1 )
61-
62- #
75+
76+ #
6377 x_label_p1 = TexMobject ("a" )
6478 output_label_p1 = TexMobject ("f(a)" )
6579 x_label_p2 = TexMobject ("b" )
@@ -83,11 +97,8 @@ def get_h_line(input_tracker):
8397 graph_dot_p1 .move_to (get_graph_point (input_tracker_p1 ))
8498 graph_dot_p2 .move_to (get_graph_point (input_tracker_p2 ))
8599
86-
87100 #
88- self .play (
89- ShowCreation (graph ),
90- )
101+ self .play (ShowCreation (graph ),)
91102 # Animacion del punto a
92103 self .add_foreground_mobject (graph_dot_p1 )
93104 self .add_foreground_mobject (graph_dot_p2 )
@@ -106,7 +117,7 @@ def get_h_line(input_tracker):
106117 ShowCreation (h_line_p2 ),
107118 Write (output_label_p2 ),
108119 DrawBorderThenFill (output_triangle_p2 ),
109- run_time = 0.5
120+ run_time = 0.5 ,
110121 )
111122 self .add (
112123 input_triangle_p2 ,
@@ -119,58 +130,61 @@ def get_h_line(input_tracker):
119130 )
120131 ###################
121132 pendiente_recta = self .get_secant_slope_group (
122- 1.9 , recta , dx = 1.4 ,
123- df_label = None ,
124- dx_label = None ,
125- dx_line_color = PURPLE ,
126- df_line_color = ORANGE ,
127- )
133+ 1.9 ,
134+ recta ,
135+ dx = 1.4 ,
136+ df_label = None ,
137+ dx_label = None ,
138+ dx_line_color = PURPLE ,
139+ df_line_color = ORANGE ,
140+ )
128141 grupo_secante = self .get_secant_slope_group (
129- 1.5 , graph , dx = 2 ,
130- df_label = None ,
131- dx_label = None ,
132- dx_line_color = "#942357" ,
133- df_line_color = "#3f7d5c" ,
134- secant_line_color = RED ,
142+ 1.5 ,
143+ graph ,
144+ dx = 2 ,
145+ df_label = None ,
146+ dx_label = None ,
147+ dx_line_color = "#942357" ,
148+ df_line_color = "#3f7d5c" ,
149+ secant_line_color = RED ,
135150 )
136151
137-
138152 self .add (
139- input_triangle_p2 ,
140- graph_dot_p2 ,
141- v_line_p2 ,
142- h_line_p2 ,
143- output_triangle_p2 ,
153+ input_triangle_p2 , graph_dot_p2 , v_line_p2 , h_line_p2 , output_triangle_p2 ,
144154 )
145155 self .play (FadeIn (grupo_secante ))
146156
147157 kwargs = {
148- "x_min" : 4 ,
149- "x_max" : 9 ,
150- "fill_opacity" : 0.75 ,
151- "stroke_width" : 0.25 ,
158+ "x_min" : 4 ,
159+ "x_max" : 9 ,
160+ "fill_opacity" : 0.75 ,
161+ "stroke_width" : 0.25 ,
152162 }
153- self .graph = graph
154- iteraciones = 6
155-
163+ self .graph = graph
164+ iteraciones = 6
156165
157166 self .rect_list = self .get_riemann_rectangles_list (
158- graph , iteraciones ,start_color = PURPLE ,end_color = ORANGE , ** kwargs
167+ graph , iteraciones , start_color = PURPLE , end_color = ORANGE , ** kwargs
159168 )
160169 flat_rects = self .get_riemann_rectangles (
161- self .get_graph (lambda x : 0 ), dx = 0.5 ,start_color = invert_color (PURPLE ),end_color = invert_color (ORANGE ),** kwargs
170+ self .get_graph (lambda x : 0 ),
171+ dx = 0.5 ,
172+ start_color = invert_color (PURPLE ),
173+ end_color = invert_color (ORANGE ),
174+ ** kwargs
162175 )
163176 rects = self .rect_list [0 ]
164177 self .transform_between_riemann_rects (
165- flat_rects , rects ,
166- replace_mobject_with_target_in_scene = True ,
167- run_time = 0.9
178+ flat_rects , rects , replace_mobject_with_target_in_scene = True , run_time = 0.9
168179 )
169180
170181 # adding manim
171182 picture = Group (* self .mobjects )
172183 picture .scale (0.6 ).to_edge (LEFT , buff = SMALL_BUFF )
173- manim = TextMobject ("Manim" ).set_height (1.5 ) \
174- .next_to (picture , RIGHT ) \
175- .shift (DOWN * 0.7 )
184+ manim = (
185+ TextMobject ("Manim" )
186+ .set_height (1.5 )
187+ .next_to (picture , RIGHT )
188+ .shift (DOWN * 0.7 )
189+ )
176190 self .add (manim )
0 commit comments