add better string representation of color objects

This commit is contained in:
Mylloon 2023-04-03 02:36:54 +02:00
parent 23edb27190
commit e38bf28abb
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -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})"