A community-maintained Python framework for creating mathematical animations.
colored triangle indicator in GraphScene
Ben Hambrecht8e7f33c65a15
diff --git a/scene/graph_scene.py b/scene/graph_scene.pyindex 72107241f..a224ba596 100644--- a/scene/graph_scene.py+++ b/scene/graph_scene.py@@ -4,12 +4,13 @@ from constants import *import itertools as itfrom scene.scene import Scene-from animation.creation import Write+from animation.creation import Write, DrawBorderThenFill, ShowCreationfrom animation.transform import Transformfrom animation.update import UpdateFromAlphaFuncfrom mobject.functions import ParametricFunctionfrom mobject.geometry import Linefrom mobject.geometry import Rectangle+from mobject.geometry import RegularPolygonfrom mobject.number_line import NumberLinefrom mobject.svg.tex_mobject import TexMobjectfrom mobject.svg.tex_mobject import TextMobject@@ -438,25 +439,28 @@ class GraphScene(Scene):return group- def add_T_label(self, x_val, **kwargs):+ def add_T_label(self, x_val, color = WHITE, animated = False, **kwargs):triangle = RegularPolygon(n=3, start_angle = np.pi/2)triangle.scale_to_fit_height(MED_SMALL_BUFF)triangle.move_to(self.coords_to_point(x_val, 0), UP)- triangle.set_fill(WHITE, 1)+ triangle.set_fill(color, 1)triangle.set_stroke(width = 0)- T_label = TexMobject(self.variable_point_label)+ T_label = TexMobject(self.variable_point_label, fill_color = color)T_label.next_to(triangle, DOWN)v_line = self.get_vertical_line_to_graph(x_val, self.v_graph,color = YELLOW)- self.play(- DrawBorderThenFill(triangle),- ShowCreation(v_line),- Write(T_label, run_time = 1),- **kwargs- )+ if animated:+ self.play(+ DrawBorderThenFill(triangle),+ ShowCreation(v_line),+ Write(T_label, run_time = 1),+ **kwargs+ )+ else:+ self.add(triangle, v_line, T_label)self.T_label_group = VGroup(T_label, triangle)self.right_v_line = v_line