Fix set_width for variable stroke width

This commit is contained in:
Grant Sanderson 2023-01-20 21:38:48 -08:00
parent 8e1fdd5a79
commit 9e02796c9a

View file

@ -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):