-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f97345c
commit 09d9e46
Showing
5 changed files
with
82 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
from systems.texture_system.color import Color | ||
from systems.texture_system.texture_system import TextureSystem | ||
|
||
__all__ = ['Color', 'TextureSystem'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class Color: | ||
__slots__ = ['_r', '_g', '_b', '_a'] | ||
|
||
def __init__(self, r: int, g: int, b: int, a: int) -> None: | ||
self.r = r | ||
self.g = g | ||
self.b = b | ||
self.a = a | ||
|
||
@property | ||
def r(self) -> int: | ||
return self._r | ||
|
||
@r.setter | ||
def r(self, value: int) -> None: | ||
if not (0 <= value <= 255): | ||
raise ValueError("Invalid value for r. It must be between 0 and 255") | ||
|
||
self._r = value | ||
|
||
@property | ||
def g(self) -> int: | ||
return self._g | ||
|
||
@g.setter | ||
def g(self, value: int) -> None: | ||
if not (0 <= value <= 255): | ||
raise ValueError("Invalid value for g. It must be between 0 and 255") | ||
|
||
self._g = value | ||
|
||
@property | ||
def b(self) -> int: | ||
return self._b | ||
|
||
@b.setter | ||
def b(self, value: int) -> None: | ||
if not (0 <= value <= 255): | ||
raise ValueError("Invalid value for b. It must be between 0 and 255") | ||
|
||
self._b = value | ||
|
||
@property | ||
def a(self) -> int: | ||
return self._a | ||
|
||
@a.setter | ||
def a(self, value: int) -> None: | ||
if not (0 <= value <= 255): | ||
raise ValueError("Invalid value for a. It must be between 0 and 255") | ||
|
||
self._a = value | ||
|
||
def __str__(self) -> str: | ||
return f"{self.r}_{self.g}_{self.b}_{self.a}" | ||
|
||
def __repr__(self) -> str: | ||
return f"Color(r={self.r}, g={self.g}, b={self.b}, a={self.a})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters