Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions manim/utils/color/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,9 @@ def __xor__(self, other: Self) -> Self:
self._internal_from_integer(self.to_integer() ^ int(other), 1.0)
)

def __hash__(self) -> int:
return hash(self.to_hex(with_alpha=True))


RGBA = ManimColor
"""RGBA Color Space"""
Expand Down
8 changes: 7 additions & 1 deletion tests/module/utils/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from manim import BLACK, Mobject, Scene, VMobject
from manim import BLACK, RED, WHITE, ManimColor, Mobject, Scene, VMobject


def test_import_color():
Expand Down Expand Up @@ -49,3 +49,9 @@ def test_set_color():
assert m.color.to_hex() == "#FFFFFF"
m.set_color(BLACK)
assert m.color.to_hex() == "#000000"


def test_color_hash():
assert hash(WHITE) == hash(ManimColor([1.0, 1.0, 1.0, 1.0]))
assert hash(WHITE) == hash("#FFFFFFFF")
assert hash(WHITE) != hash(RED)
Loading