add better string representation of color objects
This commit is contained in:
parent
23edb27190
commit
e38bf28abb
1 changed files with 13 additions and 0 deletions
13
utils.py
13
utils.py
|
@ -129,6 +129,9 @@ class Color3i:
|
|||
self.g = g
|
||||
self.b = b
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.__class__.__name__}({self.r}, {self.g}, {self.b})"
|
||||
|
||||
|
||||
class Color4f:
|
||||
"""Color RGBA as float"""
|
||||
|
@ -138,3 +141,13 @@ class Color4f:
|
|||
self.g = g
|
||||
self.b = b
|
||||
self.a = a
|
||||
|
||||
def __str__(self):
|
||||
max_precision = 3
|
||||
|
||||
r = round(self.r, max_precision)
|
||||
g = round(self.g, max_precision)
|
||||
b = round(self.b, max_precision)
|
||||
a = round(self.a, max_precision)
|
||||
|
||||
return f"{self.__class__.__name__}({r}, {g}, {b}, {a})"
|
||||
|
|
Reference in a new issue