Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit d506113

Browse files
authored
Merge pull request #12 from DirectiveAthena/4.1.1-proposal
Change: i... now return self (bugfix), use of slots
2 parents 30d651c + 91d5482 commit d506113

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
setuptools.setup(
1616
name="AthenaColor",
17-
version="4.1.0",
17+
version="4.1.1",
1818
author="Andreas Sas",
1919
author_email="",
2020
description="Package to support full usage of RGB colors in the Console.",

src/AthenaColor/Objects/Color/ColorSystem.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def wrapper(self,other:ColorSystem|int|tuple):
3535
# - Actual Color System -
3636
# ----------------------------------------------------------------------------------------------------------------------
3737
class ColorSystem(ABC):
38-
@abstractmethod
3938
def __init__(self, *_):
4039
# no 'ColorSystem' can be created on its own
4140
raise PermissionError
@@ -111,28 +110,36 @@ def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem:
111110

112111
@ _ColorConversionInput
113112
def __iadd__(self, other: ColorSystem|int|tuple) -> ColorSystem:
114-
return self._value_setter(CSD.add(self.export(), other))
113+
self._value_setter(CSD.add(self.export(), other))
114+
return self
115115
@ _ColorConversionInput
116116
def __isub__(self, other: ColorSystem|int|tuple) -> ColorSystem:
117-
return self._value_setter(CSD.sub(self.export(), other))
117+
self._value_setter(CSD.sub(self.export(), other))
118+
return self
118119
@ _ColorConversionInput
119120
def __imul__(self, other: ColorSystem|int|tuple) -> ColorSystem:
120-
return self._value_setter(CSD.mul(self.export(), other))
121+
self._value_setter(CSD.mul(self.export(), other))
122+
return self
121123
@ _ColorConversionInput
122124
def __ifloordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem:
123-
return self._value_setter(CSD.floordiv(self.export(), other))
125+
self._value_setter(CSD.floordiv(self.export(), other))
126+
return self
124127
@ _ColorConversionInput
125128
def __itruediv__(self, other: ColorSystem|int|tuple) -> ColorSystem:
126-
return self._value_setter(CSD.truediv(self.export(), other))
129+
self._value_setter(CSD.truediv(self.export(), other))
130+
return self
127131
@ _ColorConversionInput
128132
def __itruediv__(self, other: ColorSystem|int|tuple) -> ColorSystem:
129-
return self._value_setter(CSD.truediv(self.export(), other))
133+
self._value_setter(CSD.truediv(self.export(), other))
134+
return self
130135
@ _ColorConversionInput
131136
def __imod__(self, other: ColorSystem|int|tuple) -> ColorSystem:
132-
return self._value_setter(CSD.mod(self.export(), other))
137+
self._value_setter(CSD.mod(self.export(), other))
138+
return self
133139
@ _ColorConversionInput
134140
def __ipow__(self, other: ColorSystem|int|tuple) -> ColorSystem:
135-
return self._value_setter(CSD.power(self.export(), other))
141+
self._value_setter(CSD.power(self.export(), other))
142+
return self
136143

137144
# ------------------------------------------------------------------------------------------------------------------
138145
# - Comparison Dunders -
@@ -164,6 +171,8 @@ def __ge__(self, other: ColorSystem|int|float|tuple) -> bool:
164171
# - RGB -
165172
# ------------------------------------------------------------------------------------------------------------------
166173
class RGB(ColorSystem):
174+
__slots__ = "_r","_g","_b"
175+
167176
"""
168177
Color Object for RGB values.
169178
All r,g,b values are integer values which range between 0 and 255, including.
@@ -216,6 +225,8 @@ def __repr__(self) -> str:
216225
# ----------------------------------------------------------------------------------------------------------------------
217226
# inherits from rgb as it is just another notation of the rgb format
218227
class HEX(RGB):
228+
__slots__ = "_r","_g","_b"
229+
219230
"""
220231
Color Object for HEX values.
221232
Inherits from RGB as this is just another notation for RGB values.
@@ -271,6 +282,8 @@ def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem:
271282
# - RGBA -
272283
# ------------------------------------------------------------------------------------------------------------------
273284
class RGBA(ColorSystem):
285+
__slots__ = "_r","_g","_b", "_a"
286+
274287
"""
275288
Color Object for RGBA values.
276289
All r,g,b,a values are integer values which range between 0 and 255, including.
@@ -330,6 +343,8 @@ def __repr__(self) -> str:
330343
# ----------------------------------------------------------------------------------------------------------------------
331344
# inherits from rgba as it is just another notation of the rgb format
332345
class HEXA(RGBA):
346+
__slots__ = "_r","_g","_b", "_a"
347+
333348
"""
334349
Color Object for HEXA values.
335350
Inherits from RGBA as this is just another notation for RGBA values.
@@ -385,6 +400,8 @@ def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem:
385400
# - HSV -
386401
# ------------------------------------------------------------------------------------------------------------------
387402
class HSV(ColorSystem):
403+
__slots__ = "_h","_s","_v"
404+
388405
"""
389406
Color Object for HSV values.
390407
The h value is a float value which ranges between 0 and 360, including.
@@ -437,6 +454,8 @@ def __repr__(self) -> str:
437454
# - HSL -
438455
# ------------------------------------------------------------------------------------------------------------------
439456
class HSL(ColorSystem):
457+
__slots__ = "_h","_s","_l"
458+
440459
"""
441460
Color Object for HSL values.
442461
The h value is a float value which ranges between 0 and 360, including.
@@ -489,6 +508,8 @@ def __repr__(self) -> str:
489508
# - CMYK -
490509
# ----------------------------------------------------------------------------------------------------------------------
491510
class CMYK(ColorSystem):
511+
__slots__ = "_c","_m","_y","_k"
512+
492513
"""
493514
Color Object for CMYK values.
494515
All c,m,y,k values are float values which range between 0 and 1, including

src/AthenaColor/Objects/Console/Styling/Inline/RgbControlled.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@
2323
# - Code -
2424
# ----------------------------------------------------------------------------------------------------------------------
2525
class RgbControlled:
26+
__slots__ = (
27+
"_param_code",
28+
"Maroon","DarkRed","Brown","Firebrick","Crimson","Red","Tomato","Coral","IndianRed","LightCoral","DarkSalmon",
29+
"Salmon","LightSalmon","OrangeRed","DarkOrange","Orange","Gold","DarkGoldenRod","GoldenRod","PaleGoldenRod",
30+
"DarkKhaki","Khaki","Olive","Yellow","YellowGreen","DarkOliveGreen","OliveDrab","LawnGreen","Chartreuse",
31+
"GreenYellow","DarkGreen","Green","ForestGreen","Lime","LimeGreen","LightGreen","PaleGreen","DarkSeaGreen",
32+
"MediumSpringGreen","SpringGreen","SeaGreen","MediumAquaMarine","MediumSeaGreen","LightSeaGreen","DarkSlateGray",
33+
"Teal","DarkCyan","Aqua","Cyan","LightCyan","DarkTurquoise","Turquoise","MediumTurquoise","PaleTurquoise",
34+
"AquaMarine","PowderBlue","CadetBlue","SteelBlue","CornFlowerBlue","DeepSkyBlue","DodgerBlue","LightBlue",
35+
"SkyBlue","LightSkyBlue","MidnightBlue","Navy","DarkBlue","MediumBlue","Blue","RoyalBlue","BlueViolet","Indigo",
36+
"DarkSlateBlue","SlateBlue","MediumSlateBlue","MediumPurple","DarkMagenta","DarkViolet","DarkOrchid","MediumOrchid",
37+
"Purple","Thistle","Plum","Violet","Magenta","Orchid","MediumVioletRed","PaleVioletRed","DeepPink","HotPink",
38+
"LightPink","Pink","AntiqueWhite","Beige","Bisque","BlanchedAlmond","Wheat","CornSilk","LemonChiffon",
39+
"LightGoldenRodYellow","LightYellow","SaddleBrown","Sienna","Chocolate","Peru","SandyBrown","BurlyWood","Tan",
40+
"RosyBrown","Moccasin","NavajoWhite","PeachPuff","MistyRose","LavenderBlush","Linen","OldLace","PapayaWhip",
41+
"WeaShell","MintCream","SlateGray","LightSlateGray","LightSteelBlue","Lavender","FloralWhite","AliceBlue",
42+
"GhostWhite","Honeydew","Ivory","Azure","Snow","Black","DimGray","Gray","DarkGray","Silver","LightGray"
43+
,"Gainsboro","WhiteSmoke","White",
44+
)
2645
def __init__(self, param_code:str):
2746
self._param_code = param_code
2847
self.Maroon = ColorSequence(f"{self._param_code}{str(HtmlColorObjects.Maroon)}")

0 commit comments

Comments
 (0)