From 9e02796c9ac3f5c3e6b83ed7bfbed435af55b0ef Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Fri, 20 Jan 2023 21:38:48 -0800 Subject: [PATCH] Fix set_width for variable stroke width --- manimlib/mobject/types/vectorized_mobject.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 35a77a28..75a4b9e8 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -199,9 +199,12 @@ class VMobject(Mobject): if width is not None: for mob in self.get_family(recurse): data = mob.data if mob.get_num_points() > 0 else mob._data_defaults - if not isinstance(width, float | int): - width = resize_with_interpolation(np.array(width), len(data)).flatten() - data['stroke_width'][:, 0] = width + if isinstance(width, float | int): + data['stroke_width'][:, 0] = width + else: + data['stroke_width'][:, 0] = resize_with_interpolation( + np.array(width), len(data) + ).flatten() if background is not None: for mob in self.get_family(recurse):