Fixed affecting colors bug returns copy instead

This commit is contained in:
Tristan Schulz 2023-09-12 23:35:03 +02:00
commit 115bcf968f
2 changed files with 3 additions and 6 deletions

View file

@ -269,8 +269,7 @@ class OpenGLVMobject(OpenGLMobject):
if color is not None:
mob.fill_color = listify(ManimColor.parse(color))
if opacity is not None:
for c in mob.fill_color:
c.set_opacity(opacity)
mob.fill_color = [c.set_opacity(opacity) for c in mob.fill_color]
return self
def set_stroke(
@ -285,8 +284,7 @@ class OpenGLVMobject(OpenGLMobject):
if color is not None:
mob.stroke_color = listify(ManimColor.parse(color))
if opacity is not None:
for c in mob.stroke_color:
c.set_opacity(opacity)
mob.stroke_color = [c.set_opacity(opacity) for c in mob.stroke_color]
if width is not None:
mob.stroke_width = listify(width)

View file

@ -529,8 +529,7 @@ class ManimColor:
"""
if opacity < 0 or opacity > 1:
raise ValueError(f"Alpha value is not in range 0-1 it is {opacity}")
self._internal_value[3] = opacity
return self
return ManimColor(self._internal_value[:3], opacity)
@classmethod
def from_rgb(