From 8e2c6220d9b6445836e9526e295538ff5ed64ff8 Mon Sep 17 00:00:00 2001 From: themanyfaceddemon Date: Mon, 29 Jul 2024 00:07:59 +0300 Subject: [PATCH] add from_tuple and to_tuple --- Code/systems/texture_system/color.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Code/systems/texture_system/color.py b/Code/systems/texture_system/color.py index 24e7e74..c362f6c 100644 --- a/Code/systems/texture_system/color.py +++ b/Code/systems/texture_system/color.py @@ -1,3 +1,6 @@ +from typing import Tuple + + class Color: __slots__ = ['_r', '_g', '_b', '_a'] @@ -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)