Skip to content

Commit

Permalink
add from_tuple and to_tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
themanyfaceddemon committed Jul 28, 2024
1 parent ac0def8 commit 8e2c622
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Code/systems/texture_system/color.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from typing import Tuple


class Color:
__slots__ = ['_r', '_g', '_b', '_a']

Expand Down Expand Up @@ -56,3 +59,10 @@ def __str__(self) -> str:

def __repr__(self) -> str:
return f"Color(r={self.r}, g={self.g}, b={self.b}, a={self.a})"

@staticmethod
def from_tuple(value: Tuple[int, int, int, int]) -> "Color":
return Color(value[0], value[1], value[2], value[3])

def to_tuple(self) -> Tuple[int, int, int, int]:
return (self.r, self.g, self.r, self.a)

0 comments on commit 8e2c622

Please sign in to comment.