forked from K0lb3/UnityPy
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathColor.py
More file actions
56 lines (46 loc) · 1.59 KB
/
Copy pathColor.py
File metadata and controls
56 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from dataclasses import dataclass
from .Vector4 import Vector4
@dataclass
class Color:
R: float
G: float
B: float
A: float
def __init__(self, r: float = 0.0, g: float = 0.0, b: float = 0.0, a: float = 0.0):
if not all(isinstance(v, (int, float)) for v in (r, g, b, a)):
raise TypeError("All components must be numeric.")
self.R = r
self.G = g
self.B = b
self.A = a
def __add__(self, other):
return Color(
self.R + other.R, self.G + other.G, self.B + other.B, self.A + other.A
)
def __sub__(self, other):
return Color(
self.R - other.R, self.G - other.G, self.B - other.B, self.A - other.A
)
def __mul__(self, other):
if isinstance(other, Color):
return Color(
self.R * other.R, self.G * other.G, self.B * other.B, self.A * other.A
)
else:
return Color(self.R * other, self.G * other, self.B * other, self.A * other)
def __truediv__(self, other):
if isinstance(other, Color):
return Color(
self.R / other.R, self.G / other.G, self.B / other.B, self.A / other.A
)
else:
return Color(self.R / other, self.G / other, self.B / other, self.A / other)
def __eq__(self, other):
if isinstance(other, Color):
return self.__dict__ == other.__dict__
else:
return False
def __ne__(self, other):
return not (self == other)
def Vector4(self):
return Vector4(self.R, self.G, self.B, self.A)