From 3a111cf3afa41ca82a447e9f2add535db8a55cbf Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sun, 7 Jun 2020 12:23:35 -0700 Subject: [PATCH] Get rid of this color nonsense --- manimlib/mobject/mobject.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index e9b13d1d..adf2ad97 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -62,7 +62,6 @@ class Mobject(Container): self.submobjects = [] self.parents = [] self.family = [self] - self.color = Color(self.color) if self.name is None: self.name = self.__class__.__name__ self.time_based_updaters = [] @@ -670,19 +669,30 @@ class Mobject(Container): # Color functions - def set_color(self, color=YELLOW_C, family=True): - """ - Condition is function which takes in one arguments, (x, y, z). - Here it just recurses to submobjects, but in subclasses this - should be further implemented based on the the inner workings - of color - """ + def set_color(self, color, family=True): + # Here it just recurses to submobjects, but in subclasses this + # should be further implemented based on the the inner workings + # of color if family: for submob in self.submobjects: submob.set_color(color, family=family) - self.color = color return self + def set_opacity(self, opacity, family=True): + # Here it just recurses to submobjects, but in subclasses this + # should be further implemented based on the the inner workings + # of color + if family: + for submob in self.submobjects: + submob.set_opacity(opacity, family=family) + return self + + def get_color(self): + raise Exception("Not implemented") + + def get_opacity(self): + raise Exception("Not implemented") + def set_color_by_gradient(self, *colors): self.set_submobject_colors_by_gradient(*colors) return self @@ -717,10 +727,6 @@ class Mobject(Container): return self - def to_original_color(self): - self.set_color(self.color) - return self - def fade_to(self, color, alpha, family=True): if self.get_num_points() > 0: new_color = interpolate_color( @@ -738,9 +744,6 @@ class Mobject(Container): submob.fade(darkness, family) return self - def get_color(self): - return self.color - def get_gloss(self): return self.gloss