From ad4ceb3f1a884c99861cea254d7ec6216e3f0022 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 24 Jan 2018 16:09:37 -0800 Subject: [PATCH] A few bits of cleanup --- mobject/vectorized_mobject.py | 4 ++-- topics/geometry.py | 7 ++++--- topics/number_line.py | 13 ++++++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/mobject/vectorized_mobject.py b/mobject/vectorized_mobject.py index 4b1a37e6..2fb398c2 100644 --- a/mobject/vectorized_mobject.py +++ b/mobject/vectorized_mobject.py @@ -100,12 +100,12 @@ class VMobject(Mobject): #match styles accordingly submobs1, submobs2 = self.submobjects, vmobject.submobjects if len(submobs1) == 0: - return + return self elif len(submobs2) == 0: submobs2 = [vmobject] for sm1, sm2 in zip(*make_even(submobs1, submobs2)): sm1.match_style(sm2) - return + return self def fade(self, darkness = 0.5): for submob in self.submobject_family(): diff --git a/topics/geometry.py b/topics/geometry.py index bbbd12a5..3605d8b6 100644 --- a/topics/geometry.py +++ b/topics/geometry.py @@ -97,9 +97,6 @@ class Arc(VMobject): return self - - - class Circle(Arc): CONFIG = { "color" : RED, @@ -511,6 +508,7 @@ class Arrow(Line): Line.put_start_and_end_on(self, *args, **kwargs) self.set_tip_points(self.tip, preserve_normal = False) self.set_rectangular_stem_points() + return self def scale(self, scale_factor, **kwargs): Line.scale(self, scale_factor, **kwargs) @@ -520,6 +518,9 @@ class Arrow(Line): self.set_rectangular_stem_points() return self + def copy(self): + return self.deepcopy() + class Vector(Arrow): CONFIG = { "color" : YELLOW, diff --git a/topics/number_line.py b/topics/number_line.py index 7aa5fa9b..623abf4e 100644 --- a/topics/number_line.py +++ b/topics/number_line.py @@ -200,14 +200,21 @@ class Axes(VGroup): self.y_axis.point_to_number(point), ) - def get_graph(self, function, num_graph_points = None, **kwargs): + def get_graph( + self, function, num_graph_points = None, + x_min = None, + x_max = None, + **kwargs + ): kwargs["fill_opacity"] = kwargs.get("fill_opacity", 0) kwargs["num_anchor_points"] = \ num_graph_points or self.default_num_graph_points + x_min = x_min or self.x_min + x_max = x_max or self.x_max graph = ParametricFunction( lambda t : self.coords_to_point(t, function(t)), - t_min = self.x_min, - t_max = self.x_max, + t_min = x_min, + t_max = x_max, **kwargs ) graph.underlying_function = function