Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,18 +2108,22 @@ def to_original_color(self) -> Self:
self.set_color(self.color)
return self

def fade_to(
def fade_to_color(
self, color: ParsableManimColor, alpha: float, family: bool = True
) -> Self:
"""Fades the color of the mobject towards the provided color by interpolating the colors.
As long as family is set to True, the submobject's colors are also faded likewise.
"""
if self.get_num_points() > 0:
new_color = interpolate_color(self.get_color(), ManimColor(color), alpha)
self.set_color(new_color, family=False)
if family:
for submob in self.submobjects:
submob.fade_to(color, alpha)
submob.fade_to_color(color, alpha)
return self

def fade(self, darkness: float = 0.5, family: bool = True) -> Self:
"""This method is to be overridden in mobject's subclass"""
if family:
for submob in self.submobjects:
submob.fade(darkness, family)
Expand Down Expand Up @@ -2214,6 +2218,7 @@ def get_points_defining_boundary(self) -> Point3D_Array:
return self.get_all_points()

def get_num_points(self) -> int:
"""Returns the number of points which make up only the mobject, but not it's submobject."""
return len(self.points)

def get_extremum_along_dim(
Expand Down
Loading