We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 79b11d1 commit ba5acdaCopy full SHA for ba5acda
1 file changed
src/pybricks/parameters.py
@@ -112,6 +112,12 @@ def __init__(self, h: Number, s: Number = 100, v: Number = 100):
112
The brightness value.
113
"""
114
115
+ def __setattr__(self, key, value):
116
+ if not hasattr(self, key):
117
+ super().__setattr__(key, value)
118
+ else: # immutable after __init__
119
+ raise AttributeError("Can't modify immutable object attribute: " + key)
120
+
121
def __iter__(self):
122
"""Allows unpacking of the Color instance into h, s, and v."""
123
return iter((self.h, self.s, self.v))
@@ -135,6 +141,11 @@ def __truediv__(self, scale: float) -> Color:
135
141
def __floordiv__(self, scale: int) -> Color:
136
142
return self.__mul__(1 / scale)
137
143
144
+ def __lshift__(self, shift: int) -> Color:
145
+ return self.__rshift__(-shift)
146
147
+ def __rshift__(self, shift: int) -> Color:
148
+ return Color((self.h + shift) % 360, self.s, self.v)
138
149
139
150
Color.NONE = Color(0, 0, 0)
140
151
Color.BLACK = Color(0, 0, 10)
0 commit comments