From 5e49f20294bb9cb178cd1a37cf74c6c53eb45ef4 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 14 Apr 2022 14:37:50 -0700 Subject: [PATCH] Add VMobject.get_highlight --- manimlib/mobject/types/vectorized_mobject.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index f5b47859..bc815fbb 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -349,6 +349,22 @@ class VMobject(Mobject): def get_joint_type(self) -> str: return self.joint_type + def get_highlight( + self, + stroke_color: Color = WHITE, + added_stroke: float = 3.0, + opacity: float = 0.75, + ) -> VMobject: + highlight = self.copy() + highlight.set_fill(opacity=0) + highlight.set_stroke( + color=stroke_color, + width=self.get_stroke_width() + added_stroke, + opacity=opacity + ) + highlight.add_updater(lambda m: m.move_to(self)) + return highlight + # Points def set_anchors_and_handles( self, @@ -681,7 +697,7 @@ class VMobject(Mobject): self.get_end_anchors(), )))) - def get_points_without_null_curves(self, atol: float=1e-9) -> np.ndarray: + def get_points_without_null_curves(self, atol: float = 1e-9) -> np.ndarray: nppc = self.n_points_per_curve points = self.get_points() distinct_curves = reduce(op.or_, [