From bc2db8658748b18306c1193195adbf3b47e05474 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 14:43:44 +0200 Subject: [PATCH 01/40] Feature: ColorSystem bool() --- src/AthenaColor/Objects/Color/ColorSystem.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 16e2161..fa57b3b 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -131,6 +131,12 @@ def export(self) -> tuple: Done to not need specific dunders for each separate color class. """ + def __bool__(self) -> bool: + """ + Returns a True value if all values of the Color System are not 0 + """ + return all(a!=0 for a in self.export()) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ From b66315fa7ff520ab312eb4bee372f9d7af29d44e Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 14:59:59 +0200 Subject: [PATCH 02/40] Fix: Correct repr for HEX values and round() implmentation --- Tests/BulkTests.py | 37 +++++++++++ Tests/ColorObjects/test_Dunders.py | 64 ++++++++++++++++++++ Tests/ColorObjects/test_HEX.py | 2 +- src/AthenaColor/Objects/Color/ColorSystem.py | 17 +++++- 4 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 Tests/BulkTests.py create mode 100644 Tests/ColorObjects/test_Dunders.py diff --git a/Tests/BulkTests.py b/Tests/BulkTests.py new file mode 100644 index 0000000..28830ba --- /dev/null +++ b/Tests/BulkTests.py @@ -0,0 +1,37 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - Package Imports - +# ---------------------------------------------------------------------------------------------------------------------- +# General Packages +from __future__ import annotations +import unittest + +# Custom Library + +# Custom Packages + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +class BulkTests(unittest.TestCase): + def Subtest_Equality(self, ObjectType:type, cases): + for value, result, value_printer in cases: + with self.subTest(ObjectType=ObjectType,value=value, result=result, value_printer=value_printer): + self.assertEqual(ObjectType(value), result) + + def Subtest_Fail(self, ObjectType:type, cases): + for value, error in cases: + with self.subTest(ObjectType=ObjectType,value=value, error=error): + with self.assertRaises(error): + ObjectType(value) + + def Subtest_ObjectOperation(self, ObjectType:type, args:tuple, kwargs:dict, cases): + for operation, oargs, okwargs,result in cases: + with self.subTest(ObjectType=ObjectType, args=args, kwargs=kwargs, oargs=oargs, okwargs=okwargs,result=result, ): + test_object = ObjectType(*args, **kwargs) + self.assertEqual(operation(test_object, *oargs, *okwargs), result) + + def Subtest_ObjectOperationBulk(self, ObjectType:type, cases): + for operation, oargs, okwargs, args, kwargs,result in cases: + with self.subTest(ObjectType=ObjectType, args=args, kwargs=kwargs, operation=operation,oargs=oargs, okwargs=okwargs,result=result, ): + test_object = ObjectType(*args, **kwargs) + self.assertEqual(operation(test_object, *oargs, *okwargs), result) \ No newline at end of file diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py new file mode 100644 index 0000000..a00b868 --- /dev/null +++ b/Tests/ColorObjects/test_Dunders.py @@ -0,0 +1,64 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - Package Imports - +# ---------------------------------------------------------------------------------------------------------------------- +# General Packages +from __future__ import annotations +import unittest + +# Custom Library +from AthenaColor import RGB, RGBA, HEX, HEXA, HSL, HSV, CMYK + +# Custom Packages +from Tests.BulkTests import BulkTests + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +class DunderTesting(BulkTests): + def test_RGB(self): + objectType=RGB + casesOperation=( + #operation oargs okwargs args kwargs result + (str, (), {}, (0,0,0), {}, "0;0;0"), + (repr, (), {}, (0,0,0), {}, "RGB(r=0,g=0,b=0)"), + (round, (), {}, (0,0,0), {}, RGB(0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + ) + + self.Subtest_ObjectOperationBulk(objectType, casesOperation) + + def test_HEX(self): + objectType=HEX + casesOperation=( + #operation oargs okwargs args kwargs result + (str, (), {}, ("#000000",), {}, "#000000"), + (repr, (), {}, ("#000000",), {}, 'HEX(hex_value="#000000")'), + (round, (), {}, ("#000000",), {}, HEX("#000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + ) + + self.Subtest_ObjectOperationBulk(objectType, casesOperation) + + def test_RGBA(self): + objectType=RGBA + casesOperation=( + #operation oargs okwargs args kwargs result + (str, (), {}, (0,0,0), {}, "0;0;0;0"), + (repr, (), {}, (0,0,0), {}, "RGBA(r=0,g=0,b=0,a=0)"), + (round, (), {}, (0,0,0), {}, RGBA(0,0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + ) + + self.Subtest_ObjectOperationBulk(objectType, casesOperation) + + def test_HEXA(self): + objectType=HEXA + casesOperation=( + #operation oargs okwargs args kwargs result + (str, (), {}, ("#00000000",), {}, "#00000000"), + (repr, (), {}, ("#00000000",), {}, 'HEXA(hex_value="#00000000")'), + (round, (), {}, ("#00000000",), {}, HEXA("#00000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + ) + + self.Subtest_ObjectOperationBulk(objectType, casesOperation) + + def test_HSV(self):pass + def test_HSL(self):pass + def test_CMYK(self):pass \ No newline at end of file diff --git a/Tests/ColorObjects/test_HEX.py b/Tests/ColorObjects/test_HEX.py index c1ec73b..e2515ab 100644 --- a/Tests/ColorObjects/test_HEX.py +++ b/Tests/ColorObjects/test_HEX.py @@ -35,7 +35,7 @@ def test_input(self): HEX(**{"hex_value":"#123456","a":1}) def test_repr(self): - self.assertEqual(repr(self.CreateColor()),"HEX(r=32,g=64,b=128)") + self.assertEqual(repr(self.CreateColor()),'HEX(hex_value="#204080")') def test_str(self): self.assertEqual(str(self.CreateColor()),"#204080") diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index fa57b3b..e2b88b5 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -137,6 +137,11 @@ def __bool__(self) -> bool: """ return all(a!=0 for a in self.export()) + def __round__(self, n=None) -> ColorSystem: + """ + Returns a new object, with its values rounded to n + """ + return type(self)(*(round(value,n) for value in self.export())) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @@ -410,7 +415,11 @@ def __str__(self) -> str: return rgb_to_hex(*self.export()) def __repr__(self) -> str: - return f"HEX(r={self.r},g={self.g},b={self.b})" + return f"""HEX(hex_value="{rgb_to_hex(*self.export())}")""" + + # Cast dunders + def __round__(self, n=None): + return type(self)(rgb_to_hex(*(round(value,n) for value in self.export()))) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - @@ -573,7 +582,11 @@ def __str__(self) -> str: return rgba_to_hexa(*self.export()) def __repr__(self) -> str: - return f"HEXA(r={self.r},g={self.g},b={self.b},a={self.a})" + return f"""HEXA(hex_value="{rgba_to_hexa(*self.export())}")""" + + # Cast dunders + def __round__(self, n=None): + return type(self)(rgba_to_hexa(*(round(value,n) for value in self.export()))) # ------------------------------------------------------------------------------------------------------------------ From 0fc91915c85c187a8eec9617128ad674655069b9 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 15:32:20 +0200 Subject: [PATCH 03/40] Feature: bool and divmod --- Tests/ColorObjects/test_Dunders.py | 51 ++++++++++++--- src/AthenaColor/Functions/DunderFunctions.py | 3 + src/AthenaColor/Objects/Color/ColorSystem.py | 69 +++++++++++++------- 3 files changed, 88 insertions(+), 35 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index a00b868..d44d7f1 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -18,12 +18,17 @@ class DunderTesting(BulkTests): def test_RGB(self): objectType=RGB casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, (0,0,0), {}, "0;0;0"), - (repr, (), {}, (0,0,0), {}, "RGB(r=0,g=0,b=0)"), - (round, (), {}, (0,0,0), {}, RGB(0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + #operation oargs okwargs args kwargs result + (str, (), {}, (0,0,0), {}, "0;0;0"), + (repr, (), {}, (0,0,0), {}, "RGB(r=0,g=0,b=0)"), + (round, (), {}, (0,0,0), {}, RGB(0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (bool, (), {}, (0,0,0), {}, False), + (bool, (), {}, (0,0,1), {}, True), + (divmod, (8,), {}, (127,71,54),{}, (RGB(r=15,g=8,b=6), RGB(r=7,g=7,b=6))), + (divmod, ((8,4,2),), {}, (127,71,54),{}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), + (divmod, (RGB(8,4,2),), {}, (127,71,54),{}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), + (divmod, (HSL(180,.5,.5),),{}, (127,71,54),{}, (RGB(r=1,g=0,b=0), RGB(r=63,g=71,b=54))), ) - self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_HEX(self): @@ -34,7 +39,6 @@ def test_HEX(self): (repr, (), {}, ("#000000",), {}, 'HEX(hex_value="#000000")'), (round, (), {}, ("#000000",), {}, HEX("#000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless ) - self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_RGBA(self): @@ -45,7 +49,6 @@ def test_RGBA(self): (repr, (), {}, (0,0,0), {}, "RGBA(r=0,g=0,b=0,a=0)"), (round, (), {}, (0,0,0), {}, RGBA(0,0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless ) - self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_HEXA(self): @@ -56,9 +59,37 @@ def test_HEXA(self): (repr, (), {}, ("#00000000",), {}, 'HEXA(hex_value="#00000000")'), (round, (), {}, ("#00000000",), {}, HEXA("#00000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless ) + self.Subtest_ObjectOperationBulk(objectType, casesOperation) + + def test_HSV(self): + objectType=HSV + casesOperation=( + #operation oargs okwargs args kwargs result + (str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"), + (repr, (), {}, (180,.5,.5), {}, 'HSV(h=180,s=0.5,v=0.5)'), + (round, (), {}, (180,.5,.5), {}, HSV(180,0,0)), + (round, (5,), {}, (180,.123456,.123456),{}, HSV(180,.12346,.12346)), + ) + self.Subtest_ObjectOperationBulk(objectType, casesOperation) + def test_HSL(self): + objectType=HSL + casesOperation=( + #operation oargs okwargs args kwargs result + (str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"), + (repr, (), {}, (180,.5,.5), {}, 'HSL(h=180,s=0.5,l=0.5)'), + (round, (), {}, (180,.5,.5), {}, HSL(180,0,0)), + (round, (5,), {}, (180,.123456,.123456),{}, HSL(180,.12346,.12346)), + ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) - def test_HSV(self):pass - def test_HSL(self):pass - def test_CMYK(self):pass \ No newline at end of file + def test_CMYK(self): + objectType=CMYK + casesOperation=( + #operation oargs okwargs args kwargs result + (str, (), {}, (.5,.5,.5,.5), {}, "0.5;0.5;0.5;0.5"), + (repr, (), {}, (.5,.5,.5,.5), {}, 'CMYK(c=0.5,m=0.5,y=0.5,k=0.5)'), + (round, (), {}, (.5,.5,.5,.5), {}, CMYK(0,0,0,0)), + (round, (5,), {}, (.123456,.123456,.123456,.123456),{},CMYK(.12346,.12346,.12346,.12346)), + ) + self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Functions/DunderFunctions.py b/src/AthenaColor/Functions/DunderFunctions.py index 622b8ff..e185d4f 100644 --- a/src/AthenaColor/Functions/DunderFunctions.py +++ b/src/AthenaColor/Functions/DunderFunctions.py @@ -61,6 +61,9 @@ def power(left:tuple, right:tuple)->tuple: for lr in zip(left, right) ) +def divmod_function(left:tuple, right:tuple)->tuple: + return floordiv(left,right), mod(left,right) + # ---------------------------------------------------------------------------------------------------------------------- # - Comparator Dunders - # ---------------------------------------------------------------------------------------------------------------------- diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index e2b88b5..957c80c 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -135,13 +135,14 @@ def __bool__(self) -> bool: """ Returns a True value if all values of the Color System are not 0 """ - return all(a!=0 for a in self.export()) + return any(color!=0 for color in self.export()) def __round__(self, n=None) -> ColorSystem: """ Returns a new object, with its values rounded to n """ - return type(self)(*(round(value,n) for value in self.export())) + return self.__class__(*(round(value,n) for value in self.export())) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @@ -155,7 +156,7 @@ def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: result = dunder_func(func=CSD.add, left=self, right=other) if result is NotImplemented: return result - return type(self)(*result) + return self.__class__(*result) # noinspection PyTypeChecker def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: @@ -167,7 +168,7 @@ def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: result = dunder_func(func=CSD.sub, left=self, right=other) if result is NotImplemented: return result - return type(self)(*result) + return self.__class__(*result) # noinspection PyTypeChecker def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: @@ -179,7 +180,7 @@ def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: result = dunder_func(func=CSD.mul, left=self, right=other) if result is NotImplemented: return result - return type(self)(*result) + return self.__class__(*result) # noinspection PyTypeChecker def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: @@ -191,7 +192,7 @@ def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: result = dunder_func(func=CSD.floordiv, left=self, right=other) if result is NotImplemented: return result - return type(self)(*result) + return self.__class__(*result) # noinspection PyTypeChecker def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: @@ -203,7 +204,7 @@ def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: result = dunder_func(func=CSD.truediv, left=self, right=other) if result is NotImplemented: return result - return type(self)(*result) + return self.__class__(*result) # noinspection PyTypeChecker def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: @@ -215,7 +216,7 @@ def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: result = dunder_func(func=CSD.mod, left=self, right=other) if result is NotImplemented: return result - return type(self)(*result) + return self.__class__(*result) # noinspection PyTypeChecker def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: @@ -227,7 +228,13 @@ def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: result = dunder_func(func=CSD.power, left=self, right=other) if result is NotImplemented: return result - return type(self)(*result) + return self.__class__(*result) + + def __divmod__(self, other: ColorSystem|int|float|tuple): + result = dunder_func(func=CSD.divmod_function, left=self, right=other) + if result is NotImplemented: + return result + return (*(self.__class__(*colors) for colors in result),) @abstractmethod def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... @@ -419,38 +426,44 @@ def __repr__(self) -> str: # Cast dunders def __round__(self, n=None): - return type(self)(rgb_to_hex(*(round(value,n) for value in self.export()))) + return self.__class__(rgb_to_hex(*(round(value,n) for value in self.export()))) + + def __divmod__(self, other: ColorSystem|int|float|tuple): + result = dunder_func(func=CSD.divmod_function, left=self, right=other) + if result is NotImplemented: + return result + return (*(self.__class__(rgb_to_hex(*colors)) for colors in result),) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ # noinspection PyTypeChecker def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgb_to_hex(*dunder_func(func=CSD.add, left=self, right=other))) + return self.__class__(rgb_to_hex(*dunder_func(func=CSD.add, left=self, right=other))) # noinspection PyTypeChecker def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgb_to_hex(*dunder_func(func=CSD.sub, left=self, right=other))) + return self.__class__(rgb_to_hex(*dunder_func(func=CSD.sub, left=self, right=other))) # noinspection PyTypeChecker def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgb_to_hex(*dunder_func(func=CSD.mul, left=self, right=other))) + return self.__class__(rgb_to_hex(*dunder_func(func=CSD.mul, left=self, right=other))) # noinspection PyTypeChecker def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgb_to_hex(*dunder_func(func=CSD.floordiv, left=self, right=other))) + return self.__class__(rgb_to_hex(*dunder_func(func=CSD.floordiv, left=self, right=other))) # noinspection PyTypeChecker def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgb_to_hex(*dunder_func(func=CSD.truediv, left=self, right=other))) + return self.__class__(rgb_to_hex(*dunder_func(func=CSD.truediv, left=self, right=other))) # noinspection PyTypeChecker def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgb_to_hex(*dunder_func(func=CSD.mod, left=self, right=other))) + return self.__class__(rgb_to_hex(*dunder_func(func=CSD.mod, left=self, right=other))) # noinspection PyTypeChecker def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgb_to_hex(*dunder_func(func=CSD.power, left=self, right=other))) + return self.__class__(rgb_to_hex(*dunder_func(func=CSD.power, left=self, right=other))) # ------------------------------------------------------------------------------------------------------------------ # - RGBA - @@ -586,7 +599,13 @@ def __repr__(self) -> str: # Cast dunders def __round__(self, n=None): - return type(self)(rgba_to_hexa(*(round(value,n) for value in self.export()))) + return self.__class__(rgba_to_hexa(*(round(value,n) for value in self.export()))) + + def __divmod__(self, other: ColorSystem|int|float|tuple): + result = dunder_func(func=CSD.divmod_function, left=self, right=other) + if result is NotImplemented: + return result + return (*(self.__class__(rgba_to_hexa(*colors)) for colors in result),) # ------------------------------------------------------------------------------------------------------------------ @@ -594,31 +613,31 @@ def __round__(self, n=None): # ------------------------------------------------------------------------------------------------------------------ # noinspection PyTypeChecker def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgba_to_hexa(*dunder_func(func=CSD.add, left=self, right=other))) + return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.add, left=self, right=other))) # noinspection PyTypeChecker def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgba_to_hexa(*dunder_func(func=CSD.sub, left=self, right=other))) + return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.sub, left=self, right=other))) # noinspection PyTypeChecker def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgba_to_hexa(*dunder_func(func=CSD.mul, left=self, right=other))) + return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.mul, left=self, right=other))) # noinspection PyTypeChecker def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgba_to_hexa(*dunder_func(func=CSD.floordiv, left=self, right=other))) + return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.floordiv, left=self, right=other))) # noinspection PyTypeChecker def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgba_to_hexa(*dunder_func(func=CSD.truediv, left=self, right=other))) + return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.truediv, left=self, right=other))) # noinspection PyTypeChecker def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgba_to_hexa(*dunder_func(func=CSD.mod, left=self, right=other))) + return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.mod, left=self, right=other))) # noinspection PyTypeChecker def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return type(self)(rgba_to_hexa(*dunder_func(func=CSD.power, left=self, right=other))) + return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.power, left=self, right=other))) # ------------------------------------------------------------------------------------------------------------------ # - HSV - From 6627ec070479673cf9c0ed03d3354649b487f78e Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 16:08:56 +0200 Subject: [PATCH 04/40] Feature: more tests for divmod --- Tests/ColorObjects/test_Dunders.py | 102 +++++++++++++------ src/AthenaColor/Objects/Color/ColorSystem.py | 20 ++-- 2 files changed, 79 insertions(+), 43 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index d44d7f1..b3c4f5f 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -18,16 +18,16 @@ class DunderTesting(BulkTests): def test_RGB(self): objectType=RGB casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, (0,0,0), {}, "0;0;0"), - (repr, (), {}, (0,0,0), {}, "RGB(r=0,g=0,b=0)"), - (round, (), {}, (0,0,0), {}, RGB(0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless - (bool, (), {}, (0,0,0), {}, False), - (bool, (), {}, (0,0,1), {}, True), - (divmod, (8,), {}, (127,71,54),{}, (RGB(r=15,g=8,b=6), RGB(r=7,g=7,b=6))), - (divmod, ((8,4,2),), {}, (127,71,54),{}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), - (divmod, (RGB(8,4,2),), {}, (127,71,54),{}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), - (divmod, (HSL(180,.5,.5),),{}, (127,71,54),{}, (RGB(r=1,g=0,b=0), RGB(r=63,g=71,b=54))), + #operation oargs okwargs args kwargs result + (str, (), {}, (0,0,0), {}, "0;0;0"), + (repr, (), {}, (0,0,0), {}, "RGB(r=0,g=0,b=0)"), + (round, (), {}, (0,0,0), {}, RGB(0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (bool, (), {}, (0,0,0), {}, False), + (bool, (), {}, (0,0,1), {}, True), + (divmod, (8,), {}, (127,71,54), {}, (RGB(r=15,g=8,b=6), RGB(r=7,g=7,b=6))), + (divmod, ((8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), + (divmod, (RGB(8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), + (divmod, (HSL(180,.5,.5),), {}, (127,71,54), {}, (RGB(r=1,g=0,b=0), RGB(r=63,g=71,b=54))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -38,58 +38,94 @@ def test_HEX(self): (str, (), {}, ("#000000",), {}, "#000000"), (repr, (), {}, ("#000000",), {}, 'HEX(hex_value="#000000")'), (round, (), {}, ("#000000",), {}, HEX("#000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (bool, (), {}, ("#000000",), {}, False), + (bool, (), {}, ("#000001",), {}, True), + (divmod, (8,), {}, ("#7f4736",), {}, (HEX("#0f0806"), HEX("#070706"))), + ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_RGBA(self): objectType=RGBA casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, (0,0,0), {}, "0;0;0;0"), - (repr, (), {}, (0,0,0), {}, "RGBA(r=0,g=0,b=0,a=0)"), - (round, (), {}, (0,0,0), {}, RGBA(0,0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + #operation oargs okwargs args kwargs result + (str, (), {}, (0,0,0), {}, "0;0;0;0"), + (repr, (), {}, (0,0,0), {}, "RGBA(r=0,g=0,b=0,a=0)"), + (round, (), {}, (0,0,0), {}, RGBA(0,0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (bool, (), {}, (0,0,0), {}, False), + (bool, (), {}, (0,0,1), {}, True), + (divmod, (8,), {}, (127,71,54,28), {}, (RGBA(r=15,g=8,b=6,a=3), RGBA(r=7,g=7,b=6,a=4))), + (divmod, ((8,4,2,5),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=5), RGBA(r=7,g=3,b=0,a=3))), + (divmod, (RGBA(8,4,2,1),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=28), RGBA(r=7,g=3,b=0,a=0))), + (divmod, (HSL(180,.5,.5),), {}, (127,71,54,28), {}, (RGBA(r=1,g=0,b=0,a=0), RGBA(r=63,g=71,b=54,a=28))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_HEXA(self): objectType=HEXA casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, ("#00000000",), {}, "#00000000"), - (repr, (), {}, ("#00000000",), {}, 'HEXA(hex_value="#00000000")'), - (round, (), {}, ("#00000000",), {}, HEXA("#00000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + #operation oargs okwargs args kwargs result + (str, (), {}, ("#00000000",), {}, "#00000000"), + (repr, (), {}, ("#00000000",), {}, 'HEXA(hex_value="#00000000")'), + (round, (), {}, ("#00000000",), {}, HEXA("#00000000")), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (bool, (), {}, ("#00000000",), {}, False), + (bool, (), {}, ("#00000100",), {}, True), + (divmod, (8,), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f080602"), HEXA(hex_value="#07070602"))), + (divmod, ((8,4,2,5),), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f111b03"), HEXA(hex_value="#07030003"))), + (divmod, (RGBA(8,4,2,1),), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f111b12"), HEXA(hex_value="#07030000"))), + (divmod, (HEXA("#0f111b12"),),{}, ("#7f473612",), {}, (HEXA(hex_value="#08040201"), HEXA(hex_value="#07030000"))), + (divmod, (HSL(180,.5,.5),), {}, ("#7f473612",), {}, (HEXA(hex_value="#01000000"), HEXA(hex_value="#3f473612"))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_HSV(self): objectType=HSV casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"), - (repr, (), {}, (180,.5,.5), {}, 'HSV(h=180,s=0.5,v=0.5)'), - (round, (), {}, (180,.5,.5), {}, HSV(180,0,0)), - (round, (5,), {}, (180,.123456,.123456),{}, HSV(180,.12346,.12346)), + #operation oargs okwargs args kwargs result + (str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"), + (repr, (), {}, (180,.5,.5), {}, 'HSV(h=180,s=0.5,v=0.5)'), + (round, (), {}, (180,.5,.5), {}, HSV(180,0,0)), + (round, (5,), {}, (180,.123456,.123456), {}, HSV(180,.12346,.12346)), + (bool, (), {}, (0,0,0), {}, False), + (bool, (), {}, (0,0,1), {}, True), + (divmod, (8,), {}, (180,.5,.5), {}, (HSV(h=22,s=0.0,v=0.0), HSV(h=4,s=0.5,v=0.5))), + (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), + (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSV(h=9,s=0.0,v=1), HSV(h=0,s=0.5,v=0.004))), + (divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_HSL(self): objectType=HSL casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"), - (repr, (), {}, (180,.5,.5), {}, 'HSL(h=180,s=0.5,l=0.5)'), - (round, (), {}, (180,.5,.5), {}, HSL(180,0,0)), - (round, (5,), {}, (180,.123456,.123456),{}, HSL(180,.12346,.12346)), + #operation oargs okwargs args kwargs result + (str, (), {}, (180,.5,.5), {}, "180;0.5;0.5"), + (repr, (), {}, (180,.5,.5), {}, 'HSL(h=180,s=0.5,l=0.5)'), + (round, (), {}, (180,.5,.5), {}, HSL(180,0,0)), + (round, (5,), {}, (180,.123456,.123456), {}, HSL(180,.12346,.12346)), + (bool, (), {}, (0,0,0), {}, False), + (bool, (), {}, (0,0,1), {}, True), + (divmod, (8,), {}, (180,.5,.5), {}, (HSL(h=22,s=0.0,l=0.0), HSL(h=4,s=0.5,l=0.5))), + (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), + (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSL(h=9,s=0.0,l=1), HSL(h=0,s=0.5,l=0.02))), + (divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) def test_CMYK(self): objectType=CMYK casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, (.5,.5,.5,.5), {}, "0.5;0.5;0.5;0.5"), - (repr, (), {}, (.5,.5,.5,.5), {}, 'CMYK(c=0.5,m=0.5,y=0.5,k=0.5)'), - (round, (), {}, (.5,.5,.5,.5), {}, CMYK(0,0,0,0)), - (round, (5,), {}, (.123456,.123456,.123456,.123456),{},CMYK(.12346,.12346,.12346,.12346)), + #operation oargs okwargs args kwargs result + (str, (), {}, (.5,.5,.5,.5), {}, "0.5;0.5;0.5;0.5"), + (repr, (), {}, (.5,.5,.5,.5), {}, 'CMYK(c=0.5,m=0.5,y=0.5,k=0.5)'), + (round, (), {}, (.5,.5,.5,.5), {}, CMYK(0,0,0,0)), + (round, (5,), {}, (.123456,.123456,.123456,.123456), {}, CMYK(.12346,.12346,.12346,.12346)), + (divmod, ((8,4,2,5),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))), + (divmod, ((.8,.4,.2,.5),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1.0,y=1,k=1.0), CMYK(c=0.5,m=0.1,y=0.1,k=0.0))), + (bool, (), {}, (0,0,0,0), {}, False), + (bool, (), {}, (0,0,0,1), {}, True), + (divmod, (8,), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))), + (divmod, ((8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), + (divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 957c80c..7bda956 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -48,13 +48,13 @@ def map_color(left:ColorSystem,right:ColorSystem) -> tuple: elif isinstance(right,CMYK): return cmyk_to_rgb(*right.export()) elif isinstance(right, (RGBA,HEXA)): - return right.export()[:-1] + return (*right.export()[:-1],) elif isinstance(left, HSL): if isinstance(right, (RGB,HEX)): return rgb_to_hsl(*right.export()) elif isinstance(right,HSL): - return right.export() + return (*right.export(),) elif isinstance(right,HSV): return hsv_to_hsl(*right.export()) elif isinstance(right,CMYK): @@ -68,7 +68,7 @@ def map_color(left:ColorSystem,right:ColorSystem) -> tuple: elif isinstance(right,HSL): return hsl_to_hsv(*right.export()) elif isinstance(right,HSV): - return right.export() + return (*right.export(),) elif isinstance(right,CMYK): return cmyk_to_hsv(*right.export()) elif isinstance(right, (RGBA,HEXA)): @@ -82,21 +82,21 @@ def map_color(left:ColorSystem,right:ColorSystem) -> tuple: elif isinstance(right,HSV): return hsv_to_cmyk(*right.export()) elif isinstance(right,CMYK): - return right.export() + return (*right.export(),) elif isinstance(right, (RGBA,HEXA)): return rgb_to_cmyk(*right.export()[:-1]) elif isinstance(left, (RGBA,HEXA)): if isinstance(right, (RGB,HEX)): - return right.export(), init.transparent_default_float + return (*right.export(), init.transparentDefault[1]) elif isinstance(right,HSL): - return hsl_to_rgb(*right.export()), init.transparent_default_float + return (*hsl_to_rgb(*right.export()), init.transparentDefault[1]) elif isinstance(right,HSV): - return hsv_to_rgb(*right.export()), init.transparent_default_float + return (*hsv_to_rgb(*right.export()), init.transparentDefault[1]) elif isinstance(right,CMYK): - return cmyk_to_rgb(*right.export()), init.transparent_default_float + return (*cmyk_to_rgb(*right.export()), init.transparentDefault[1]) elif isinstance(right, (RGBA,HEXA)): - return right.export() + return (*right.export(),) # If nothing has matched, this will return -> return NotImplemented @@ -133,7 +133,7 @@ def export(self) -> tuple: def __bool__(self) -> bool: """ - Returns a True value if all values of the Color System are not 0 + Returns a True value if any values of the Color System are not 0 """ return any(color!=0 for color in self.export()) From 46ab7eb0ddb12c29ef95824131593b046ec4e2e6 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 16:17:10 +0200 Subject: [PATCH 05/40] feature: int() --- Tests/ColorObjects/test_Dunders.py | 30 +++++++++++++------- src/AthenaColor/Objects/Color/ColorSystem.py | 7 +++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index b3c4f5f..3a53a38 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -28,6 +28,8 @@ def test_RGB(self): (divmod, ((8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), (divmod, (RGB(8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), (divmod, (HSL(180,.5,.5),), {}, (127,71,54), {}, (RGB(r=1,g=0,b=0), RGB(r=63,g=71,b=54))), + (int, (), {}, (127,127,127), {}, 127), + (int, (), {}, (64,25,18), {}, 35), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -48,16 +50,18 @@ def test_HEX(self): def test_RGBA(self): objectType=RGBA casesOperation=( - #operation oargs okwargs args kwargs result - (str, (), {}, (0,0,0), {}, "0;0;0;0"), - (repr, (), {}, (0,0,0), {}, "RGBA(r=0,g=0,b=0,a=0)"), - (round, (), {}, (0,0,0), {}, RGBA(0,0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless - (bool, (), {}, (0,0,0), {}, False), - (bool, (), {}, (0,0,1), {}, True), - (divmod, (8,), {}, (127,71,54,28), {}, (RGBA(r=15,g=8,b=6,a=3), RGBA(r=7,g=7,b=6,a=4))), - (divmod, ((8,4,2,5),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=5), RGBA(r=7,g=3,b=0,a=3))), - (divmod, (RGBA(8,4,2,1),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=28), RGBA(r=7,g=3,b=0,a=0))), - (divmod, (HSL(180,.5,.5),), {}, (127,71,54,28), {}, (RGBA(r=1,g=0,b=0,a=0), RGBA(r=63,g=71,b=54,a=28))), + #operation oargs okwargs args kwargs result + (str, (), {}, (0,0,0), {}, "0;0;0;0"), + (repr, (), {}, (0,0,0), {}, "RGBA(r=0,g=0,b=0,a=0)"), + (round, (), {}, (0,0,0), {}, RGBA(0,0,0,0)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (bool, (), {}, (0,0,0), {}, False), + (bool, (), {}, (0,0,1), {}, True), + (divmod, (8,), {}, (127,71,54,28), {}, (RGBA(r=15,g=8,b=6,a=3), RGBA(r=7,g=7,b=6,a=4))), + (divmod, ((8,4,2,5),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=5), RGBA(r=7,g=3,b=0,a=3))), + (divmod, (RGBA(8,4,2,1),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=28), RGBA(r=7,g=3,b=0,a=0))), + (divmod, (HSL(180,.5,.5),), {}, (127,71,54,28), {}, (RGBA(r=1,g=0,b=0,a=0), RGBA(r=63,g=71,b=54,a=28))), + (int, (), {}, (127,127,127,127), {}, 127), + (int, (), {}, (64,25,18,127), {}, 58), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -92,6 +96,8 @@ def test_HSV(self): (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSV(h=9,s=0.0,v=1), HSV(h=0,s=0.5,v=0.004))), (divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), + (int, (), {}, (180,.5,.5), {}, 60), + (int, (), {}, (289,.25,.145), {}, 96), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -109,6 +115,8 @@ def test_HSL(self): (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSL(h=9,s=0.0,l=1), HSL(h=0,s=0.5,l=0.02))), (divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), + (int, (), {}, (180,.5,.5), {}, 60), + (int, (), {}, (289,.25,.145), {}, 96), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -127,5 +135,7 @@ def test_CMYK(self): (divmod, (8,), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))), (divmod, ((8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), (divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), + (int, (), {}, (.5,.5,.5,.5), {}, 0), + (int, (), {}, (.125,.25,.145,.75), {}, 0), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 7bda956..25969ba 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -143,6 +143,13 @@ def __round__(self, n=None) -> ColorSystem: """ return self.__class__(*(round(value,n) for value in self.export())) + def __int__(self) -> int: + """ + Returns the average value of all Color Elements + """ + values = self.export() + return int(sum(values)/len(values)) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ From a261806a936d3dcbc0f09701db636bbbb3c0f640 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 16:20:48 +0200 Subject: [PATCH 06/40] feature: float() --- Tests/ColorObjects/test_Dunders.py | 10 ++++++++++ src/AthenaColor/Objects/Color/ColorSystem.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index 3a53a38..36268a6 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -30,6 +30,8 @@ def test_RGB(self): (divmod, (HSL(180,.5,.5),), {}, (127,71,54), {}, (RGB(r=1,g=0,b=0), RGB(r=63,g=71,b=54))), (int, (), {}, (127,127,127), {}, 127), (int, (), {}, (64,25,18), {}, 35), + (float, (), {}, (127,127,127), {}, 127), + (float, (), {}, (64,25,18), {}, 35.666666666666664), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -62,6 +64,8 @@ def test_RGBA(self): (divmod, (HSL(180,.5,.5),), {}, (127,71,54,28), {}, (RGBA(r=1,g=0,b=0,a=0), RGBA(r=63,g=71,b=54,a=28))), (int, (), {}, (127,127,127,127), {}, 127), (int, (), {}, (64,25,18,127), {}, 58), + (float, (), {}, (127,127,127,127), {}, 127), + (float, (), {}, (64,25,18,127), {}, 58.5), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -98,6 +102,8 @@ def test_HSV(self): (divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), (int, (), {}, (180,.5,.5), {}, 60), (int, (), {}, (289,.25,.145), {}, 96), + (float, (), {}, (180,.5,.5), {}, 60.333333333333336), + (float, (), {}, (289,.25,.145), {}, 96.46499999999999), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -117,6 +123,8 @@ def test_HSL(self): (divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), (int, (), {}, (180,.5,.5), {}, 60), (int, (), {}, (289,.25,.145), {}, 96), + (float, (), {}, (180,.5,.5), {}, 60.333333333333336), + (float, (), {}, (289,.25,.145), {}, 96.46499999999999), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -137,5 +145,7 @@ def test_CMYK(self): (divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), (int, (), {}, (.5,.5,.5,.5), {}, 0), (int, (), {}, (.125,.25,.145,.75), {}, 0), + (float, (), {}, (.5,.5,.5,.5), {}, 0.5), + (float, (), {}, (.125,.25,.145,.75), {}, 0.3175), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 25969ba..33af478 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -145,10 +145,16 @@ def __round__(self, n=None) -> ColorSystem: def __int__(self) -> int: """ - Returns the average value of all Color Elements + Returns the average value of all Color Elements as an integer value + """ + return int(self.__float__()) + + def __float__(self) -> float: + """ + Returns the average value of all Color Elements as a float value """ values = self.export() - return int(sum(values)/len(values)) + return sum(values)/len(values) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - From 23ba3b3e7473215a5b7f079e3e5b14eb2b29d779 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 16:24:36 +0200 Subject: [PATCH 07/40] feature: iter() --- src/AthenaColor/Objects/Color/ColorSystem.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 33af478..f96c2c4 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -155,6 +155,9 @@ def __float__(self) -> float: """ values = self.export() return sum(values)/len(values) + + def __iter__(self): + return iter(self.export()) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - From 6ab9bd6c7bdc69c0cce47624a8ce1ea7cc42309f Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 16:26:18 +0200 Subject: [PATCH 08/40] feature: sum test --- Tests/ColorObjects/test_Dunders.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index 36268a6..dbafc48 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -32,6 +32,7 @@ def test_RGB(self): (int, (), {}, (64,25,18), {}, 35), (float, (), {}, (127,127,127), {}, 127), (float, (), {}, (64,25,18), {}, 35.666666666666664), + (sum, (), {}, (127,127,127), {}, 381), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) From 1a3034b427431868916bf5bb1efb5493c39f0706 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 16:28:41 +0200 Subject: [PATCH 09/40] feature: len() --- Tests/ColorObjects/test_Dunders.py | 5 +++++ src/AthenaColor/Objects/Color/ColorSystem.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index dbafc48..31c52a2 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -33,6 +33,7 @@ def test_RGB(self): (float, (), {}, (127,127,127), {}, 127), (float, (), {}, (64,25,18), {}, 35.666666666666664), (sum, (), {}, (127,127,127), {}, 381), + (len, (), {}, (127,127,127), {}, 3), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -67,6 +68,7 @@ def test_RGBA(self): (int, (), {}, (64,25,18,127), {}, 58), (float, (), {}, (127,127,127,127), {}, 127), (float, (), {}, (64,25,18,127), {}, 58.5), + (len, (), {}, (64,25,18,127), {}, 4), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -105,6 +107,7 @@ def test_HSV(self): (int, (), {}, (289,.25,.145), {}, 96), (float, (), {}, (180,.5,.5), {}, 60.333333333333336), (float, (), {}, (289,.25,.145), {}, 96.46499999999999), + (len, (), {}, (289,.25,.145), {}, 3), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -126,6 +129,7 @@ def test_HSL(self): (int, (), {}, (289,.25,.145), {}, 96), (float, (), {}, (180,.5,.5), {}, 60.333333333333336), (float, (), {}, (289,.25,.145), {}, 96.46499999999999), + (len, (), {}, (289,.25,.145), {}, 3), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -148,5 +152,6 @@ def test_CMYK(self): (int, (), {}, (.125,.25,.145,.75), {}, 0), (float, (), {}, (.5,.5,.5,.5), {}, 0.5), (float, (), {}, (.125,.25,.145,.75), {}, 0.3175), + (len, (), {}, (.125,.25,.145,.75), {}, 4), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index f96c2c4..47298e9 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -159,6 +159,9 @@ def __float__(self) -> float: def __iter__(self): return iter(self.export()) + def __len__(self): + return len(self.export()) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ From 6f75f15598fece4f6d891434085ace5637f3d292 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 18:29:40 +0200 Subject: [PATCH 10/40] feature: hash() and ColorSystem._value_setter(values) --- Tests/ColorObjects/test_Dunders.py | 10 + src/AthenaColor/Objects/Color/ColorSystem.py | 312 +++++-------------- 2 files changed, 87 insertions(+), 235 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index 31c52a2..221a36f 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -34,6 +34,9 @@ def test_RGB(self): (float, (), {}, (64,25,18), {}, 35.666666666666664), (sum, (), {}, (127,127,127), {}, 381), (len, (), {}, (127,127,127), {}, 3), + (max, (), {}, (52,128,255), {}, 255), + (min, (), {}, (52,128,255), {}, 52), + (hash, (), {}, (52,128,255), {}, 335258822), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -47,6 +50,7 @@ def test_HEX(self): (bool, (), {}, ("#000000",), {}, False), (bool, (), {}, ("#000001",), {}, True), (divmod, (8,), {}, ("#7f4736",), {}, (HEX("#0f0806"), HEX("#070706"))), + (hash, (), {}, ("#000001",), {}, 1105321676), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -69,6 +73,8 @@ def test_RGBA(self): (float, (), {}, (127,127,127,127), {}, 127), (float, (), {}, (64,25,18,127), {}, 58.5), (len, (), {}, (64,25,18,127), {}, 4), + (hash, (), {}, (64,25,18,127), {}, -502044045), + (hash, (), {}, (64,25,18,127), {}, -502044045), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -86,6 +92,7 @@ def test_HEXA(self): (divmod, (RGBA(8,4,2,1),), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f111b12"), HEXA(hex_value="#07030000"))), (divmod, (HEXA("#0f111b12"),),{}, ("#7f473612",), {}, (HEXA(hex_value="#08040201"), HEXA(hex_value="#07030000"))), (divmod, (HSL(180,.5,.5),), {}, ("#7f473612",), {}, (HEXA(hex_value="#01000000"), HEXA(hex_value="#3f473612"))), + (hash, (), {}, ("#00000100",), {}, -855659026), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -108,6 +115,7 @@ def test_HSV(self): (float, (), {}, (180,.5,.5), {}, 60.333333333333336), (float, (), {}, (289,.25,.145), {}, 96.46499999999999), (len, (), {}, (289,.25,.145), {}, 3), + (hash, (), {}, (289,.25,.145), {}, 1367479895), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -130,6 +138,7 @@ def test_HSL(self): (float, (), {}, (180,.5,.5), {}, 60.333333333333336), (float, (), {}, (289,.25,.145), {}, 96.46499999999999), (len, (), {}, (289,.25,.145), {}, 3), + (hash, (), {}, (289,.25,.145), {}, 1367479895), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -153,5 +162,6 @@ def test_CMYK(self): (float, (), {}, (.5,.5,.5,.5), {}, 0.5), (float, (), {}, (.125,.25,.145,.75), {}, 0.3175), (len, (), {}, (.125,.25,.145,.75), {}, 4), + (hash, (), {}, (.125,.25,.145,.75), {}, -629847754), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 47298e9..88b0f0c 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -3,6 +3,7 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations +import math from abc import ABC, abstractmethod from typing import Callable, Tuple # Custom Library @@ -114,7 +115,7 @@ def __str__(self)->str: """ Returns a string with the various color system elements in a ';' separated string. """ - return init.stringSeparation.join(str(c) for c in self.export()) + return init.stringSeparation.join(str(c) for c in self) @abstractmethod def __repr__(self)->str: @@ -131,17 +132,25 @@ def export(self) -> tuple: Done to not need specific dunders for each separate color class. """ + @abstractmethod + def _value_setter(self, values:tuple): + """ + Sets all the object's color system elements. + Used internally in dunder operations. + Done to not need specific dunders for each separate color class. + """ + def __bool__(self) -> bool: """ Returns a True value if any values of the Color System are not 0 """ - return any(color!=0 for color in self.export()) + return any(color!=0 for color in self) def __round__(self, n=None) -> ColorSystem: """ Returns a new object, with its values rounded to n """ - return self.__class__(*(round(value,n) for value in self.export())) + return self.__class__(*(round(value,n) for value in self)) def __int__(self) -> int: """ @@ -162,6 +171,14 @@ def __iter__(self): def __len__(self): return len(self.export()) + def __hash__(self): + return hash(self.export()) + + def __floor__(self): #math.floor + self._value_setter( + *(math.floor(value) for value in self) + ) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @@ -255,20 +272,48 @@ def __divmod__(self, other: ColorSystem|int|float|tuple): return result return (*(self.__class__(*colors) for colors in result),) - @abstractmethod - def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... - @abstractmethod - def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... - @abstractmethod - def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... - @abstractmethod - def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... - @abstractmethod - def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... - @abstractmethod - def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... - @abstractmethod - def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem:... + def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: + values = dunder_func(func=CSD.add, left=self, right=other) + if values is NotImplemented: + return values + self._value_setter(values) + return self + def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: + values = dunder_func(func=CSD.sub, left=self, right=other) + if values is NotImplemented: + return values + self._value_setter(values) + return self + def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: + values = dunder_func(func=CSD.mul, left=self, right=other) + if values is NotImplemented: + return values + self._value_setter(values) + return self + def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: + values = dunder_func(func=CSD.floordiv, left=self, right=other) + if values is NotImplemented: + return values + self._value_setter(values) + return self + def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: + values = dunder_func(func=CSD.truediv, left=self, right=other) + if values is NotImplemented: + return values + self._value_setter(values) + return self + def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: + values = dunder_func(func=CSD.mod, left=self, right=other) + if values is NotImplemented: + return values + self._value_setter(values) + return self + def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: + values = dunder_func(func=CSD.power, left=self, right=other) + if values is NotImplemented: + return values + self._value_setter(values) + return self # ------------------------------------------------------------------------------------------------------------------ # - Comparison Dunders - @@ -338,6 +383,9 @@ def __init__(self,r:int|float=0, g:int|float=0, b:int|float=0): def export(self) -> Tuple[int,int,int]: return self.r,self.g,self.b + def _value_setter(self, values:tuple): + self.r, self.g, self.b = values + # ------------------------------------------------------------------------------------------------------------------ # RGB Properties # ------------------------------------------------------------------------------------------------------------------ @@ -378,49 +426,6 @@ def b(self, value: int|float): def __repr__(self) -> str: return f"RGB(r={self.r},g={self.g},b={self.b})" - def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.add, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b = value - return self - def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.sub, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b = value - return self - def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mul, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b = value - return self - def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.floordiv, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b = value - return self - def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.truediv, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b = value - return self - def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mod, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b = value - return self - def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.power, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b = value - return self - # ---------------------------------------------------------------------------------------------------------------------- # - HEX - # ---------------------------------------------------------------------------------------------------------------------- @@ -501,6 +506,9 @@ def __init__(self,r:int=0, g:int=0, b:int=0, a:int=0): def export(self) -> Tuple[int,int,int,int]: return self.r,self.g,self.b,self.a + def _value_setter(self, values:tuple): + self.r, self.g, self.b = values + # ------------------------------------------------------------------------------------------------------------------ # RGB Properties # ------------------------------------------------------------------------------------------------------------------ @@ -550,49 +558,6 @@ def a(self, value: int|float): def __repr__(self) -> str: return f"RGBA(r={self.r},g={self.g},b={self.b},a={self.a})" - def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.add, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b, self.a = value - return self - def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.sub, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b, self.a = value - return self - def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mul, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b, self.a = value - return self - def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.floordiv, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b, self.a = value - return self - def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.truediv, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b, self.a = value - return self - def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mod, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b, self.a = value - return self - def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.power, left=self, right=other) - if value is NotImplemented: - return value - self.r, self.g, self.b, self.a = value - return self - # ---------------------------------------------------------------------------------------------------------------------- # - Code - @@ -676,6 +641,9 @@ def __init__(self,h: int|float=0.0, s: int|float=0.0, v: int|float=0.0): def export(self) -> Tuple[int|float,int|float,int|float]: return self.h,self.s,self.v + def _value_setter(self, values:tuple): + self.r, self.g, self.b = values + # ------------------------------------------------------------------------------------------------------------------ # RGB Properties # ------------------------------------------------------------------------------------------------------------------ @@ -707,51 +675,6 @@ def v(self, value: int|float): def __repr__(self) -> str: return f"HSV(h={self.h},s={self.s},v={self.v})" - def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.add, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.v = value - return self - def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.sub, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.v = value - return self - def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mul, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.v = value - return self - def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.floordiv, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.v = value - return self - def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.truediv, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.v = value - return self - def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mod, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.v = value - return self - def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.power, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.v = value - return self - - - # ------------------------------------------------------------------------------------------------------------------ # - HSL - # ------------------------------------------------------------------------------------------------------------------ @@ -770,6 +693,9 @@ def __init__(self,h:int|float=0, s:int|float=0, l:int|float=0): def export(self) -> Tuple[int|float,int|float,int|float]: return self.h,self.s,self.l + def _value_setter(self, values:tuple): + self.r, self.g, self.b = values + # ------------------------------------------------------------------------------------------------------------------ # RGB Properties # ------------------------------------------------------------------------------------------------------------------ @@ -801,50 +727,6 @@ def l(self, value: int|float): def __repr__(self) -> str: return f"HSL(h={self.h},s={self.s},l={self.l})" - def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.add, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.l = value - return self - def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.sub, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.l = value - return self - def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mul, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.l = value - return self - def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.floordiv, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.l = value - return self - def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.truediv, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.l = value - return self - def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mod, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.l = value - return self - def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.power, left=self, right=other) - if value is NotImplemented: - return value - self.h,self.s,self.l = value - return self - - # ---------------------------------------------------------------------------------------------------------------------- # - CMYK - # ---------------------------------------------------------------------------------------------------------------------- @@ -862,6 +744,9 @@ def __init__(self, c:int|float=0, m:int|float=0, y:int|float=0, k:int|float=0): def export(self) -> Tuple[int|float,int|float,int|float,int|float]: return self.c,self.m,self.y,self.k + def _value_setter(self, values:tuple): + self.r, self.g, self.b = values + # ------------------------------------------------------------------------------------------------------------------ # CMYK Properties # ------------------------------------------------------------------------------------------------------------------ @@ -899,46 +784,3 @@ def k(self, value: int|float): # String magic methods def __repr__(self) -> str: return f"CMYK(c={self.c},m={self.m},y={self.y},k={self.k})" - - def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.add, left=self, right=other) - if value is NotImplemented: - return value - self.c,self.m,self.y,self.k = value - return self - def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.sub, left=self, right=other) - if value is NotImplemented: - return value - self.c,self.m,self.y,self.k = value - return self - def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mul, left=self, right=other) - if value is NotImplemented: - return value - self.c,self.m,self.y,self.k = value - return self - def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.floordiv, left=self, right=other) - if value is NotImplemented: - return value - self.c,self.m,self.y,self.k = value - return self - def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.truediv, left=self, right=other) - if value is NotImplemented: - return value - self.c,self.m,self.y,self.k = value - return self - def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.mod, left=self, right=other) - if value is NotImplemented: - return value - self.c,self.m,self.y,self.k = value - return self - def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - value = dunder_func(func=CSD.power, left=self, right=other) - if value is NotImplemented: - return value - self.c,self.m,self.y,self.k = value - return self \ No newline at end of file From 11c8e7e53ef5cd6132f17f38fc2062155b11e68a Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 18:38:44 +0200 Subject: [PATCH 11/40] feature: math.floor() and math.ceil() --- Tests/ColorObjects/test_Dunders.py | 12 ++++++ src/AthenaColor/Objects/Color/ColorSystem.py | 39 +++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index 221a36f..d479ac4 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -3,6 +3,8 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations + +import math import unittest # Custom Library @@ -37,6 +39,8 @@ def test_RGB(self): (max, (), {}, (52,128,255), {}, 255), (min, (), {}, (52,128,255), {}, 52), (hash, (), {}, (52,128,255), {}, 335258822), + (math.floor,(), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (math.ceil, (), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -75,6 +79,8 @@ def test_RGBA(self): (len, (), {}, (64,25,18,127), {}, 4), (hash, (), {}, (64,25,18,127), {}, -502044045), (hash, (), {}, (64,25,18,127), {}, -502044045), + (math.floor,(), {}, (64,25,18,127), {}, RGBA(r=64,g=25,b=18,a=127)), + (math.ceil, (), {}, (64,25,18,127), {}, RGBA(r=64,g=25,b=18,a=127)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -116,6 +122,8 @@ def test_HSV(self): (float, (), {}, (289,.25,.145), {}, 96.46499999999999), (len, (), {}, (289,.25,.145), {}, 3), (hash, (), {}, (289,.25,.145), {}, 1367479895), + (math.floor,(), {}, (289,.25,.145), {}, HSV(289,0,0)), + (math.ceil, (), {}, (289,.25,.145), {}, HSV(289,1,1)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -139,6 +147,8 @@ def test_HSL(self): (float, (), {}, (289,.25,.145), {}, 96.46499999999999), (len, (), {}, (289,.25,.145), {}, 3), (hash, (), {}, (289,.25,.145), {}, 1367479895), + (math.floor,(), {}, (289,.25,.145), {}, HSL(289,0,0)), + (math.ceil, (), {}, (289,.25,.145), {}, HSL(289,1,1)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -163,5 +173,7 @@ def test_CMYK(self): (float, (), {}, (.125,.25,.145,.75), {}, 0.3175), (len, (), {}, (.125,.25,.145,.75), {}, 4), (hash, (), {}, (.125,.25,.145,.75), {}, -629847754), + (math.floor,(), {}, (.125,.25,.145,.75), {}, CMYK(0,0,0,0)), + (math.ceil, (), {}, (.125,.25,.145,.75), {}, CMYK(1,1,1,1)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 88b0f0c..c8dacea 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -174,10 +174,17 @@ def __len__(self): def __hash__(self): return hash(self.export()) - def __floor__(self): #math.floor + def __floor__(self) -> ColorSystem: #math.floor self._value_setter( - *(math.floor(value) for value in self) + tuple(math.floor(value) for value in self) ) + return self + + def __ceil__(self) -> ColorSystem: #math.ceil + self._value_setter( + tuple(math.ceil(value) for value in self) + ) + return self # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - @@ -384,6 +391,10 @@ def export(self) -> Tuple[int,int,int]: return self.r,self.g,self.b def _value_setter(self, values:tuple): + if not isinstance(values, tuple): + raise TypeError + elif len(values) != len(self): + raise ValueError self.r, self.g, self.b = values # ------------------------------------------------------------------------------------------------------------------ @@ -507,7 +518,11 @@ def export(self) -> Tuple[int,int,int,int]: return self.r,self.g,self.b,self.a def _value_setter(self, values:tuple): - self.r, self.g, self.b = values + if not isinstance(values, tuple): + raise TypeError + elif len(values) != len(self): + raise ValueError + self.r, self.g, self.b, self.a = values # ------------------------------------------------------------------------------------------------------------------ # RGB Properties @@ -642,7 +657,11 @@ def export(self) -> Tuple[int|float,int|float,int|float]: return self.h,self.s,self.v def _value_setter(self, values:tuple): - self.r, self.g, self.b = values + if not isinstance(values, tuple): + raise TypeError + elif len(values) != len(self): + raise ValueError + self.h,self.s,self.v = values # ------------------------------------------------------------------------------------------------------------------ # RGB Properties @@ -694,7 +713,11 @@ def export(self) -> Tuple[int|float,int|float,int|float]: return self.h,self.s,self.l def _value_setter(self, values:tuple): - self.r, self.g, self.b = values + if not isinstance(values, tuple): + raise TypeError + elif len(values) != len(self): + raise ValueError + self.h,self.s,self.l = values # ------------------------------------------------------------------------------------------------------------------ # RGB Properties @@ -745,7 +768,11 @@ def export(self) -> Tuple[int|float,int|float,int|float,int|float]: return self.c,self.m,self.y,self.k def _value_setter(self, values:tuple): - self.r, self.g, self.b = values + if not isinstance(values, tuple): + raise TypeError + elif len(values) != len(self): + raise ValueError + self.c,self.m,self.y,self.k = values # ------------------------------------------------------------------------------------------------------------------ # CMYK Properties From 34e6ec237ee0104eca768ecc412fe7232144358a Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 18:43:06 +0200 Subject: [PATCH 12/40] feature: abs() --- src/AthenaColor/Objects/Color/ColorSystem.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index c8dacea..8273ac5 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -186,6 +186,9 @@ def __ceil__(self) -> ColorSystem: #math.ceil ) return self + def __abs__(self) -> ColorSystem: + return self.__class__(*(abs(value) for value in self)) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @@ -469,6 +472,9 @@ def __divmod__(self, other: ColorSystem|int|float|tuple): return result return (*(self.__class__(rgb_to_hex(*colors)) for colors in result),) + def __abs__(self) -> ColorSystem: + return self.__class__(rgb_to_hex(*(abs(value) for value in self))) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @@ -606,6 +612,8 @@ def __divmod__(self, other: ColorSystem|int|float|tuple): return result return (*(self.__class__(rgba_to_hexa(*colors)) for colors in result),) + def __abs__(self) -> ColorSystem: + return self.__class__(rgba_to_hexa(*(abs(value) for value in self))) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - From 7dd8cd53c2f2381d2458b3628c7e7a79db5c00d4 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 18:49:39 +0200 Subject: [PATCH 13/40] feature: copy.copy() --- Tests/ColorObjects/test_Dunders.py | 3 ++- src/AthenaColor/Objects/Color/ColorSystem.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index d479ac4..b6b81b0 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -3,7 +3,7 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations - +import copy import math import unittest @@ -41,6 +41,7 @@ def test_RGB(self): (hash, (), {}, (52,128,255), {}, 335258822), (math.floor,(), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless (math.ceil, (), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless + (copy.copy, (), {}, (52,128,255), {}, RGB(52,128,255)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 8273ac5..e70b434 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -189,6 +189,9 @@ def __ceil__(self) -> ColorSystem: #math.ceil def __abs__(self) -> ColorSystem: return self.__class__(*(abs(value) for value in self)) + def __copy__(self): + return eval(repr(self)) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ From 29e5c9a50521126ee86a2858eeb46593e08ca498 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 18:53:27 +0200 Subject: [PATCH 14/40] feature: __contains__ equivalent of "in" --- Tests/ColorObjects/test_Dunders.py | 3 +++ src/AthenaColor/Objects/Color/ColorSystem.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index b6b81b0..ac23e60 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -5,6 +5,7 @@ from __future__ import annotations import copy import math +import operator import unittest # Custom Library @@ -42,6 +43,8 @@ def test_RGB(self): (math.floor,(), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless (math.ceil, (), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless (copy.copy, (), {}, (52,128,255), {}, RGB(52,128,255)), + (operator.contains,(52,), {}, (52,128,255), {}, True), + (operator.contains,(12,), {}, (52,128,255), {}, False), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index e70b434..dd37545 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -192,6 +192,9 @@ def __abs__(self) -> ColorSystem: def __copy__(self): return eval(repr(self)) + def __contains__(self, item): + return item in self.export() + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ From ea09b37b00bda481b4a8997272c4b34c90eb5cdf Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 18:57:44 +0200 Subject: [PATCH 15/40] feature: math.trunc --- src/AthenaColor/Objects/Color/ColorSystem.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index dd37545..d99af45 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -195,6 +195,9 @@ def __copy__(self): def __contains__(self, item): return item in self.export() + def __trunc__(self) -> ColorSystem: + return self.__class__(*(math.trunc(value) for value in self)) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ From 5158e606f1146d5f2cbd12e58a775253504431a6 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 21:19:06 +0200 Subject: [PATCH 16/40] Change: removed not unse ful functions and replaced int() and float() with an .average() method --- Tests/ColorObjects/test_Dunders.py | 35 ------------- src/AthenaColor/Objects/Color/ColorSystem.py | 55 +++----------------- 2 files changed, 7 insertions(+), 83 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index ac23e60..96597b0 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -31,17 +31,10 @@ def test_RGB(self): (divmod, ((8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), (divmod, (RGB(8,4,2),), {}, (127,71,54), {}, (RGB(r=15,g=17,b=27), RGB(r=7,g=3,b=0))), (divmod, (HSL(180,.5,.5),), {}, (127,71,54), {}, (RGB(r=1,g=0,b=0), RGB(r=63,g=71,b=54))), - (int, (), {}, (127,127,127), {}, 127), - (int, (), {}, (64,25,18), {}, 35), - (float, (), {}, (127,127,127), {}, 127), - (float, (), {}, (64,25,18), {}, 35.666666666666664), (sum, (), {}, (127,127,127), {}, 381), - (len, (), {}, (127,127,127), {}, 3), (max, (), {}, (52,128,255), {}, 255), (min, (), {}, (52,128,255), {}, 52), (hash, (), {}, (52,128,255), {}, 335258822), - (math.floor,(), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless - (math.ceil, (), {}, (64,25,18), {}, RGB(r=64,g=25,b=18)), # doesn't really impact the RGB or HEX objects, but exsists nonetheless (copy.copy, (), {}, (52,128,255), {}, RGB(52,128,255)), (operator.contains,(52,), {}, (52,128,255), {}, True), (operator.contains,(12,), {}, (52,128,255), {}, False), @@ -76,15 +69,8 @@ def test_RGBA(self): (divmod, ((8,4,2,5),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=5), RGBA(r=7,g=3,b=0,a=3))), (divmod, (RGBA(8,4,2,1),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=28), RGBA(r=7,g=3,b=0,a=0))), (divmod, (HSL(180,.5,.5),), {}, (127,71,54,28), {}, (RGBA(r=1,g=0,b=0,a=0), RGBA(r=63,g=71,b=54,a=28))), - (int, (), {}, (127,127,127,127), {}, 127), - (int, (), {}, (64,25,18,127), {}, 58), - (float, (), {}, (127,127,127,127), {}, 127), - (float, (), {}, (64,25,18,127), {}, 58.5), - (len, (), {}, (64,25,18,127), {}, 4), (hash, (), {}, (64,25,18,127), {}, -502044045), (hash, (), {}, (64,25,18,127), {}, -502044045), - (math.floor,(), {}, (64,25,18,127), {}, RGBA(r=64,g=25,b=18,a=127)), - (math.ceil, (), {}, (64,25,18,127), {}, RGBA(r=64,g=25,b=18,a=127)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -120,14 +106,7 @@ def test_HSV(self): (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSV(h=9,s=0.0,v=1), HSV(h=0,s=0.5,v=0.004))), (divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), - (int, (), {}, (180,.5,.5), {}, 60), - (int, (), {}, (289,.25,.145), {}, 96), - (float, (), {}, (180,.5,.5), {}, 60.333333333333336), - (float, (), {}, (289,.25,.145), {}, 96.46499999999999), - (len, (), {}, (289,.25,.145), {}, 3), (hash, (), {}, (289,.25,.145), {}, 1367479895), - (math.floor,(), {}, (289,.25,.145), {}, HSV(289,0,0)), - (math.ceil, (), {}, (289,.25,.145), {}, HSV(289,1,1)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -145,14 +124,7 @@ def test_HSL(self): (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSL(h=9,s=0.0,l=1), HSL(h=0,s=0.5,l=0.02))), (divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), - (int, (), {}, (180,.5,.5), {}, 60), - (int, (), {}, (289,.25,.145), {}, 96), - (float, (), {}, (180,.5,.5), {}, 60.333333333333336), - (float, (), {}, (289,.25,.145), {}, 96.46499999999999), - (len, (), {}, (289,.25,.145), {}, 3), (hash, (), {}, (289,.25,.145), {}, 1367479895), - (math.floor,(), {}, (289,.25,.145), {}, HSL(289,0,0)), - (math.ceil, (), {}, (289,.25,.145), {}, HSL(289,1,1)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -171,13 +143,6 @@ def test_CMYK(self): (divmod, (8,), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))), (divmod, ((8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), (divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), - (int, (), {}, (.5,.5,.5,.5), {}, 0), - (int, (), {}, (.125,.25,.145,.75), {}, 0), - (float, (), {}, (.5,.5,.5,.5), {}, 0.5), - (float, (), {}, (.125,.25,.145,.75), {}, 0.3175), - (len, (), {}, (.125,.25,.145,.75), {}, 4), (hash, (), {}, (.125,.25,.145,.75), {}, -629847754), - (math.floor,(), {}, (.125,.25,.145,.75), {}, CMYK(0,0,0,0)), - (math.ceil, (), {}, (.125,.25,.145,.75), {}, CMYK(1,1,1,1)), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index d99af45..5288f98 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -140,6 +140,13 @@ def _value_setter(self, values:tuple): Done to not need specific dunders for each separate color class. """ + def average(self) -> float: + """ + Returns the average value of all Color Elements as a float value + """ + values = self.export() + return sum(values)/len(values) + def __bool__(self) -> bool: """ Returns a True value if any values of the Color System are not 0 @@ -151,19 +158,6 @@ def __round__(self, n=None) -> ColorSystem: Returns a new object, with its values rounded to n """ return self.__class__(*(round(value,n) for value in self)) - - def __int__(self) -> int: - """ - Returns the average value of all Color Elements as an integer value - """ - return int(self.__float__()) - - def __float__(self) -> float: - """ - Returns the average value of all Color Elements as a float value - """ - values = self.export() - return sum(values)/len(values) def __iter__(self): return iter(self.export()) @@ -174,18 +168,6 @@ def __len__(self): def __hash__(self): return hash(self.export()) - def __floor__(self) -> ColorSystem: #math.floor - self._value_setter( - tuple(math.floor(value) for value in self) - ) - return self - - def __ceil__(self) -> ColorSystem: #math.ceil - self._value_setter( - tuple(math.ceil(value) for value in self) - ) - return self - def __abs__(self) -> ColorSystem: return self.__class__(*(abs(value) for value in self)) @@ -195,9 +177,6 @@ def __copy__(self): def __contains__(self, item): return item in self.export() - def __trunc__(self) -> ColorSystem: - return self.__class__(*(math.trunc(value) for value in self)) - # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @@ -403,10 +382,6 @@ def export(self) -> Tuple[int,int,int]: return self.r,self.g,self.b def _value_setter(self, values:tuple): - if not isinstance(values, tuple): - raise TypeError - elif len(values) != len(self): - raise ValueError self.r, self.g, self.b = values # ------------------------------------------------------------------------------------------------------------------ @@ -533,10 +508,6 @@ def export(self) -> Tuple[int,int,int,int]: return self.r,self.g,self.b,self.a def _value_setter(self, values:tuple): - if not isinstance(values, tuple): - raise TypeError - elif len(values) != len(self): - raise ValueError self.r, self.g, self.b, self.a = values # ------------------------------------------------------------------------------------------------------------------ @@ -674,10 +645,6 @@ def export(self) -> Tuple[int|float,int|float,int|float]: return self.h,self.s,self.v def _value_setter(self, values:tuple): - if not isinstance(values, tuple): - raise TypeError - elif len(values) != len(self): - raise ValueError self.h,self.s,self.v = values # ------------------------------------------------------------------------------------------------------------------ @@ -730,10 +697,6 @@ def export(self) -> Tuple[int|float,int|float,int|float]: return self.h,self.s,self.l def _value_setter(self, values:tuple): - if not isinstance(values, tuple): - raise TypeError - elif len(values) != len(self): - raise ValueError self.h,self.s,self.l = values # ------------------------------------------------------------------------------------------------------------------ @@ -785,10 +748,6 @@ def export(self) -> Tuple[int|float,int|float,int|float,int|float]: return self.c,self.m,self.y,self.k def _value_setter(self, values:tuple): - if not isinstance(values, tuple): - raise TypeError - elif len(values) != len(self): - raise ValueError self.c,self.m,self.y,self.k = values # ------------------------------------------------------------------------------------------------------------------ From 23989f810e381e2f7724a822386492501d208d6b Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 21:21:50 +0200 Subject: [PATCH 17/40] Fix: Unused import --- src/AthenaColor/Objects/Color/ColorSystem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 5288f98..2aec723 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -3,7 +3,6 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations -import math from abc import ABC, abstractmethod from typing import Callable, Tuple # Custom Library From 6bb9e64d33b7b8dfe3f798108725330336564ac5 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 21:22:42 +0200 Subject: [PATCH 18/40] Fix: unused import and __all__ completion --- Tests/ColorObjects/test_ColorTupleConversions.py | 1 - Tests/ColorObjects/test_Dunders.py | 2 -- src/AthenaColor/Objects/Color/ColorTupleConversion.py | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Tests/ColorObjects/test_ColorTupleConversions.py b/Tests/ColorObjects/test_ColorTupleConversions.py index 4fa7c95..3d3cbf9 100644 --- a/Tests/ColorObjects/test_ColorTupleConversions.py +++ b/Tests/ColorObjects/test_ColorTupleConversions.py @@ -7,7 +7,6 @@ # Custom Library from AthenaColor.Objects.Color.ColorTupleConversion import * -from AthenaColor.Objects.Color.ColorTupleConversion import NormalizeRgb # Custom Packages # ---------------------------------------------------------------------------------------------------------------------- diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index 96597b0..5467fb4 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -4,9 +4,7 @@ # General Packages from __future__ import annotations import copy -import math import operator -import unittest # Custom Library from AthenaColor import RGB, RGBA, HEX, HEXA, HSL, HSV, CMYK diff --git a/src/AthenaColor/Objects/Color/ColorTupleConversion.py b/src/AthenaColor/Objects/Color/ColorTupleConversion.py index 67783cd..680d7a5 100644 --- a/src/AthenaColor/Objects/Color/ColorTupleConversion.py +++ b/src/AthenaColor/Objects/Color/ColorTupleConversion.py @@ -22,7 +22,7 @@ __all__ = [ "hsl_to_hsv","hsv_to_hsl","hex_to_hsl","hsl_to_hex","hex_to_hsv","hsv_to_hex","rgb_to_hsl","hsl_to_rgb", "rgb_to_hsv","hsv_to_rgb","hsv_to_cmyk","cmyk_to_hsv","cmyk_to_hsl","hsl_to_cmyk","hex_to_cmyk","cmyk_to_hex", - "rgb_to_cmyk","cmyk_to_rgb","hex_to_rgb","hexa_to_rgba","rgba_to_hexa","rgb_to_hex" + "rgb_to_cmyk","cmyk_to_rgb","hex_to_rgb","hexa_to_rgba","rgba_to_hexa","rgb_to_hex", "NormalizeRgb" ] # ---------------------------------------------------------------------------------------------------------------------- From f21d86403c10f25855e1886f423ed0bdf74482c7 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 21:55:46 +0200 Subject: [PATCH 19/40] Change: map_color uses dictionary instead of long if statementr --- src/AthenaColor/Objects/Color/ColorSystem.py | 239 +++++++------------ 1 file changed, 86 insertions(+), 153 deletions(-) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 2aec723..0223f70 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -37,69 +37,12 @@ def dunder_func(func:Callable,left:ColorSystem,right:ColorSystem|int|float|tuple else: return NotImplemented -def map_color(left:ColorSystem,right:ColorSystem) -> tuple: - if isinstance(left, (RGB,HEX,)): - if isinstance(right, (RGB,HEX)): - return right.export() - elif isinstance(right,HSL): - return hsl_to_rgb(*right.export()) - elif isinstance(right,HSV): - return hsv_to_rgb(*right.export()) - elif isinstance(right,CMYK): - return cmyk_to_rgb(*right.export()) - elif isinstance(right, (RGBA,HEXA)): - return (*right.export()[:-1],) - - elif isinstance(left, HSL): - if isinstance(right, (RGB,HEX)): - return rgb_to_hsl(*right.export()) - elif isinstance(right,HSL): - return (*right.export(),) - elif isinstance(right,HSV): - return hsv_to_hsl(*right.export()) - elif isinstance(right,CMYK): - return cmyk_to_hsl(*right.export()) - elif isinstance(right, (RGBA,HEXA)): - return rgb_to_hsl(*right.export()[:-1]) - - elif isinstance(left, HSV): - if isinstance(right, (RGB,HEX)): - return rgb_to_hsv(*right.export()) - elif isinstance(right,HSL): - return hsl_to_hsv(*right.export()) - elif isinstance(right,HSV): - return (*right.export(),) - elif isinstance(right,CMYK): - return cmyk_to_hsv(*right.export()) - elif isinstance(right, (RGBA,HEXA)): - return rgb_to_hsv(*right.export()[:-1]) - - elif isinstance(left, CMYK): - if isinstance(right, (RGB,HEX)): - return rgb_to_cmyk(*right.export()) - elif isinstance(right,HSL): - return hsl_to_cmyk(*right.export()) - elif isinstance(right,HSV): - return hsv_to_cmyk(*right.export()) - elif isinstance(right,CMYK): - return (*right.export(),) - elif isinstance(right, (RGBA,HEXA)): - return rgb_to_cmyk(*right.export()[:-1]) - - elif isinstance(left, (RGBA,HEXA)): - if isinstance(right, (RGB,HEX)): - return (*right.export(), init.transparentDefault[1]) - elif isinstance(right,HSL): - return (*hsl_to_rgb(*right.export()), init.transparentDefault[1]) - elif isinstance(right,HSV): - return (*hsv_to_rgb(*right.export()), init.transparentDefault[1]) - elif isinstance(right,CMYK): - return (*cmyk_to_rgb(*right.export()), init.transparentDefault[1]) - elif isinstance(right, (RGBA,HEXA)): - return (*right.export(),) - - # If nothing has matched, this will return -> - return NotImplemented +def map_color(left,right) -> tuple: + try: + a = color_conversions_mapped[type(left)][type(right)] + return a(right) + except KeyError: + return NotImplemented # ---------------------------------------------------------------------------------------------------------------------- # - Actual Color System - @@ -111,51 +54,25 @@ def __init__(self, *_): raise PermissionError def __str__(self)->str: - """ - Returns a string with the various color system elements in a ';' separated string. - """ return init.stringSeparation.join(str(c) for c in self) @abstractmethod - def __repr__(self)->str: - """ - Returns a string, starting with the name of the class, followed by the various elements. - example: 'RGB(r=255,g=255,b=255)' - """ + def __repr__(self)->str:... @abstractmethod - def export(self) -> tuple: - """ - Returns all the object's color system elements. - Used internally in dunder operations. - Done to not need specific dunders for each separate color class. - """ + def export(self) -> tuple:... @abstractmethod - def _value_setter(self, values:tuple): - """ - Sets all the object's color system elements. - Used internally in dunder operations. - Done to not need specific dunders for each separate color class. - """ + def _value_setter(self, values:tuple):... def average(self) -> float: - """ - Returns the average value of all Color Elements as a float value - """ values = self.export() return sum(values)/len(values) def __bool__(self) -> bool: - """ - Returns a True value if any values of the Color System are not 0 - """ return any(color!=0 for color in self) def __round__(self, n=None) -> ColorSystem: - """ - Returns a new object, with its values rounded to n - """ return self.__class__(*(round(value,n) for value in self)) def __iter__(self): @@ -167,9 +84,6 @@ def __len__(self): def __hash__(self): return hash(self.export()) - def __abs__(self) -> ColorSystem: - return self.__class__(*(abs(value) for value in self)) - def __copy__(self): return eval(repr(self)) @@ -179,12 +93,14 @@ def __contains__(self, item): # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ + # ! Math Dunder which executes an operator between the left- and right-hand side of the operation. + # The returned object will be a new instance of the left-hand object's class. + # If the two sides of the operation are NOT of the same type, + # it will convert the right-hand object to the same type as the left-hand type. + # noinspection PyTypeChecker def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: """ - Math Dunder which executes an ADDITION operator between the left- and right-hand side of the operation. - The returned object will be a new instance of the left-hand object's class. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. """ result = dunder_func(func=CSD.add, left=self, right=other) if result is NotImplemented: @@ -193,11 +109,6 @@ def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: # noinspection PyTypeChecker def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - """ - Math Dunder which executes an SUBTRACTION operator between the left- and right-hand side of the operation. - The returned object will be a new instance of the left-hand object's class. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ result = dunder_func(func=CSD.sub, left=self, right=other) if result is NotImplemented: return result @@ -205,11 +116,6 @@ def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: # noinspection PyTypeChecker def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - """ - Math Dunder which executes an MULTIPLICATION operator between the left- and right-hand side of the operation. - The returned object will be a new instance of the left-hand object's class. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ result = dunder_func(func=CSD.mul, left=self, right=other) if result is NotImplemented: return result @@ -217,11 +123,6 @@ def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: # noinspection PyTypeChecker def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - """ - Math Dunder which executes an FLOOR DIVISION operator between the left- and right-hand side of the operation. - The returned object will be a new instance of the left-hand object's class. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ result = dunder_func(func=CSD.floordiv, left=self, right=other) if result is NotImplemented: return result @@ -229,11 +130,6 @@ def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: # noinspection PyTypeChecker def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - """ - Math Dunder which executes an DIVISION operator between the left- and right-hand side of the operation. - The returned object will be a new instance of the left-hand object's class. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ result = dunder_func(func=CSD.truediv, left=self, right=other) if result is NotImplemented: return result @@ -241,11 +137,6 @@ def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: # noinspection PyTypeChecker def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - """ - Math Dunder which executes an MODULO operator between the left- and right-hand side of the operation. - The returned object will be a new instance of the left-hand object's class. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ result = dunder_func(func=CSD.mod, left=self, right=other) if result is NotImplemented: return result @@ -253,11 +144,6 @@ def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: # noinspection PyTypeChecker def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - """ - Math Dunder which executes an POWER operator between the left- and right-hand side of the operation. - The returned object will be a new instance of the left-hand object's class. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ result = dunder_func(func=CSD.power, left=self, right=other) if result is NotImplemented: return result @@ -267,7 +153,7 @@ def __divmod__(self, other: ColorSystem|int|float|tuple): result = dunder_func(func=CSD.divmod_function, left=self, right=other) if result is NotImplemented: return result - return (*(self.__class__(*colors) for colors in result),) + return self.__class__(*result[0]), self.__class__(*result[1]) def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: values = dunder_func(func=CSD.add, left=self, right=other) @@ -315,52 +201,32 @@ def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: # ------------------------------------------------------------------------------------------------------------------ # - Comparison Dunders - # ------------------------------------------------------------------------------------------------------------------ + # ! Comparison Dunder which executes an operator between the left- and right-hand side of the operation. + # If the two sides of the operation are NOT of the same type, + # it will convert the right-hand object to the same type as the left-hand type. + # noinspection PyTypeChecker def __gt__(self, other: ColorSystem|int|float|tuple) -> bool: - """ - Comparison Dunder which compares for GREATER THAN. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ return dunder_func(func=CSD.gt,left=self,right=other) # noinspection PyTypeChecker def __lt__(self, other: ColorSystem|int|float|tuple) -> bool: - """ - Comparison Dunder which compares for SMALLER THAN. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ return dunder_func(func=CSD.lt,left=self,right=other) # noinspection PyTypeChecker def __eq__(self, other: ColorSystem|int|float|tuple) -> bool: - """ - Comparison Dunder which compares for EQUALITY. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ return dunder_func(func=CSD.eq,left=self,right=other) # noinspection PyTypeChecker def __ne__(self, other: ColorSystem|int|float|tuple) -> bool: - """ - Comparison Dunder which compares for INEQUALITY. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ return dunder_func(func=CSD.ne,left=self,right=other) # noinspection PyTypeChecker def __le__(self, other: ColorSystem|int|float|tuple) -> bool: - """ - Comparison Dunder which compares for SMALLER OR EQUAL TO. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ return dunder_func(func=CSD.le,left=self,right=other) # noinspection PyTypeChecker def __ge__(self, other: ColorSystem|int|float|tuple) -> bool: - """ - Comparison Dunder which compares for GREATER OR EQUAL TO. - If the two sides of the operation are NOT of the same type, it will convert the right-hand object to the same type as the left-hand type. - """ return dunder_func(func=CSD.ge,left=self,right=other) # ------------------------------------------------------------------------------------------------------------------ @@ -786,3 +652,70 @@ def k(self, value: int|float): # String magic methods def __repr__(self) -> str: return f"CMYK(c={self.c},m={self.m},y={self.y},k={self.k})" + +# needs to be placed here, as only after all the defining of all the colors, this map can be made +color_conversions_mapped ={ + RGB : { + RGB: lambda r: r.export(), + HEX: lambda r: r.export(), + HSL: lambda r: hsl_to_rgb(*r.export()), + HSV: lambda r: hsv_to_rgb(*r.export()), + CMYK: lambda r: cmyk_to_rgb(*r.export()), + RGBA: lambda r: (*r.export()[:-1],), + HEXA: lambda r: (*r.export()[:-1],), + }, + HEX : { + RGB: lambda r: r.export(), + HEX: lambda r: r.export(), + HSL: lambda r: hsl_to_rgb(*r.export()), + HSV: lambda r: hsv_to_rgb(*r.export()), + CMYK: lambda r: cmyk_to_rgb(*r.export()), + RGBA: lambda r: (*r.export()[:-1],), + HEXA: lambda r: (*r.export()[:-1],), + }, + HSL : { + RGB: lambda r: rgb_to_hsl(*r.export()), + HEX: lambda r: rgb_to_hsl(*r.export()), + HSL: lambda r: r.export(), + HSV: lambda r: hsv_to_hsl(*r.export()), + CMYK: lambda r: cmyk_to_hsl(*r.export()), + RGBA: lambda r: rgb_to_hsl(*r.export()[:-1]), + HEXA: lambda r: rgb_to_hsl(*r.export()[:-1]), + }, + HSV : { + RGB: lambda r: rgb_to_hsv(*r.export()), + HEX: lambda r: rgb_to_hsv(*r.export()), + HSL: lambda r: hsl_to_hsv(*r.export()), + HSV: lambda r: r.export(), + CMYK: lambda r: cmyk_to_hsv(*r.export()), + RGBA: lambda r: rgb_to_hsv(*r.export()[:-1]), + HEXA: lambda r: rgb_to_hsv(*r.export()[:-1]), + }, + CMYK : { + RGB: lambda r: rgb_to_cmyk(*r.export()), + HEX: lambda r: rgb_to_cmyk(*r.export()), + HSL: lambda r: hsl_to_cmyk(*r.export()), + HSV: lambda r: hsv_to_cmyk(*r.export()), + CMYK: lambda r: r.export(), + RGBA: lambda r: rgb_to_cmyk(*r.export()[:-1]), + HEXA: lambda r: rgb_to_cmyk(*r.export()[:-1]), + }, + RGBA : { + RGB: lambda r: (*r.export(), init.transparentDefault[1]), + HEX: lambda r: (*r.export(), init.transparentDefault[1]), + HSL: lambda r: (*hsl_to_rgb(*r.export()), init.transparentDefault[1]), + HSV: lambda r: (*hsv_to_rgb(*r.export()), init.transparentDefault[1]), + CMYK: lambda r: (*cmyk_to_rgb(*r.export()), init.transparentDefault[1]), + RGBA: lambda r: r.export(), + HEXA: lambda r: r.export(), + }, + HEXA : { + RGB: lambda r: (*r.export(), init.transparentDefault[1]), + HEX: lambda r: (*r.export(), init.transparentDefault[1]), + HSL: lambda r: (*hsl_to_rgb(*r.export()), init.transparentDefault[1]), + HSV: lambda r: (*hsv_to_rgb(*r.export()), init.transparentDefault[1]), + CMYK: lambda r: (*cmyk_to_rgb(*r.export()), init.transparentDefault[1]), + RGBA: lambda r: r.export(), + HEXA: lambda r: r.export(), + }, +} \ No newline at end of file From 3bd180c8f80e36930ae9db1c37b0be7acfc76483 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 22:31:51 +0200 Subject: [PATCH 20/40] Fix: Removed hash test, as they differ from version to version --- Tests/ColorObjects/test_Dunders.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index 5467fb4..b8b6b46 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -32,7 +32,6 @@ def test_RGB(self): (sum, (), {}, (127,127,127), {}, 381), (max, (), {}, (52,128,255), {}, 255), (min, (), {}, (52,128,255), {}, 52), - (hash, (), {}, (52,128,255), {}, 335258822), (copy.copy, (), {}, (52,128,255), {}, RGB(52,128,255)), (operator.contains,(52,), {}, (52,128,255), {}, True), (operator.contains,(12,), {}, (52,128,255), {}, False), @@ -49,7 +48,6 @@ def test_HEX(self): (bool, (), {}, ("#000000",), {}, False), (bool, (), {}, ("#000001",), {}, True), (divmod, (8,), {}, ("#7f4736",), {}, (HEX("#0f0806"), HEX("#070706"))), - (hash, (), {}, ("#000001",), {}, 1105321676), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -67,8 +65,6 @@ def test_RGBA(self): (divmod, ((8,4,2,5),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=5), RGBA(r=7,g=3,b=0,a=3))), (divmod, (RGBA(8,4,2,1),), {}, (127,71,54,28), {}, (RGBA(r=15,g=17,b=27,a=28), RGBA(r=7,g=3,b=0,a=0))), (divmod, (HSL(180,.5,.5),), {}, (127,71,54,28), {}, (RGBA(r=1,g=0,b=0,a=0), RGBA(r=63,g=71,b=54,a=28))), - (hash, (), {}, (64,25,18,127), {}, -502044045), - (hash, (), {}, (64,25,18,127), {}, -502044045), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -86,7 +82,6 @@ def test_HEXA(self): (divmod, (RGBA(8,4,2,1),), {}, ("#7f473612",), {}, (HEXA(hex_value="#0f111b12"), HEXA(hex_value="#07030000"))), (divmod, (HEXA("#0f111b12"),),{}, ("#7f473612",), {}, (HEXA(hex_value="#08040201"), HEXA(hex_value="#07030000"))), (divmod, (HSL(180,.5,.5),), {}, ("#7f473612",), {}, (HEXA(hex_value="#01000000"), HEXA(hex_value="#3f473612"))), - (hash, (), {}, ("#00000100",), {}, -855659026), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -104,7 +99,6 @@ def test_HSV(self): (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSV(h=9,s=0.0,v=1), HSV(h=0,s=0.5,v=0.004))), (divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), - (hash, (), {}, (289,.25,.145), {}, 1367479895), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -122,7 +116,6 @@ def test_HSL(self): (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSL(h=9,s=0.0,l=1), HSL(h=0,s=0.5,l=0.02))), (divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), - (hash, (), {}, (289,.25,.145), {}, 1367479895), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -141,6 +134,5 @@ def test_CMYK(self): (divmod, (8,), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))), (divmod, ((8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), (divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), - (hash, (), {}, (.125,.25,.145,.75), {}, -629847754), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file From 51ba90673e757191e9ec77481cec7732fea3b611 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 22:51:11 +0200 Subject: [PATCH 21/40] Change: Speed increase --- src/AthenaColor/Objects/Color/ColorSystem.py | 67 +++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 0223f70..554728a 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -653,69 +653,74 @@ def k(self, value: int|float): def __repr__(self) -> str: return f"CMYK(c={self.c},m={self.m},y={self.y},k={self.k})" +# BELOW HERE IS FOR SPEED INCREASE! +# Possible because we now have a __hash__ on any given ColorSystem class # needs to be placed here, as only after all the defining of all the colors, this map can be made +_r_export = lambda r: r.export() +_r_export_slice = lambda r: r.export() +trnspDef = init.transparentDefault[1] color_conversions_mapped ={ RGB : { - RGB: lambda r: r.export(), - HEX: lambda r: r.export(), + RGB: _r_export, + HEX: _r_export, HSL: lambda r: hsl_to_rgb(*r.export()), HSV: lambda r: hsv_to_rgb(*r.export()), CMYK: lambda r: cmyk_to_rgb(*r.export()), - RGBA: lambda r: (*r.export()[:-1],), - HEXA: lambda r: (*r.export()[:-1],), + RGBA: _r_export_slice, + HEXA: _r_export_slice, }, HEX : { - RGB: lambda r: r.export(), - HEX: lambda r: r.export(), + RGB: _r_export, + HEX: _r_export, HSL: lambda r: hsl_to_rgb(*r.export()), HSV: lambda r: hsv_to_rgb(*r.export()), CMYK: lambda r: cmyk_to_rgb(*r.export()), - RGBA: lambda r: (*r.export()[:-1],), - HEXA: lambda r: (*r.export()[:-1],), + RGBA: _r_export_slice, + HEXA: _r_export_slice, }, HSL : { RGB: lambda r: rgb_to_hsl(*r.export()), HEX: lambda r: rgb_to_hsl(*r.export()), - HSL: lambda r: r.export(), + HSL: _r_export, HSV: lambda r: hsv_to_hsl(*r.export()), CMYK: lambda r: cmyk_to_hsl(*r.export()), - RGBA: lambda r: rgb_to_hsl(*r.export()[:-1]), - HEXA: lambda r: rgb_to_hsl(*r.export()[:-1]), + RGBA: lambda r: rgb_to_hsl(*_r_export_slice(r)), + HEXA: lambda r: rgb_to_hsl(*_r_export_slice(r)), }, HSV : { RGB: lambda r: rgb_to_hsv(*r.export()), HEX: lambda r: rgb_to_hsv(*r.export()), HSL: lambda r: hsl_to_hsv(*r.export()), - HSV: lambda r: r.export(), + HSV: _r_export, CMYK: lambda r: cmyk_to_hsv(*r.export()), - RGBA: lambda r: rgb_to_hsv(*r.export()[:-1]), - HEXA: lambda r: rgb_to_hsv(*r.export()[:-1]), + RGBA: lambda r: rgb_to_hsv(*_r_export_slice(r)), + HEXA: lambda r: rgb_to_hsv(*_r_export_slice(r)), }, CMYK : { RGB: lambda r: rgb_to_cmyk(*r.export()), HEX: lambda r: rgb_to_cmyk(*r.export()), HSL: lambda r: hsl_to_cmyk(*r.export()), HSV: lambda r: hsv_to_cmyk(*r.export()), - CMYK: lambda r: r.export(), - RGBA: lambda r: rgb_to_cmyk(*r.export()[:-1]), - HEXA: lambda r: rgb_to_cmyk(*r.export()[:-1]), + CMYK: _r_export, + RGBA: lambda r: rgb_to_cmyk(*_r_export_slice(r)), + HEXA: lambda r: rgb_to_cmyk(*_r_export_slice(r)), }, RGBA : { - RGB: lambda r: (*r.export(), init.transparentDefault[1]), - HEX: lambda r: (*r.export(), init.transparentDefault[1]), - HSL: lambda r: (*hsl_to_rgb(*r.export()), init.transparentDefault[1]), - HSV: lambda r: (*hsv_to_rgb(*r.export()), init.transparentDefault[1]), - CMYK: lambda r: (*cmyk_to_rgb(*r.export()), init.transparentDefault[1]), - RGBA: lambda r: r.export(), - HEXA: lambda r: r.export(), + RGB: lambda r: (*r.export(), trnspDef), + HEX: lambda r: (*r.export(), trnspDef), + HSL: lambda r: (*hsl_to_rgb(*r.export()), trnspDef), + HSV: lambda r: (*hsv_to_rgb(*r.export()), trnspDef), + CMYK: lambda r: (*cmyk_to_rgb(*r.export()), trnspDef), + RGBA: _r_export, + HEXA: _r_export, }, HEXA : { - RGB: lambda r: (*r.export(), init.transparentDefault[1]), - HEX: lambda r: (*r.export(), init.transparentDefault[1]), - HSL: lambda r: (*hsl_to_rgb(*r.export()), init.transparentDefault[1]), - HSV: lambda r: (*hsv_to_rgb(*r.export()), init.transparentDefault[1]), - CMYK: lambda r: (*cmyk_to_rgb(*r.export()), init.transparentDefault[1]), - RGBA: lambda r: r.export(), - HEXA: lambda r: r.export(), + RGB: lambda r: (*r.export(), trnspDef), + HEX: lambda r: (*r.export(), trnspDef), + HSL: lambda r: (*hsl_to_rgb(*r.export()), trnspDef), + HSV: lambda r: (*hsv_to_rgb(*r.export()), trnspDef), + CMYK: lambda r: (*cmyk_to_rgb(*r.export()), trnspDef), + RGBA: _r_export, + HEXA: _r_export, }, } \ No newline at end of file From ab68c7042077bb0989bc19c96816af7716b78555 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 22:56:35 +0200 Subject: [PATCH 22/40] Feature: Test for speed --- Tests/SpeedTest.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Tests/SpeedTest.py diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py new file mode 100644 index 0000000..7228d58 --- /dev/null +++ b/Tests/SpeedTest.py @@ -0,0 +1,36 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - Package Imports - +# ---------------------------------------------------------------------------------------------------------------------- +# General Packages +from __future__ import annotations + +# Custom Library +from AthenaColor import * +import timeit + +# Custom Packages + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +def Conversion(): + RGB(255, 255, 255) - CMYK(.1, .1, .1, .1) + +def ConversionInline(): + a = RGB(255, 255, 255) + a -= CMYK(.1, .1, .1, .1) + +if __name__ == '__main__': + print( + "Conversion: ", + ForeNest.Red( + timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5) + ) + ) + + print( + "ConversionInline: ", + ForeNest.Red( + timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5) + ) + ) \ No newline at end of file From 93081ac0e422a2d6c10e11e0dda701be96855f2c Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 23:16:41 +0200 Subject: [PATCH 23/40] Speed: No Strict Type on defined colors --- Tests/SpeedTest.py | 30 +- .../Styling/Nested/RgbControlledNest.py | 292 +++++++++--------- 2 files changed, 167 insertions(+), 155 deletions(-) diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py index 7228d58..5960650 100644 --- a/Tests/SpeedTest.py +++ b/Tests/SpeedTest.py @@ -20,17 +20,21 @@ def ConversionInline(): a = RGB(255, 255, 255) a -= CMYK(.1, .1, .1, .1) +def TextInline(): + a = f"{Fore.Red}SOMETHING{Style.NoForeground}" + b = f"{Style.Bold}Bold{Style.NoBold}" + c = f"{Back.Blue}I'M BLUE{Style.NoBackground}" + return a,b,c + +def TextNested(): + a = ForeNest.Red("SOMETHING") + b = StyleNest.Bold("Bold") + c = BackNest.Blue("I'M BLUE") + return a,b,c + if __name__ == '__main__': - print( - "Conversion: ", - ForeNest.Red( - timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5) - ) - ) - - print( - "ConversionInline: ", - ForeNest.Red( - timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5) - ) - ) \ No newline at end of file + # print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") + # print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") + print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") + print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") + diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py index 11e9cce..8e5a541 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py @@ -8,7 +8,7 @@ # Custom Library # Custom Packages -from AthenaColor.Objects.Color.ColorSystem import RGB,HEX +from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence from AthenaColor.Data.HtmlColors import HtmlColorObjects as HtmlColors from AthenaColor.Functions.General import StrictType @@ -40,13 +40,21 @@ def custom(self,*obj, color:RGB|HEX, **kwargs) -> str: reset_code=self._reset, **kwargs ) + def _partialmethod(self,*obj, color:RGB|HEX, **kwargs) -> str: + # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' + return NestedColorSequence( + *obj, + control_code=f"{self._param_code}{color.r};{color.g};{color.b}", + reset_code=self._reset, + **kwargs + ) def rgb(self,*obj, r:int,g:int,b:int, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - color = RGB(r, g, b) + r,g,b = NormalizeRgb(r, g, b) return NestedColorSequence( *obj, - control_code=f"{self._param_code}{color.r};{color.g};{color.b}", + control_code=f"{self._param_code}{r};{g};{b}", reset_code=self._reset, **kwargs ) @@ -54,142 +62,142 @@ def rgb(self,*obj, r:int,g:int,b:int, **kwargs) -> str: # ------------------------------------------------------------------------------------------------------------------ # - HTML colors - # ------------------------------------------------------------------------------------------------------------------ - Maroon = partialmethod(custom, color=HtmlColors.Maroon) - DarkRed = partialmethod(custom, color=HtmlColors.DarkRed) - Brown = partialmethod(custom, color=HtmlColors.Brown) - Firebrick = partialmethod(custom, color=HtmlColors.Firebrick) - Crimson = partialmethod(custom, color=HtmlColors.Crimson) - Red = partialmethod(custom, color=HtmlColors.Red) - Tomato = partialmethod(custom, color=HtmlColors.Tomato) - Coral = partialmethod(custom, color=HtmlColors.Coral) - IndianRed = partialmethod(custom, color=HtmlColors.IndianRed) - LightCoral = partialmethod(custom, color=HtmlColors.LightCoral) - DarkSalmon = partialmethod(custom, color=HtmlColors.DarkSalmon) - Salmon = partialmethod(custom, color=HtmlColors.Salmon) - LightSalmon = partialmethod(custom, color=HtmlColors.LightSalmon) - OrangeRed = partialmethod(custom, color=HtmlColors.OrangeRed) - DarkOrange = partialmethod(custom, color=HtmlColors.DarkOrange) - Orange = partialmethod(custom, color=HtmlColors.Orange) - Gold = partialmethod(custom, color=HtmlColors.Gold) - DarkGoldenRod = partialmethod(custom, color=HtmlColors.DarkGoldenRod) - GoldenRod = partialmethod(custom, color=HtmlColors.GoldenRod) - PaleGoldenRod = partialmethod(custom, color=HtmlColors.PaleGoldenRod) - DarkKhaki = partialmethod(custom, color=HtmlColors.DarkKhaki) - Khaki = partialmethod(custom, color=HtmlColors.Khaki) - Olive = partialmethod(custom, color=HtmlColors.Olive) - Yellow = partialmethod(custom, color=HtmlColors.Yellow) - YellowGreen = partialmethod(custom, color=HtmlColors.YellowGreen) - DarkOliveGreen = partialmethod(custom, color=HtmlColors.DarkOliveGreen) - OliveDrab = partialmethod(custom, color=HtmlColors.OliveDrab) - LawnGreen = partialmethod(custom, color=HtmlColors.LawnGreen) - Chartreuse = partialmethod(custom, color=HtmlColors.Chartreuse) - GreenYellow = partialmethod(custom, color=HtmlColors.GreenYellow) - DarkGreen = partialmethod(custom, color=HtmlColors.DarkGreen) - Green = partialmethod(custom, color=HtmlColors.Green) - ForestGreen = partialmethod(custom, color=HtmlColors.ForestGreen) - Lime = partialmethod(custom, color=HtmlColors.Lime) - LimeGreen = partialmethod(custom, color=HtmlColors.LimeGreen) - LightGreen = partialmethod(custom, color=HtmlColors.LightGreen) - PaleGreen = partialmethod(custom, color=HtmlColors.PaleGreen) - DarkSeaGreen = partialmethod(custom, color=HtmlColors.DarkSeaGreen) - MediumSpringGreen = partialmethod(custom, color=HtmlColors.MediumSpringGreen) - SpringGreen = partialmethod(custom, color=HtmlColors.SpringGreen) - SeaGreen = partialmethod(custom, color=HtmlColors.SeaGreen) - MediumAquaMarine = partialmethod(custom, color=HtmlColors.MediumAquaMarine) - MediumSeaGreen = partialmethod(custom, color=HtmlColors.MediumSeaGreen) - LightSeaGreen = partialmethod(custom, color=HtmlColors.LightSeaGreen) - DarkSlateGray = partialmethod(custom, color=HtmlColors.DarkSlateGray) - Teal = partialmethod(custom, color=HtmlColors.Teal) - DarkCyan = partialmethod(custom, color=HtmlColors.DarkCyan) - Aqua = partialmethod(custom, color=HtmlColors.Aqua) - Cyan = partialmethod(custom, color=HtmlColors.Cyan) - LightCyan = partialmethod(custom, color=HtmlColors.LightCyan) - DarkTurquoise = partialmethod(custom, color=HtmlColors.DarkTurquoise) - Turquoise = partialmethod(custom, color=HtmlColors.Turquoise) - MediumTurquoise = partialmethod(custom, color=HtmlColors.MediumTurquoise) - PaleTurquoise = partialmethod(custom, color=HtmlColors.PaleTurquoise) - AquaMarine = partialmethod(custom, color=HtmlColors.AquaMarine) - PowderBlue = partialmethod(custom, color=HtmlColors.PowderBlue) - CadetBlue = partialmethod(custom, color=HtmlColors.CadetBlue) - SteelBlue = partialmethod(custom, color=HtmlColors.SteelBlue) - CornFlowerBlue = partialmethod(custom, color=HtmlColors.CornFlowerBlue) - DeepSkyBlue = partialmethod(custom, color=HtmlColors.DeepSkyBlue) - DodgerBlue = partialmethod(custom, color=HtmlColors.DodgerBlue) - LightBlue = partialmethod(custom, color=HtmlColors.LightBlue) - SkyBlue = partialmethod(custom, color=HtmlColors.SkyBlue) - LightSkyBlue = partialmethod(custom, color=HtmlColors.LightSkyBlue) - MidnightBlue = partialmethod(custom, color=HtmlColors.MidnightBlue) - Navy = partialmethod(custom, color=HtmlColors.Navy) - DarkBlue = partialmethod(custom, color=HtmlColors.DarkBlue) - MediumBlue = partialmethod(custom, color=HtmlColors.MediumBlue) - Blue = partialmethod(custom, color=HtmlColors.Blue) - RoyalBlue = partialmethod(custom, color=HtmlColors.RoyalBlue) - BlueViolet = partialmethod(custom, color=HtmlColors.BlueViolet) - Indigo = partialmethod(custom, color=HtmlColors.Indigo) - DarkSlateBlue = partialmethod(custom, color=HtmlColors.DarkSlateBlue) - SlateBlue = partialmethod(custom, color=HtmlColors.SlateBlue) - MediumSlateBlue = partialmethod(custom, color=HtmlColors.MediumSlateBlue) - MediumPurple = partialmethod(custom, color=HtmlColors.MediumPurple) - DarkMagenta = partialmethod(custom, color=HtmlColors.DarkMagenta) - DarkViolet = partialmethod(custom, color=HtmlColors.DarkViolet) - DarkOrchid = partialmethod(custom, color=HtmlColors.DarkOrchid) - MediumOrchid = partialmethod(custom, color=HtmlColors.MediumOrchid) - Purple = partialmethod(custom, color=HtmlColors.Purple) - Thistle = partialmethod(custom, color=HtmlColors.Thistle) - Plum = partialmethod(custom, color=HtmlColors.Plum) - Violet = partialmethod(custom, color=HtmlColors.Violet) - Magenta = partialmethod(custom, color=HtmlColors.Magenta) - Orchid = partialmethod(custom, color=HtmlColors.Orchid) - MediumVioletRed = partialmethod(custom, color=HtmlColors.MediumVioletRed) - PaleVioletRed = partialmethod(custom, color=HtmlColors.PaleVioletRed) - DeepPink = partialmethod(custom, color=HtmlColors.DeepPink) - HotPink = partialmethod(custom, color=HtmlColors.HotPink) - LightPink = partialmethod(custom, color=HtmlColors.LightPink) - Pink = partialmethod(custom, color=HtmlColors.Pink) - AntiqueWhite = partialmethod(custom, color=HtmlColors.AntiqueWhite) - Beige = partialmethod(custom, color=HtmlColors.Beige) - Bisque = partialmethod(custom, color=HtmlColors.Bisque) - BlanchedAlmond = partialmethod(custom, color=HtmlColors.BlanchedAlmond) - Wheat = partialmethod(custom, color=HtmlColors.Wheat) - CornSilk = partialmethod(custom, color=HtmlColors.CornSilk) - LemonChiffon = partialmethod(custom, color=HtmlColors.LemonChiffon) - LightGoldenRodYellow= partialmethod(custom, color=HtmlColors.LightGoldenRodYellow) - LightYellow = partialmethod(custom, color=HtmlColors.LightYellow) - SaddleBrown = partialmethod(custom, color=HtmlColors.SaddleBrown) - Sienna = partialmethod(custom, color=HtmlColors.Sienna) - Chocolate = partialmethod(custom, color=HtmlColors.Chocolate) - Peru = partialmethod(custom, color=HtmlColors.Peru) - SandyBrown = partialmethod(custom, color=HtmlColors.SandyBrown) - BurlyWood = partialmethod(custom, color=HtmlColors.BurlyWood) - Tan = partialmethod(custom, color=HtmlColors.Tan) - RosyBrown = partialmethod(custom, color=HtmlColors.RosyBrown) - Moccasin = partialmethod(custom, color=HtmlColors.Moccasin) - NavajoWhite = partialmethod(custom, color=HtmlColors.NavajoWhite) - PeachPuff = partialmethod(custom, color=HtmlColors.PeachPuff) - MistyRose = partialmethod(custom, color=HtmlColors.MistyRose) - LavenderBlush = partialmethod(custom, color=HtmlColors.LavenderBlush) - Linen = partialmethod(custom, color=HtmlColors.Linen) - OldLace = partialmethod(custom, color=HtmlColors.OldLace) - PapayaWhip = partialmethod(custom, color=HtmlColors.PapayaWhip) - WeaShell = partialmethod(custom, color=HtmlColors.WeaShell) - MintCream = partialmethod(custom, color=HtmlColors.MintCream) - SlateGray = partialmethod(custom, color=HtmlColors.SlateGray) - LightSlateGray = partialmethod(custom, color=HtmlColors.LightSlateGray) - LightSteelBlue = partialmethod(custom, color=HtmlColors.LightSteelBlue) - Lavender = partialmethod(custom, color=HtmlColors.Lavender) - FloralWhite = partialmethod(custom, color=HtmlColors.FloralWhite) - AliceBlue = partialmethod(custom, color=HtmlColors.AliceBlue) - GhostWhite = partialmethod(custom, color=HtmlColors.GhostWhite) - Honeydew = partialmethod(custom, color=HtmlColors.Honeydew) - Ivory = partialmethod(custom, color=HtmlColors.Ivory) - Azure = partialmethod(custom, color=HtmlColors.Azure) - Snow = partialmethod(custom, color=HtmlColors.Snow) - Black = partialmethod(custom, color=HtmlColors.Black) - DimGray = partialmethod(custom, color=HtmlColors.DimGray) - Gray = partialmethod(custom, color=HtmlColors.Gray) - DarkGray = partialmethod(custom, color=HtmlColors.DarkGray) - Silver = partialmethod(custom, color=HtmlColors.Silver) - LightGray = partialmethod(custom, color=HtmlColors.LightGray) - Gainsboro = partialmethod(custom, color=HtmlColors.Gainsboro) - WhiteSmoke = partialmethod(custom, color=HtmlColors.WhiteSmoke) - White = partialmethod(custom, color=HtmlColors.White) \ No newline at end of file + Maroon = partialmethod(_partialmethod, color=HtmlColors.Maroon) + DarkRed = partialmethod(_partialmethod, color=HtmlColors.DarkRed) + Brown = partialmethod(_partialmethod, color=HtmlColors.Brown) + Firebrick = partialmethod(_partialmethod, color=HtmlColors.Firebrick) + Crimson = partialmethod(_partialmethod, color=HtmlColors.Crimson) + Red = partialmethod(_partialmethod, color=HtmlColors.Red) + Tomato = partialmethod(_partialmethod, color=HtmlColors.Tomato) + Coral = partialmethod(_partialmethod, color=HtmlColors.Coral) + IndianRed = partialmethod(_partialmethod, color=HtmlColors.IndianRed) + LightCoral = partialmethod(_partialmethod, color=HtmlColors.LightCoral) + DarkSalmon = partialmethod(_partialmethod, color=HtmlColors.DarkSalmon) + Salmon = partialmethod(_partialmethod, color=HtmlColors.Salmon) + LightSalmon = partialmethod(_partialmethod, color=HtmlColors.LightSalmon) + OrangeRed = partialmethod(_partialmethod, color=HtmlColors.OrangeRed) + DarkOrange = partialmethod(_partialmethod, color=HtmlColors.DarkOrange) + Orange = partialmethod(_partialmethod, color=HtmlColors.Orange) + Gold = partialmethod(_partialmethod, color=HtmlColors.Gold) + DarkGoldenRod = partialmethod(_partialmethod, color=HtmlColors.DarkGoldenRod) + GoldenRod = partialmethod(_partialmethod, color=HtmlColors.GoldenRod) + PaleGoldenRod = partialmethod(_partialmethod, color=HtmlColors.PaleGoldenRod) + DarkKhaki = partialmethod(_partialmethod, color=HtmlColors.DarkKhaki) + Khaki = partialmethod(_partialmethod, color=HtmlColors.Khaki) + Olive = partialmethod(_partialmethod, color=HtmlColors.Olive) + Yellow = partialmethod(_partialmethod, color=HtmlColors.Yellow) + YellowGreen = partialmethod(_partialmethod, color=HtmlColors.YellowGreen) + DarkOliveGreen = partialmethod(_partialmethod, color=HtmlColors.DarkOliveGreen) + OliveDrab = partialmethod(_partialmethod, color=HtmlColors.OliveDrab) + LawnGreen = partialmethod(_partialmethod, color=HtmlColors.LawnGreen) + Chartreuse = partialmethod(_partialmethod, color=HtmlColors.Chartreuse) + GreenYellow = partialmethod(_partialmethod, color=HtmlColors.GreenYellow) + DarkGreen = partialmethod(_partialmethod, color=HtmlColors.DarkGreen) + Green = partialmethod(_partialmethod, color=HtmlColors.Green) + ForestGreen = partialmethod(_partialmethod, color=HtmlColors.ForestGreen) + Lime = partialmethod(_partialmethod, color=HtmlColors.Lime) + LimeGreen = partialmethod(_partialmethod, color=HtmlColors.LimeGreen) + LightGreen = partialmethod(_partialmethod, color=HtmlColors.LightGreen) + PaleGreen = partialmethod(_partialmethod, color=HtmlColors.PaleGreen) + DarkSeaGreen = partialmethod(_partialmethod, color=HtmlColors.DarkSeaGreen) + MediumSpringGreen = partialmethod(_partialmethod, color=HtmlColors.MediumSpringGreen) + SpringGreen = partialmethod(_partialmethod, color=HtmlColors.SpringGreen) + SeaGreen = partialmethod(_partialmethod, color=HtmlColors.SeaGreen) + MediumAquaMarine = partialmethod(_partialmethod, color=HtmlColors.MediumAquaMarine) + MediumSeaGreen = partialmethod(_partialmethod, color=HtmlColors.MediumSeaGreen) + LightSeaGreen = partialmethod(_partialmethod, color=HtmlColors.LightSeaGreen) + DarkSlateGray = partialmethod(_partialmethod, color=HtmlColors.DarkSlateGray) + Teal = partialmethod(_partialmethod, color=HtmlColors.Teal) + DarkCyan = partialmethod(_partialmethod, color=HtmlColors.DarkCyan) + Aqua = partialmethod(_partialmethod, color=HtmlColors.Aqua) + Cyan = partialmethod(_partialmethod, color=HtmlColors.Cyan) + LightCyan = partialmethod(_partialmethod, color=HtmlColors.LightCyan) + DarkTurquoise = partialmethod(_partialmethod, color=HtmlColors.DarkTurquoise) + Turquoise = partialmethod(_partialmethod, color=HtmlColors.Turquoise) + MediumTurquoise = partialmethod(_partialmethod, color=HtmlColors.MediumTurquoise) + PaleTurquoise = partialmethod(_partialmethod, color=HtmlColors.PaleTurquoise) + AquaMarine = partialmethod(_partialmethod, color=HtmlColors.AquaMarine) + PowderBlue = partialmethod(_partialmethod, color=HtmlColors.PowderBlue) + CadetBlue = partialmethod(_partialmethod, color=HtmlColors.CadetBlue) + SteelBlue = partialmethod(_partialmethod, color=HtmlColors.SteelBlue) + CornFlowerBlue = partialmethod(_partialmethod, color=HtmlColors.CornFlowerBlue) + DeepSkyBlue = partialmethod(_partialmethod, color=HtmlColors.DeepSkyBlue) + DodgerBlue = partialmethod(_partialmethod, color=HtmlColors.DodgerBlue) + LightBlue = partialmethod(_partialmethod, color=HtmlColors.LightBlue) + SkyBlue = partialmethod(_partialmethod, color=HtmlColors.SkyBlue) + LightSkyBlue = partialmethod(_partialmethod, color=HtmlColors.LightSkyBlue) + MidnightBlue = partialmethod(_partialmethod, color=HtmlColors.MidnightBlue) + Navy = partialmethod(_partialmethod, color=HtmlColors.Navy) + DarkBlue = partialmethod(_partialmethod, color=HtmlColors.DarkBlue) + MediumBlue = partialmethod(_partialmethod, color=HtmlColors.MediumBlue) + Blue = partialmethod(_partialmethod, color=HtmlColors.Blue) + RoyalBlue = partialmethod(_partialmethod, color=HtmlColors.RoyalBlue) + BlueViolet = partialmethod(_partialmethod, color=HtmlColors.BlueViolet) + Indigo = partialmethod(_partialmethod, color=HtmlColors.Indigo) + DarkSlateBlue = partialmethod(_partialmethod, color=HtmlColors.DarkSlateBlue) + SlateBlue = partialmethod(_partialmethod, color=HtmlColors.SlateBlue) + MediumSlateBlue = partialmethod(_partialmethod, color=HtmlColors.MediumSlateBlue) + MediumPurple = partialmethod(_partialmethod, color=HtmlColors.MediumPurple) + DarkMagenta = partialmethod(_partialmethod, color=HtmlColors.DarkMagenta) + DarkViolet = partialmethod(_partialmethod, color=HtmlColors.DarkViolet) + DarkOrchid = partialmethod(_partialmethod, color=HtmlColors.DarkOrchid) + MediumOrchid = partialmethod(_partialmethod, color=HtmlColors.MediumOrchid) + Purple = partialmethod(_partialmethod, color=HtmlColors.Purple) + Thistle = partialmethod(_partialmethod, color=HtmlColors.Thistle) + Plum = partialmethod(_partialmethod, color=HtmlColors.Plum) + Violet = partialmethod(_partialmethod, color=HtmlColors.Violet) + Magenta = partialmethod(_partialmethod, color=HtmlColors.Magenta) + Orchid = partialmethod(_partialmethod, color=HtmlColors.Orchid) + MediumVioletRed = partialmethod(_partialmethod, color=HtmlColors.MediumVioletRed) + PaleVioletRed = partialmethod(_partialmethod, color=HtmlColors.PaleVioletRed) + DeepPink = partialmethod(_partialmethod, color=HtmlColors.DeepPink) + HotPink = partialmethod(_partialmethod, color=HtmlColors.HotPink) + LightPink = partialmethod(_partialmethod, color=HtmlColors.LightPink) + Pink = partialmethod(_partialmethod, color=HtmlColors.Pink) + AntiqueWhite = partialmethod(_partialmethod, color=HtmlColors.AntiqueWhite) + Beige = partialmethod(_partialmethod, color=HtmlColors.Beige) + Bisque = partialmethod(_partialmethod, color=HtmlColors.Bisque) + BlanchedAlmond = partialmethod(_partialmethod, color=HtmlColors.BlanchedAlmond) + Wheat = partialmethod(_partialmethod, color=HtmlColors.Wheat) + CornSilk = partialmethod(_partialmethod, color=HtmlColors.CornSilk) + LemonChiffon = partialmethod(_partialmethod, color=HtmlColors.LemonChiffon) + LightGoldenRodYellow= partialmethod(_partialmethod, color=HtmlColors.LightGoldenRodYellow) + LightYellow = partialmethod(_partialmethod, color=HtmlColors.LightYellow) + SaddleBrown = partialmethod(_partialmethod, color=HtmlColors.SaddleBrown) + Sienna = partialmethod(_partialmethod, color=HtmlColors.Sienna) + Chocolate = partialmethod(_partialmethod, color=HtmlColors.Chocolate) + Peru = partialmethod(_partialmethod, color=HtmlColors.Peru) + SandyBrown = partialmethod(_partialmethod, color=HtmlColors.SandyBrown) + BurlyWood = partialmethod(_partialmethod, color=HtmlColors.BurlyWood) + Tan = partialmethod(_partialmethod, color=HtmlColors.Tan) + RosyBrown = partialmethod(_partialmethod, color=HtmlColors.RosyBrown) + Moccasin = partialmethod(_partialmethod, color=HtmlColors.Moccasin) + NavajoWhite = partialmethod(_partialmethod, color=HtmlColors.NavajoWhite) + PeachPuff = partialmethod(_partialmethod, color=HtmlColors.PeachPuff) + MistyRose = partialmethod(_partialmethod, color=HtmlColors.MistyRose) + LavenderBlush = partialmethod(_partialmethod, color=HtmlColors.LavenderBlush) + Linen = partialmethod(_partialmethod, color=HtmlColors.Linen) + OldLace = partialmethod(_partialmethod, color=HtmlColors.OldLace) + PapayaWhip = partialmethod(_partialmethod, color=HtmlColors.PapayaWhip) + WeaShell = partialmethod(_partialmethod, color=HtmlColors.WeaShell) + MintCream = partialmethod(_partialmethod, color=HtmlColors.MintCream) + SlateGray = partialmethod(_partialmethod, color=HtmlColors.SlateGray) + LightSlateGray = partialmethod(_partialmethod, color=HtmlColors.LightSlateGray) + LightSteelBlue = partialmethod(_partialmethod, color=HtmlColors.LightSteelBlue) + Lavender = partialmethod(_partialmethod, color=HtmlColors.Lavender) + FloralWhite = partialmethod(_partialmethod, color=HtmlColors.FloralWhite) + AliceBlue = partialmethod(_partialmethod, color=HtmlColors.AliceBlue) + GhostWhite = partialmethod(_partialmethod, color=HtmlColors.GhostWhite) + Honeydew = partialmethod(_partialmethod, color=HtmlColors.Honeydew) + Ivory = partialmethod(_partialmethod, color=HtmlColors.Ivory) + Azure = partialmethod(_partialmethod, color=HtmlColors.Azure) + Snow = partialmethod(_partialmethod, color=HtmlColors.Snow) + Black = partialmethod(_partialmethod, color=HtmlColors.Black) + DimGray = partialmethod(_partialmethod, color=HtmlColors.DimGray) + Gray = partialmethod(_partialmethod, color=HtmlColors.Gray) + DarkGray = partialmethod(_partialmethod, color=HtmlColors.DarkGray) + Silver = partialmethod(_partialmethod, color=HtmlColors.Silver) + LightGray = partialmethod(_partialmethod, color=HtmlColors.LightGray) + Gainsboro = partialmethod(_partialmethod, color=HtmlColors.Gainsboro) + WhiteSmoke = partialmethod(_partialmethod, color=HtmlColors.WhiteSmoke) + White = partialmethod(_partialmethod, color=HtmlColors.White) \ No newline at end of file From 7174b83414a848ad2df006b24197d5c3fe59e325 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 23:32:46 +0200 Subject: [PATCH 24/40] Change: NestedColorSequence Speedup --- Tests/Functions/test_ANSIsequences.py | 79 ++----------------- src/AthenaColor/Functions/ANSIsquences.py | 16 ++-- .../Styling/Nested/RgbControlledNest.py | 2 + 3 files changed, 17 insertions(+), 80 deletions(-) diff --git a/Tests/Functions/test_ANSIsequences.py b/Tests/Functions/test_ANSIsequences.py index 85df8ec..75ab812 100644 --- a/Tests/Functions/test_ANSIsequences.py +++ b/Tests/Functions/test_ANSIsequences.py @@ -36,11 +36,6 @@ def test_ColorSequence(self): "" ) - # noinspection PyTypeChecker - def test_ColorSequence_Fails(self): - with self.assertRaises(TypeError): - ColorSequence((38,2,128,0,0)) - def test_NestedColorSequence(self): self.assertEqual( NestedColorSequence( @@ -52,37 +47,9 @@ def test_NestedColorSequence(self): reset_code=0, sep="\n" ), -f"""This is a test +f"""This is a test For real""" ) - - self.assertEqual( - NestedColorSequence( - # objects - "This is a test", - "For real", - # color/styling, reset and seperation - reset_code=0, - sep="\n" - ), -f"""This is a test -For real""" - ) - - self.assertEqual( - NestedColorSequence( - # objects - "This is a test", - "For real", - # color/styling, reset and seperation - control_code="38;2;128;0;0", - sep="\n" - ), -f"""This is a test -For real""" - ) - - self.assertEqual( self.nested(self.nested( NestedColorSequence( @@ -94,44 +61,8 @@ def test_NestedColorSequence(self): reset_code=0, sep="\n" ))), -f"""This is a test -This is a test -This is a test +f"""This is a test +This is a test +This is a test For real""" - ) - - # noinspection PyTypeChecker - def test_NestedColorSequence_Fail(self): - with self.assertRaises(TypeError): - NestedColorSequence( - # objects - "This is a test", - "For real", - # color/styling, reset and seperation - control_code="38;2;128;0;0", - reset_code=0, - sep=("\n",) - ) - - with self.assertRaises(TypeError): - NestedColorSequence( - # objects - "This is a test", - "For real", - # color/styling, reset and seperation - control_code=("38;2;128;0;0",), - reset_code=0, - sep="\n" - ) - - with self.assertRaises(TypeError): - self.nested(self.nested( - NestedColorSequence( - # objects - "This is a test", - "For real", - # color/styling, reset and seperation - control_code="38;2;128;0;0", - reset_code=(0,), - sep="\n" - ))) \ No newline at end of file + ) \ No newline at end of file diff --git a/src/AthenaColor/Functions/ANSIsquences.py b/src/AthenaColor/Functions/ANSIsquences.py index 564499f..de71f5d 100644 --- a/src/AthenaColor/Functions/ANSIsquences.py +++ b/src/AthenaColor/Functions/ANSIsquences.py @@ -26,16 +26,20 @@ def ColorSequence(control_code:int|str)->str: Used for quick assembly of correct Ansi Escape functions Used the escape code defined in AthenaColor init """ - return f'{init.esc}[{StrictType(control_code, (int,str))}{ConsoleCodes.color}' + return f'{init.esc}[{control_code}m' -def NestedColorSequence(*obj, control_code:int|str=None,reset_code:int|str=None, sep:str=" ") -> str: +def NestedColorSequence(*obj, control_code:int|str,reset_code:int|str, sep:str=" ") -> str: """ Used by Nested Console StyleNest Makeup operations like ForeNest, BackNest, StyleNest. Function wraps every obj in the properly defined control- and reset codes. This is made to prevent style makeup bleed """ - color = ColorSequence(control_code=control_code) if control_code is not None else '' - reset = ColorSequence(control_code=reset_code) if reset_code is not None else '' - sep_ = StrictType(sep, str) + init_esc = init.esc + color = f'{init_esc}[{control_code}m' + reset = f'{init_esc}[{reset_code}m' - return f"{color}{sep_}{reset}".join([f"{color}{o}{reset}"for o in obj]) \ No newline at end of file + # SHHH, don't touch this, this is speed 101 + text = "" + for o in obj[:-1]: + text += f"{color}{o}{sep}{reset}" # SEP moved to within the color - reset, as previously, it was color-reset anyways + return text + f"{color}{obj[-1]}{reset}" \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py index 8e5a541..3e930ca 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py @@ -40,6 +40,8 @@ def custom(self,*obj, color:RGB|HEX, **kwargs) -> str: reset_code=self._reset, **kwargs ) + + # same as custom, but without the Strict Type, as the defined colors are known colors,and are types as RGB values def _partialmethod(self,*obj, color:RGB|HEX, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' return NestedColorSequence( From 6f4330573f444acb1cdd1f3cc792a72f88eb5beb Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 23:37:01 +0200 Subject: [PATCH 25/40] Fix: removed unused imports --- src/AthenaColor/Functions/ANSIsquences.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/AthenaColor/Functions/ANSIsquences.py b/src/AthenaColor/Functions/ANSIsquences.py index de71f5d..34719ac 100644 --- a/src/AthenaColor/Functions/ANSIsquences.py +++ b/src/AthenaColor/Functions/ANSIsquences.py @@ -8,8 +8,6 @@ # Custom Packages from AthenaColor.InitClass import init -from AthenaColor.Data.General import ConsoleCodes -from AthenaColor.Functions.General import StrictType # ---------------------------------------------------------------------------------------------------------------------- # - All - From 4c7ec55d3ffbe61e187baea9de646e0a6a7dfa0a Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Fri, 6 May 2022 23:53:23 +0200 Subject: [PATCH 26/40] Change: No use of Partial method, HtmlColorTuples replace with HtmlColorStr --- Tests/Data/test_HTMLColors.py | 23 - src/AthenaColor/Data/HtmlColors.py | 559 +++++++++--------- .../Styling/Nested/RgbControlledNest.py | 294 +++++---- 3 files changed, 423 insertions(+), 453 deletions(-) delete mode 100644 Tests/Data/test_HTMLColors.py diff --git a/Tests/Data/test_HTMLColors.py b/Tests/Data/test_HTMLColors.py deleted file mode 100644 index afee0eb..0000000 --- a/Tests/Data/test_HTMLColors.py +++ /dev/null @@ -1,23 +0,0 @@ -# ---------------------------------------------------------------------------------------------------------------------- -# - Package Imports - -# ---------------------------------------------------------------------------------------------------------------------- -# General Packages -from __future__ import annotations -import unittest - -# Custom Library -from AthenaColor.Data.HtmlColors import HtmlColorObjects, HtmlColorTuples - - -# Custom Packages - -# ---------------------------------------------------------------------------------------------------------------------- -# - Code - -# ---------------------------------------------------------------------------------------------------------------------- -class Data_HtmlColors(unittest.TestCase): - def test_HtmlColors(self): - for k,v in vars(HtmlColorTuples).items(): - if not k.startswith("__"): - with self.subTest(k=k, v=v): # thanks for showing me, tedthetwonk - self.assertEqual(vars(HtmlColorObjects)[k], v) - diff --git a/src/AthenaColor/Data/HtmlColors.py b/src/AthenaColor/Data/HtmlColors.py index 597700c..2c8be9d 100644 --- a/src/AthenaColor/Data/HtmlColors.py +++ b/src/AthenaColor/Data/HtmlColors.py @@ -12,284 +12,285 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- -class HtmlColorTuples: - Maroon = 128,0 ,0 - DarkRed = 139,0 ,0 - Brown = 165,42 ,42 - Firebrick = 178,34 ,34 - Crimson = 220,20 ,60 - Red = 255,0 ,0 - Tomato = 255,99 ,71 - Coral = 255,127,80 - IndianRed = 205,92 ,92 - LightCoral = 240,128,128 - DarkSalmon = 233,150,122 - Salmon = 250,128,114 - LightSalmon = 255,160,122 - OrangeRed = 255,69 ,0 - DarkOrange = 255,140,0 - Orange = 255,165,0 - Gold = 255,215,0 - DarkGoldenRod = 184,134,11 - GoldenRod = 218,165,32 - PaleGoldenRod = 238,232,170 - DarkKhaki = 189,183,107 - Khaki = 240,230,140 - Olive = 128,128,0 - Yellow = 255,255,0 - YellowGreen = 154,205,50 - DarkOliveGreen = 85 ,107,47 - OliveDrab = 107,142,35 - LawnGreen = 124,252,0 - Chartreuse = 127,255,0 - GreenYellow = 173,255,47 - DarkGreen = 0 ,100,0 - Green = 0 ,128,0 - ForestGreen = 34 ,139,34 - Lime = 0 ,255,0 - LimeGreen = 50 ,205,50 - LightGreen = 144,238,144 - PaleGreen = 152,251,152 - DarkSeaGreen = 143,188,143 - MediumSpringGreen = 0 ,250,154 - SpringGreen = 0 ,255,127 - SeaGreen = 46 ,139,87 - MediumAquaMarine = 102,205,170 - MediumSeaGreen = 60 ,179,113 - LightSeaGreen = 32 ,178,170 - DarkSlateGray = 47 ,79 ,79 - Teal = 0 ,128,128 - DarkCyan = 0 ,139,139 - Aqua = 0 ,255,255 - Cyan = 0 ,255,255 - LightCyan = 224,255,255 - DarkTurquoise = 0 ,206,209 - Turquoise = 64 ,224,208 - MediumTurquoise = 72 ,209,204 - PaleTurquoise = 175,238,238 - AquaMarine = 127,255,212 - PowderBlue = 176,224,230 - CadetBlue = 95 ,158,160 - SteelBlue = 70 ,130,180 - CornFlowerBlue = 100,149,237 - DeepSkyBlue = 0 ,191,255 - DodgerBlue = 30 ,144,255 - LightBlue = 173,216,230 - SkyBlue = 135,206,235 - LightSkyBlue = 135,206,250 - MidnightBlue = 25 ,25 ,112 - Navy = 0 ,0 ,128 - DarkBlue = 0 ,0 ,139 - MediumBlue = 0 ,0 ,205 - Blue = 0 ,0 ,255 - RoyalBlue = 65 ,105,225 - BlueViolet = 138,43 ,226 - Indigo = 75 ,0 ,130 - DarkSlateBlue = 72 ,61 ,139 - SlateBlue = 106,90 ,205 - MediumSlateBlue = 123,104,238 - MediumPurple = 147,112,219 - DarkMagenta = 139,0 ,139 - DarkViolet = 148,0 ,211 - DarkOrchid = 153,50 ,204 - MediumOrchid = 186,85 ,211 - Purple = 128,0 ,128 - Thistle = 216,191,216 - Plum = 221,160,221 - Violet = 238,130,238 - Magenta = 255,0 ,255 - Orchid = 218,112,214 - MediumVioletRed = 199,21 ,133 - PaleVioletRed = 219,112,147 - DeepPink = 255,20 ,147 - HotPink = 255,105,180 - LightPink = 255,182,193 - Pink = 255,192,203 - AntiqueWhite = 250,235,215 - Beige = 245,245,220 - Bisque = 255,228,196 - BlanchedAlmond = 255,235,205 - Wheat = 245,222,179 - CornSilk = 255,248,220 - LemonChiffon = 255,250,205 - LightGoldenRodYellow = 250,250,210 - LightYellow = 255,255,224 - SaddleBrown = 139,69 ,19 - Sienna = 160,82 ,45 - Chocolate = 210,105,30 - Peru = 205,133,63 - SandyBrown = 244,164,96 - BurlyWood = 222,184,135 - Tan = 210,180,140 - RosyBrown = 188,143,143 - Moccasin = 255,228,181 - NavajoWhite = 255,222,173 - PeachPuff = 255,218,185 - MistyRose = 255,228,225 - LavenderBlush = 255,240,245 - Linen = 250,240,230 - OldLace = 253,245,230 - PapayaWhip = 255,239,213 - WeaShell = 255,245,238 - MintCream = 245,255,250 - SlateGray = 112,128,144 - LightSlateGray = 119,136,153 - LightSteelBlue = 176,196,222 - Lavender = 230,230,250 - FloralWhite = 255,250,240 - AliceBlue = 240,248,255 - GhostWhite = 248,248,255 - Honeydew = 240,255,240 - Ivory = 255,255,240 - Azure = 240,255,255 - Snow = 255,250,250 - Black = 0 ,0 ,0 - DimGray = 105,105,105 - Gray = 128,128,128 - DarkGray = 169,169,169 - Silver = 192,192,192 - LightGray = 211,211,211 - Gainsboro = 220,220,220 - WhiteSmoke = 245,245,245 - White = 255,255,255 +class HtmlColorStr: + Maroon = "128;0;0" + DarkRed = "139;0;0" + Brown = "165;42;42" + Firebrick = "178;34;34" + Crimson = "220;20;60" + Red = "255;0;0" + Tomato = "255;99;71" + Coral = "255;127;80" + IndianRed = "205;92;92" + LightCoral = "240;128;128" + DarkSalmon = "233;150;122" + Salmon = "250;128;114" + LightSalmon = "255;160;122" + OrangeRed = "255;69;0" + DarkOrange = "255;140;0" + Orange = "255;165;0" + Gold = "255;215;0" + DarkGoldenRod = "184;134;11" + GoldenRod = "218;165;32" + PaleGoldenRod = "238;232;170" + DarkKhaki = "189;183;107" + Khaki = "240;230;140" + Olive = "128;128;0" + Yellow = "255;255;0" + YellowGreen = "154;205;50" + DarkOliveGreen = "85;107;47" + OliveDrab = "107;142;35" + LawnGreen = "124;252;0" + Chartreuse = "127;255;0" + GreenYellow = "173;255;47" + DarkGreen = "0;100;0" + Green = "0;128;0" + ForestGreen = "34;139;34" + Lime = "0;255;0" + LimeGreen = "50;205;50" + LightGreen = "144;238;144" + PaleGreen = "152;251;152" + DarkSeaGreen = "143;188;143" + MediumSpringGreen = "0;250;154" + SpringGreen = "0;255;127" + SeaGreen = "46;139;87" + MediumAquaMarine = "102;205;170" + MediumSeaGreen = "60;179;113" + LightSeaGreen = "32;178;170" + DarkSlateGray = "47;79 ;79" + Teal = "0;128;128" + DarkCyan = "0;139;139" + Aqua = "0;255;255" + Cyan = "0;255;255" + LightCyan = "224;255;255" + DarkTurquoise = "0;206;209" + Turquoise = "64;224;208" + MediumTurquoise = "72;209;204" + PaleTurquoise = "175;238;238" + AquaMarine = "127;255;212" + PowderBlue = "176;224;230" + CadetBlue = "95;158;160" + SteelBlue = "70;130;180" + CornFlowerBlue = "100;149;237" + DeepSkyBlue = "0;191;255" + DodgerBlue = "30;144;255" + LightBlue = "173;216;230" + SkyBlue = "135;206;235" + LightSkyBlue = "135;206;250" + MidnightBlue = "25;25;112" + Navy = "0;0;128" + DarkBlue = "0;0;139" + MediumBlue = "0;0;205" + Blue = "0;0;255" + RoyalBlue = "65;105;225" + BlueViolet = "138;43;226" + Indigo = "75;0;130" + DarkSlateBlue = "72;61;139" + SlateBlue = "106;90;205" + MediumSlateBlue = "123;104;238" + MediumPurple = "147;112;219" + DarkMagenta = "139;0;139" + DarkViolet = "148;0;211" + DarkOrchid = "153;50;204" + MediumOrchid = "186;85;211" + Purple = "128;0;128" + Thistle = "216;191;216" + Plum = "221;160;221" + Violet = "238;130;238" + Magenta = "255;0;255" + Orchid = "218;112;214" + MediumVioletRed = "199;21;133" + PaleVioletRed = "219;112;147" + DeepPink = "255;20;147" + HotPink = "255;105;180" + LightPink = "255;182;193" + Pink = "255;192;203" + AntiqueWhite = "250;235;215" + Beige = "245;245;220" + Bisque = "255;228;196" + BlanchedAlmond = "255;235;205" + Wheat = "245;222;179" + CornSilk = "255;248;220" + LemonChiffon = "255;250;205" + LightGoldenRodYellow = "250;250;210" + LightYellow = "255;255;224" + SaddleBrown = "139;69;19" + Sienna = "160;82;45" + Chocolate = "210;105;30" + Peru = "205;133;63" + SandyBrown = "244;164;96" + BurlyWood = "222;184;135" + Tan = "210;180;140" + RosyBrown = "188;143;143" + Moccasin = "255;228;181" + NavajoWhite = "255;222;173" + PeachPuff = "255;218;185" + MistyRose = "255;228;225" + LavenderBlush = "255;240;245" + Linen = "250;240;230" + OldLace = "253;245;230" + PapayaWhip = "255;239;213" + WeaShell = "255;245;238" + MintCream = "245;255;250" + SlateGray = "112;128;144" + LightSlateGray = "119;136;153" + LightSteelBlue = "176;196;222" + Lavender = "230;230;250" + FloralWhite = "255;250;240" + AliceBlue = "240;248;255" + GhostWhite = "248;248;255" + Honeydew = "240;255;240" + Ivory = "255;255;240" + Azure = "240;255;255" + Snow = "255;250;250" + Black = "0;0;0" + DimGray = "105;105;105" + Gray = "128;128;128" + DarkGray = "169;169;169" + Silver = "192;192;192" + LightGray = "211;211;211" + Gainsboro = "220;220;220" + WhiteSmoke = "245;245;245" + White = "255;255;255" + class HtmlColorObjects: - Maroon = RGB(*HtmlColorTuples.Maroon ) - DarkRed = RGB(*HtmlColorTuples.DarkRed ) - Brown = RGB(*HtmlColorTuples.Brown ) - Firebrick = RGB(*HtmlColorTuples.Firebrick ) - Crimson = RGB(*HtmlColorTuples.Crimson ) - Red = RGB(*HtmlColorTuples.Red ) - Tomato = RGB(*HtmlColorTuples.Tomato ) - Coral = RGB(*HtmlColorTuples.Coral ) - IndianRed = RGB(*HtmlColorTuples.IndianRed ) - LightCoral = RGB(*HtmlColorTuples.LightCoral ) - DarkSalmon = RGB(*HtmlColorTuples.DarkSalmon ) - Salmon = RGB(*HtmlColorTuples.Salmon ) - LightSalmon = RGB(*HtmlColorTuples.LightSalmon ) - OrangeRed = RGB(*HtmlColorTuples.OrangeRed ) - DarkOrange = RGB(*HtmlColorTuples.DarkOrange ) - Orange = RGB(*HtmlColorTuples.Orange ) - Gold = RGB(*HtmlColorTuples.Gold ) - DarkGoldenRod = RGB(*HtmlColorTuples.DarkGoldenRod ) - GoldenRod = RGB(*HtmlColorTuples.GoldenRod ) - PaleGoldenRod = RGB(*HtmlColorTuples.PaleGoldenRod ) - DarkKhaki = RGB(*HtmlColorTuples.DarkKhaki ) - Khaki = RGB(*HtmlColorTuples.Khaki ) - Olive = RGB(*HtmlColorTuples.Olive ) - Yellow = RGB(*HtmlColorTuples.Yellow ) - YellowGreen = RGB(*HtmlColorTuples.YellowGreen ) - DarkOliveGreen = RGB(*HtmlColorTuples.DarkOliveGreen ) - OliveDrab = RGB(*HtmlColorTuples.OliveDrab ) - LawnGreen = RGB(*HtmlColorTuples.LawnGreen ) - Chartreuse = RGB(*HtmlColorTuples.Chartreuse ) - GreenYellow = RGB(*HtmlColorTuples.GreenYellow ) - DarkGreen = RGB(*HtmlColorTuples.DarkGreen ) - Green = RGB(*HtmlColorTuples.Green ) - ForestGreen = RGB(*HtmlColorTuples.ForestGreen ) - Lime = RGB(*HtmlColorTuples.Lime ) - LimeGreen = RGB(*HtmlColorTuples.LimeGreen ) - LightGreen = RGB(*HtmlColorTuples.LightGreen ) - PaleGreen = RGB(*HtmlColorTuples.PaleGreen ) - DarkSeaGreen = RGB(*HtmlColorTuples.DarkSeaGreen ) - MediumSpringGreen = RGB(*HtmlColorTuples.MediumSpringGreen ) - SpringGreen = RGB(*HtmlColorTuples.SpringGreen ) - SeaGreen = RGB(*HtmlColorTuples.SeaGreen ) - MediumAquaMarine = RGB(*HtmlColorTuples.MediumAquaMarine ) - MediumSeaGreen = RGB(*HtmlColorTuples.MediumSeaGreen ) - LightSeaGreen = RGB(*HtmlColorTuples.LightSeaGreen ) - DarkSlateGray = RGB(*HtmlColorTuples.DarkSlateGray ) - Teal = RGB(*HtmlColorTuples.Teal ) - DarkCyan = RGB(*HtmlColorTuples.DarkCyan ) - Aqua = RGB(*HtmlColorTuples.Aqua ) - Cyan = RGB(*HtmlColorTuples.Cyan ) - LightCyan = RGB(*HtmlColorTuples.LightCyan ) - DarkTurquoise = RGB(*HtmlColorTuples.DarkTurquoise ) - Turquoise = RGB(*HtmlColorTuples.Turquoise ) - MediumTurquoise = RGB(*HtmlColorTuples.MediumTurquoise ) - PaleTurquoise = RGB(*HtmlColorTuples.PaleTurquoise ) - AquaMarine = RGB(*HtmlColorTuples.AquaMarine ) - PowderBlue = RGB(*HtmlColorTuples.PowderBlue ) - CadetBlue = RGB(*HtmlColorTuples.CadetBlue ) - SteelBlue = RGB(*HtmlColorTuples.SteelBlue ) - CornFlowerBlue = RGB(*HtmlColorTuples.CornFlowerBlue ) - DeepSkyBlue = RGB(*HtmlColorTuples.DeepSkyBlue ) - DodgerBlue = RGB(*HtmlColorTuples.DodgerBlue ) - LightBlue = RGB(*HtmlColorTuples.LightBlue ) - SkyBlue = RGB(*HtmlColorTuples.SkyBlue ) - LightSkyBlue = RGB(*HtmlColorTuples.LightSkyBlue ) - MidnightBlue = RGB(*HtmlColorTuples.MidnightBlue ) - Navy = RGB(*HtmlColorTuples.Navy ) - DarkBlue = RGB(*HtmlColorTuples.DarkBlue ) - MediumBlue = RGB(*HtmlColorTuples.MediumBlue ) - Blue = RGB(*HtmlColorTuples.Blue ) - RoyalBlue = RGB(*HtmlColorTuples.RoyalBlue ) - BlueViolet = RGB(*HtmlColorTuples.BlueViolet ) - Indigo = RGB(*HtmlColorTuples.Indigo ) - DarkSlateBlue = RGB(*HtmlColorTuples.DarkSlateBlue ) - SlateBlue = RGB(*HtmlColorTuples.SlateBlue ) - MediumSlateBlue = RGB(*HtmlColorTuples.MediumSlateBlue ) - MediumPurple = RGB(*HtmlColorTuples.MediumPurple ) - DarkMagenta = RGB(*HtmlColorTuples.DarkMagenta ) - DarkViolet = RGB(*HtmlColorTuples.DarkViolet ) - DarkOrchid = RGB(*HtmlColorTuples.DarkOrchid ) - MediumOrchid = RGB(*HtmlColorTuples.MediumOrchid ) - Purple = RGB(*HtmlColorTuples.Purple ) - Thistle = RGB(*HtmlColorTuples.Thistle ) - Plum = RGB(*HtmlColorTuples.Plum ) - Violet = RGB(*HtmlColorTuples.Violet ) - Magenta = RGB(*HtmlColorTuples.Magenta ) - Orchid = RGB(*HtmlColorTuples.Orchid ) - MediumVioletRed = RGB(*HtmlColorTuples.MediumVioletRed ) - PaleVioletRed = RGB(*HtmlColorTuples.PaleVioletRed ) - DeepPink = RGB(*HtmlColorTuples.DeepPink ) - HotPink = RGB(*HtmlColorTuples.HotPink ) - LightPink = RGB(*HtmlColorTuples.LightPink ) - Pink = RGB(*HtmlColorTuples.Pink ) - AntiqueWhite = RGB(*HtmlColorTuples.AntiqueWhite ) - Beige = RGB(*HtmlColorTuples.Beige ) - Bisque = RGB(*HtmlColorTuples.Bisque ) - BlanchedAlmond = RGB(*HtmlColorTuples.BlanchedAlmond ) - Wheat = RGB(*HtmlColorTuples.Wheat ) - CornSilk = RGB(*HtmlColorTuples.CornSilk ) - LemonChiffon = RGB(*HtmlColorTuples.LemonChiffon ) - LightGoldenRodYellow = RGB(*HtmlColorTuples.LightGoldenRodYellow ) - LightYellow = RGB(*HtmlColorTuples.LightYellow ) - SaddleBrown = RGB(*HtmlColorTuples.SaddleBrown ) - Sienna = RGB(*HtmlColorTuples.Sienna ) - Chocolate = RGB(*HtmlColorTuples.Chocolate ) - Peru = RGB(*HtmlColorTuples.Peru ) - SandyBrown = RGB(*HtmlColorTuples.SandyBrown ) - BurlyWood = RGB(*HtmlColorTuples.BurlyWood ) - Tan = RGB(*HtmlColorTuples.Tan ) - RosyBrown = RGB(*HtmlColorTuples.RosyBrown ) - Moccasin = RGB(*HtmlColorTuples.Moccasin ) - NavajoWhite = RGB(*HtmlColorTuples.NavajoWhite ) - PeachPuff = RGB(*HtmlColorTuples.PeachPuff ) - MistyRose = RGB(*HtmlColorTuples.MistyRose ) - LavenderBlush = RGB(*HtmlColorTuples.LavenderBlush ) - Linen = RGB(*HtmlColorTuples.Linen ) - OldLace = RGB(*HtmlColorTuples.OldLace ) - PapayaWhip = RGB(*HtmlColorTuples.PapayaWhip ) - WeaShell = RGB(*HtmlColorTuples.WeaShell ) - MintCream = RGB(*HtmlColorTuples.MintCream ) - SlateGray = RGB(*HtmlColorTuples.SlateGray ) - LightSlateGray = RGB(*HtmlColorTuples.LightSlateGray ) - LightSteelBlue = RGB(*HtmlColorTuples.LightSteelBlue ) - Lavender = RGB(*HtmlColorTuples.Lavender ) - FloralWhite = RGB(*HtmlColorTuples.FloralWhite ) - AliceBlue = RGB(*HtmlColorTuples.AliceBlue ) - GhostWhite = RGB(*HtmlColorTuples.GhostWhite ) - Honeydew = RGB(*HtmlColorTuples.Honeydew ) - Ivory = RGB(*HtmlColorTuples.Ivory ) - Azure = RGB(*HtmlColorTuples.Azure ) - Snow = RGB(*HtmlColorTuples.Snow ) - Black = RGB(*HtmlColorTuples.Black ) - DimGray = RGB(*HtmlColorTuples.DimGray ) - Gray = RGB(*HtmlColorTuples.Gray ) - DarkGray = RGB(*HtmlColorTuples.DarkGray ) - Silver = RGB(*HtmlColorTuples.Silver ) - LightGray = RGB(*HtmlColorTuples.LightGray ) - Gainsboro = RGB(*HtmlColorTuples.Gainsboro ) - WhiteSmoke = RGB(*HtmlColorTuples.WhiteSmoke ) - White = RGB(*HtmlColorTuples.White ) \ No newline at end of file + Maroon = RGB(128,0 ,0) + DarkRed = RGB(139,0 ,0) + Brown = RGB(165,42 ,42) + Firebrick = RGB(178,34 ,34) + Crimson = RGB(220,20 ,60) + Red = RGB(255,0 ,0) + Tomato = RGB(255,99 ,71) + Coral = RGB(255,127,80) + IndianRed = RGB(205,92 ,92) + LightCoral = RGB(240,128,128) + DarkSalmon = RGB(233,150,122) + Salmon = RGB(250,128,114) + LightSalmon = RGB(255,160,122) + OrangeRed = RGB(255,69 ,0) + DarkOrange = RGB(255,140,0) + Orange = RGB(255,165,0) + Gold = RGB(255,215,0) + DarkGoldenRod = RGB(184,134,11) + GoldenRod = RGB(218,165,32) + PaleGoldenRod = RGB(238,232,170) + DarkKhaki = RGB(189,183,107) + Khaki = RGB(240,230,140) + Olive = RGB(128,128,0) + Yellow = RGB(255,255,0) + YellowGreen = RGB(154,205,50) + DarkOliveGreen = RGB(85 ,107,47) + OliveDrab = RGB(107,142,35) + LawnGreen = RGB(124,252,0) + Chartreuse = RGB(127,255,0) + GreenYellow = RGB(173,255,47) + DarkGreen = RGB(0 ,100,0) + Green = RGB(0 ,128,0) + ForestGreen = RGB(34 ,139,34) + Lime = RGB(0 ,255,0) + LimeGreen = RGB(50 ,205,50) + LightGreen = RGB(144,238,144) + PaleGreen = RGB(152,251,152) + DarkSeaGreen = RGB(143,188,143) + MediumSpringGreen = RGB(0 ,250,154) + SpringGreen = RGB(0 ,255,127) + SeaGreen = RGB(46 ,139,87) + MediumAquaMarine = RGB(102,205,170) + MediumSeaGreen = RGB(60 ,179,113) + LightSeaGreen = RGB(32 ,178,170) + DarkSlateGray = RGB(47 ,79 ,79) + Teal = RGB(0 ,128,128) + DarkCyan = RGB(0 ,139,139) + Aqua = RGB(0 ,255,255) + Cyan = RGB(0 ,255,255) + LightCyan = RGB(224,255,255) + DarkTurquoise = RGB(0 ,206,209) + Turquoise = RGB(64 ,224,208) + MediumTurquoise = RGB(72 ,209,204) + PaleTurquoise = RGB(175,238,238) + AquaMarine = RGB(127,255,212) + PowderBlue = RGB(176,224,230) + CadetBlue = RGB(95 ,158,160) + SteelBlue = RGB(70 ,130,180) + CornFlowerBlue = RGB(100,149,237) + DeepSkyBlue = RGB(0 ,191,255) + DodgerBlue = RGB(30 ,144,255) + LightBlue = RGB(173,216,230) + SkyBlue = RGB(135,206,235) + LightSkyBlue = RGB(135,206,250) + MidnightBlue = RGB(25 ,25 ,112) + Navy = RGB(0 ,0 ,128) + DarkBlue = RGB(0 ,0 ,139) + MediumBlue = RGB(0 ,0 ,205) + Blue = RGB(0 ,0 ,255) + RoyalBlue = RGB(65 ,105,225) + BlueViolet = RGB(138,43 ,226) + Indigo = RGB(75 ,0 ,130) + DarkSlateBlue = RGB(72 ,61 ,139) + SlateBlue = RGB(106,90 ,205) + MediumSlateBlue = RGB(123,104,238) + MediumPurple = RGB(147,112,219) + DarkMagenta = RGB(139,0 ,139) + DarkViolet = RGB(148,0 ,211) + DarkOrchid = RGB(153,50 ,204) + MediumOrchid = RGB(186,85 ,211) + Purple = RGB(128,0 ,128) + Thistle = RGB(216,191,216) + Plum = RGB(221,160,221) + Violet = RGB(238,130,238) + Magenta = RGB(255,0 ,255) + Orchid = RGB(218,112,214) + MediumVioletRed = RGB(199,21 ,133) + PaleVioletRed = RGB(219,112,147) + DeepPink = RGB(255,20 ,147) + HotPink = RGB(255,105,180) + LightPink = RGB(255,182,193) + Pink = RGB(255,192,203) + AntiqueWhite = RGB(250,235,215) + Beige = RGB(245,245,220) + Bisque = RGB(255,228,196) + BlanchedAlmond = RGB(255,235,205) + Wheat = RGB(245,222,179) + CornSilk = RGB(255,248,220) + LemonChiffon = RGB(255,250,205) + LightGoldenRodYellow = RGB(250,250,210) + LightYellow = RGB(255,255,224) + SaddleBrown = RGB(139,69 ,19) + Sienna = RGB(160,82 ,45) + Chocolate = RGB(210,105,30) + Peru = RGB(205,133,63) + SandyBrown = RGB(244,164,96) + BurlyWood = RGB(222,184,135) + Tan = RGB(210,180,140) + RosyBrown = RGB(188,143,143) + Moccasin = RGB(255,228,181) + NavajoWhite = RGB(255,222,173) + PeachPuff = RGB(255,218,185) + MistyRose = RGB(255,228,225) + LavenderBlush = RGB(255,240,245) + Linen = RGB(250,240,230) + OldLace = RGB(253,245,230) + PapayaWhip = RGB(255,239,213) + WeaShell = RGB(255,245,238) + MintCream = RGB(245,255,250) + SlateGray = RGB(112,128,144) + LightSlateGray = RGB(119,136,153) + LightSteelBlue = RGB(176,196,222) + Lavender = RGB(230,230,250) + FloralWhite = RGB(255,250,240) + AliceBlue = RGB(240,248,255) + GhostWhite = RGB(248,248,255) + Honeydew = RGB(240,255,240) + Ivory = RGB(255,255,240) + Azure = RGB(240,255,255) + Snow = RGB(255,250,250) + Black = RGB(0 ,0 ,0) + DimGray = RGB(105,105,105) + Gray = RGB(128,128,128) + DarkGray = RGB(169,169,169) + Silver = RGB(192,192,192) + LightGray = RGB(211,211,211) + Gainsboro = RGB(220,220,220) + WhiteSmoke = RGB(245,245,245) + White = RGB(255,255,255) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py index 3e930ca..ca9cb5c 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py @@ -3,14 +3,13 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations -from functools import partialmethod # Custom Library # Custom Packages from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence -from AthenaColor.Data.HtmlColors import HtmlColorObjects as HtmlColors +from AthenaColor.Data.HtmlColors import HtmlColorStr as HC from AthenaColor.Functions.General import StrictType # ---------------------------------------------------------------------------------------------------------------------- @@ -23,6 +22,8 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase + class RgbControlledNest: def __init__(self, param_code:str,reset_code:int): self._param_code:str = StrictType(param_code, str) @@ -41,16 +42,6 @@ def custom(self,*obj, color:RGB|HEX, **kwargs) -> str: **kwargs ) - # same as custom, but without the Strict Type, as the defined colors are known colors,and are types as RGB values - def _partialmethod(self,*obj, color:RGB|HEX, **kwargs) -> str: - # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - return NestedColorSequence( - *obj, - control_code=f"{self._param_code}{color.r};{color.g};{color.b}", - reset_code=self._reset, - **kwargs - ) - def rgb(self,*obj, r:int,g:int,b:int, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' r,g,b = NormalizeRgb(r, g, b) @@ -64,142 +55,143 @@ def rgb(self,*obj, r:int,g:int,b:int, **kwargs) -> str: # ------------------------------------------------------------------------------------------------------------------ # - HTML colors - # ------------------------------------------------------------------------------------------------------------------ - Maroon = partialmethod(_partialmethod, color=HtmlColors.Maroon) - DarkRed = partialmethod(_partialmethod, color=HtmlColors.DarkRed) - Brown = partialmethod(_partialmethod, color=HtmlColors.Brown) - Firebrick = partialmethod(_partialmethod, color=HtmlColors.Firebrick) - Crimson = partialmethod(_partialmethod, color=HtmlColors.Crimson) - Red = partialmethod(_partialmethod, color=HtmlColors.Red) - Tomato = partialmethod(_partialmethod, color=HtmlColors.Tomato) - Coral = partialmethod(_partialmethod, color=HtmlColors.Coral) - IndianRed = partialmethod(_partialmethod, color=HtmlColors.IndianRed) - LightCoral = partialmethod(_partialmethod, color=HtmlColors.LightCoral) - DarkSalmon = partialmethod(_partialmethod, color=HtmlColors.DarkSalmon) - Salmon = partialmethod(_partialmethod, color=HtmlColors.Salmon) - LightSalmon = partialmethod(_partialmethod, color=HtmlColors.LightSalmon) - OrangeRed = partialmethod(_partialmethod, color=HtmlColors.OrangeRed) - DarkOrange = partialmethod(_partialmethod, color=HtmlColors.DarkOrange) - Orange = partialmethod(_partialmethod, color=HtmlColors.Orange) - Gold = partialmethod(_partialmethod, color=HtmlColors.Gold) - DarkGoldenRod = partialmethod(_partialmethod, color=HtmlColors.DarkGoldenRod) - GoldenRod = partialmethod(_partialmethod, color=HtmlColors.GoldenRod) - PaleGoldenRod = partialmethod(_partialmethod, color=HtmlColors.PaleGoldenRod) - DarkKhaki = partialmethod(_partialmethod, color=HtmlColors.DarkKhaki) - Khaki = partialmethod(_partialmethod, color=HtmlColors.Khaki) - Olive = partialmethod(_partialmethod, color=HtmlColors.Olive) - Yellow = partialmethod(_partialmethod, color=HtmlColors.Yellow) - YellowGreen = partialmethod(_partialmethod, color=HtmlColors.YellowGreen) - DarkOliveGreen = partialmethod(_partialmethod, color=HtmlColors.DarkOliveGreen) - OliveDrab = partialmethod(_partialmethod, color=HtmlColors.OliveDrab) - LawnGreen = partialmethod(_partialmethod, color=HtmlColors.LawnGreen) - Chartreuse = partialmethod(_partialmethod, color=HtmlColors.Chartreuse) - GreenYellow = partialmethod(_partialmethod, color=HtmlColors.GreenYellow) - DarkGreen = partialmethod(_partialmethod, color=HtmlColors.DarkGreen) - Green = partialmethod(_partialmethod, color=HtmlColors.Green) - ForestGreen = partialmethod(_partialmethod, color=HtmlColors.ForestGreen) - Lime = partialmethod(_partialmethod, color=HtmlColors.Lime) - LimeGreen = partialmethod(_partialmethod, color=HtmlColors.LimeGreen) - LightGreen = partialmethod(_partialmethod, color=HtmlColors.LightGreen) - PaleGreen = partialmethod(_partialmethod, color=HtmlColors.PaleGreen) - DarkSeaGreen = partialmethod(_partialmethod, color=HtmlColors.DarkSeaGreen) - MediumSpringGreen = partialmethod(_partialmethod, color=HtmlColors.MediumSpringGreen) - SpringGreen = partialmethod(_partialmethod, color=HtmlColors.SpringGreen) - SeaGreen = partialmethod(_partialmethod, color=HtmlColors.SeaGreen) - MediumAquaMarine = partialmethod(_partialmethod, color=HtmlColors.MediumAquaMarine) - MediumSeaGreen = partialmethod(_partialmethod, color=HtmlColors.MediumSeaGreen) - LightSeaGreen = partialmethod(_partialmethod, color=HtmlColors.LightSeaGreen) - DarkSlateGray = partialmethod(_partialmethod, color=HtmlColors.DarkSlateGray) - Teal = partialmethod(_partialmethod, color=HtmlColors.Teal) - DarkCyan = partialmethod(_partialmethod, color=HtmlColors.DarkCyan) - Aqua = partialmethod(_partialmethod, color=HtmlColors.Aqua) - Cyan = partialmethod(_partialmethod, color=HtmlColors.Cyan) - LightCyan = partialmethod(_partialmethod, color=HtmlColors.LightCyan) - DarkTurquoise = partialmethod(_partialmethod, color=HtmlColors.DarkTurquoise) - Turquoise = partialmethod(_partialmethod, color=HtmlColors.Turquoise) - MediumTurquoise = partialmethod(_partialmethod, color=HtmlColors.MediumTurquoise) - PaleTurquoise = partialmethod(_partialmethod, color=HtmlColors.PaleTurquoise) - AquaMarine = partialmethod(_partialmethod, color=HtmlColors.AquaMarine) - PowderBlue = partialmethod(_partialmethod, color=HtmlColors.PowderBlue) - CadetBlue = partialmethod(_partialmethod, color=HtmlColors.CadetBlue) - SteelBlue = partialmethod(_partialmethod, color=HtmlColors.SteelBlue) - CornFlowerBlue = partialmethod(_partialmethod, color=HtmlColors.CornFlowerBlue) - DeepSkyBlue = partialmethod(_partialmethod, color=HtmlColors.DeepSkyBlue) - DodgerBlue = partialmethod(_partialmethod, color=HtmlColors.DodgerBlue) - LightBlue = partialmethod(_partialmethod, color=HtmlColors.LightBlue) - SkyBlue = partialmethod(_partialmethod, color=HtmlColors.SkyBlue) - LightSkyBlue = partialmethod(_partialmethod, color=HtmlColors.LightSkyBlue) - MidnightBlue = partialmethod(_partialmethod, color=HtmlColors.MidnightBlue) - Navy = partialmethod(_partialmethod, color=HtmlColors.Navy) - DarkBlue = partialmethod(_partialmethod, color=HtmlColors.DarkBlue) - MediumBlue = partialmethod(_partialmethod, color=HtmlColors.MediumBlue) - Blue = partialmethod(_partialmethod, color=HtmlColors.Blue) - RoyalBlue = partialmethod(_partialmethod, color=HtmlColors.RoyalBlue) - BlueViolet = partialmethod(_partialmethod, color=HtmlColors.BlueViolet) - Indigo = partialmethod(_partialmethod, color=HtmlColors.Indigo) - DarkSlateBlue = partialmethod(_partialmethod, color=HtmlColors.DarkSlateBlue) - SlateBlue = partialmethod(_partialmethod, color=HtmlColors.SlateBlue) - MediumSlateBlue = partialmethod(_partialmethod, color=HtmlColors.MediumSlateBlue) - MediumPurple = partialmethod(_partialmethod, color=HtmlColors.MediumPurple) - DarkMagenta = partialmethod(_partialmethod, color=HtmlColors.DarkMagenta) - DarkViolet = partialmethod(_partialmethod, color=HtmlColors.DarkViolet) - DarkOrchid = partialmethod(_partialmethod, color=HtmlColors.DarkOrchid) - MediumOrchid = partialmethod(_partialmethod, color=HtmlColors.MediumOrchid) - Purple = partialmethod(_partialmethod, color=HtmlColors.Purple) - Thistle = partialmethod(_partialmethod, color=HtmlColors.Thistle) - Plum = partialmethod(_partialmethod, color=HtmlColors.Plum) - Violet = partialmethod(_partialmethod, color=HtmlColors.Violet) - Magenta = partialmethod(_partialmethod, color=HtmlColors.Magenta) - Orchid = partialmethod(_partialmethod, color=HtmlColors.Orchid) - MediumVioletRed = partialmethod(_partialmethod, color=HtmlColors.MediumVioletRed) - PaleVioletRed = partialmethod(_partialmethod, color=HtmlColors.PaleVioletRed) - DeepPink = partialmethod(_partialmethod, color=HtmlColors.DeepPink) - HotPink = partialmethod(_partialmethod, color=HtmlColors.HotPink) - LightPink = partialmethod(_partialmethod, color=HtmlColors.LightPink) - Pink = partialmethod(_partialmethod, color=HtmlColors.Pink) - AntiqueWhite = partialmethod(_partialmethod, color=HtmlColors.AntiqueWhite) - Beige = partialmethod(_partialmethod, color=HtmlColors.Beige) - Bisque = partialmethod(_partialmethod, color=HtmlColors.Bisque) - BlanchedAlmond = partialmethod(_partialmethod, color=HtmlColors.BlanchedAlmond) - Wheat = partialmethod(_partialmethod, color=HtmlColors.Wheat) - CornSilk = partialmethod(_partialmethod, color=HtmlColors.CornSilk) - LemonChiffon = partialmethod(_partialmethod, color=HtmlColors.LemonChiffon) - LightGoldenRodYellow= partialmethod(_partialmethod, color=HtmlColors.LightGoldenRodYellow) - LightYellow = partialmethod(_partialmethod, color=HtmlColors.LightYellow) - SaddleBrown = partialmethod(_partialmethod, color=HtmlColors.SaddleBrown) - Sienna = partialmethod(_partialmethod, color=HtmlColors.Sienna) - Chocolate = partialmethod(_partialmethod, color=HtmlColors.Chocolate) - Peru = partialmethod(_partialmethod, color=HtmlColors.Peru) - SandyBrown = partialmethod(_partialmethod, color=HtmlColors.SandyBrown) - BurlyWood = partialmethod(_partialmethod, color=HtmlColors.BurlyWood) - Tan = partialmethod(_partialmethod, color=HtmlColors.Tan) - RosyBrown = partialmethod(_partialmethod, color=HtmlColors.RosyBrown) - Moccasin = partialmethod(_partialmethod, color=HtmlColors.Moccasin) - NavajoWhite = partialmethod(_partialmethod, color=HtmlColors.NavajoWhite) - PeachPuff = partialmethod(_partialmethod, color=HtmlColors.PeachPuff) - MistyRose = partialmethod(_partialmethod, color=HtmlColors.MistyRose) - LavenderBlush = partialmethod(_partialmethod, color=HtmlColors.LavenderBlush) - Linen = partialmethod(_partialmethod, color=HtmlColors.Linen) - OldLace = partialmethod(_partialmethod, color=HtmlColors.OldLace) - PapayaWhip = partialmethod(_partialmethod, color=HtmlColors.PapayaWhip) - WeaShell = partialmethod(_partialmethod, color=HtmlColors.WeaShell) - MintCream = partialmethod(_partialmethod, color=HtmlColors.MintCream) - SlateGray = partialmethod(_partialmethod, color=HtmlColors.SlateGray) - LightSlateGray = partialmethod(_partialmethod, color=HtmlColors.LightSlateGray) - LightSteelBlue = partialmethod(_partialmethod, color=HtmlColors.LightSteelBlue) - Lavender = partialmethod(_partialmethod, color=HtmlColors.Lavender) - FloralWhite = partialmethod(_partialmethod, color=HtmlColors.FloralWhite) - AliceBlue = partialmethod(_partialmethod, color=HtmlColors.AliceBlue) - GhostWhite = partialmethod(_partialmethod, color=HtmlColors.GhostWhite) - Honeydew = partialmethod(_partialmethod, color=HtmlColors.Honeydew) - Ivory = partialmethod(_partialmethod, color=HtmlColors.Ivory) - Azure = partialmethod(_partialmethod, color=HtmlColors.Azure) - Snow = partialmethod(_partialmethod, color=HtmlColors.Snow) - Black = partialmethod(_partialmethod, color=HtmlColors.Black) - DimGray = partialmethod(_partialmethod, color=HtmlColors.DimGray) - Gray = partialmethod(_partialmethod, color=HtmlColors.Gray) - DarkGray = partialmethod(_partialmethod, color=HtmlColors.DarkGray) - Silver = partialmethod(_partialmethod, color=HtmlColors.Silver) - LightGray = partialmethod(_partialmethod, color=HtmlColors.LightGray) - Gainsboro = partialmethod(_partialmethod, color=HtmlColors.Gainsboro) - WhiteSmoke = partialmethod(_partialmethod, color=HtmlColors.WhiteSmoke) - White = partialmethod(_partialmethod, color=HtmlColors.White) \ No newline at end of file + # No partial methods, as this was increase the speed impact 2-fold + def Maroon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Maroon}",reset_code=self._reset,**kwargs) + def DarkRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkRed}",reset_code=self._reset,**kwargs) + def Brown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Brown}",reset_code=self._reset,**kwargs) + def Firebrick(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Firebrick}",reset_code=self._reset,**kwargs) + def Crimson(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Crimson}",reset_code=self._reset,**kwargs) + def Red(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Red}",reset_code=self._reset,**kwargs) + def Tomato(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Tomato}",reset_code=self._reset,**kwargs) + def Coral(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Coral}",reset_code=self._reset,**kwargs) + def IndianRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.IndianRed}",reset_code=self._reset,**kwargs) + def LightCoral(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightCoral}",reset_code=self._reset,**kwargs) + def DarkSalmon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSalmon}",reset_code=self._reset,**kwargs) + def Salmon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Salmon}",reset_code=self._reset,**kwargs) + def LightSalmon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSalmon}",reset_code=self._reset,**kwargs) + def OrangeRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.OrangeRed}",reset_code=self._reset,**kwargs) + def DarkOrange(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkOrange}",reset_code=self._reset,**kwargs) + def Orange(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Orange}",reset_code=self._reset,**kwargs) + def Gold(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Gold}",reset_code=self._reset,**kwargs) + def DarkGoldenRod(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkGoldenRod}",reset_code=self._reset,**kwargs) + def GoldenRod(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.GoldenRod}",reset_code=self._reset,**kwargs) + def PaleGoldenRod(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleGoldenRod}",reset_code=self._reset,**kwargs) + def DarkKhaki(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkKhaki}",reset_code=self._reset,**kwargs) + def Khaki(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Khaki}",reset_code=self._reset,**kwargs) + def Olive(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Olive}",reset_code=self._reset,**kwargs) + def Yellow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Yellow}",reset_code=self._reset,**kwargs) + def YellowGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.YellowGreen}",reset_code=self._reset,**kwargs) + def DarkOliveGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkOliveGreen}",reset_code=self._reset,**kwargs) + def OliveDrab(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.OliveDrab}",reset_code=self._reset,**kwargs) + def LawnGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LawnGreen}",reset_code=self._reset,**kwargs) + def Chartreuse(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Chartreuse}",reset_code=self._reset,**kwargs) + def GreenYellow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.GreenYellow}",reset_code=self._reset,**kwargs) + def DarkGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkGreen}",reset_code=self._reset,**kwargs) + def Green(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Green}",reset_code=self._reset,**kwargs) + def ForestGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.ForestGreen}",reset_code=self._reset,**kwargs) + def Lime(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Lime}",reset_code=self._reset,**kwargs) + def LimeGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LimeGreen}",reset_code=self._reset,**kwargs) + def LightGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightGreen}",reset_code=self._reset,**kwargs) + def PaleGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleGreen}",reset_code=self._reset,**kwargs) + def DarkSeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSeaGreen}",reset_code=self._reset,**kwargs) + def MediumSpringGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumSpringGreen}",reset_code=self._reset,**kwargs) + def SpringGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SpringGreen}",reset_code=self._reset,**kwargs) + def SeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SeaGreen}",reset_code=self._reset,**kwargs) + def MediumAquaMarine(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumAquaMarine}",reset_code=self._reset,**kwargs) + def MediumSeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumSeaGreen}",reset_code=self._reset,**kwargs) + def LightSeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSeaGreen}",reset_code=self._reset,**kwargs) + def DarkSlateGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSlateGray}",reset_code=self._reset,**kwargs) + def Teal(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Teal}",reset_code=self._reset,**kwargs) + def DarkCyan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkCyan}",reset_code=self._reset,**kwargs) + def Aqua(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Aqua}",reset_code=self._reset,**kwargs) + def Cyan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Cyan}",reset_code=self._reset,**kwargs) + def LightCyan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightCyan}",reset_code=self._reset,**kwargs) + def DarkTurquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkTurquoise}",reset_code=self._reset,**kwargs) + def Turquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Turquoise}",reset_code=self._reset,**kwargs) + def MediumTurquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumTurquoise}",reset_code=self._reset,**kwargs) + def PaleTurquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleTurquoise}",reset_code=self._reset,**kwargs) + def AquaMarine(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.AquaMarine}",reset_code=self._reset,**kwargs) + def PowderBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PowderBlue}",reset_code=self._reset,**kwargs) + def CadetBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.CadetBlue}",reset_code=self._reset,**kwargs) + def SteelBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SteelBlue}",reset_code=self._reset,**kwargs) + def CornFlowerBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.CornFlowerBlue}",reset_code=self._reset,**kwargs) + def DeepSkyBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DeepSkyBlue}",reset_code=self._reset,**kwargs) + def DodgerBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DodgerBlue}",reset_code=self._reset,**kwargs) + def LightBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightBlue}",reset_code=self._reset,**kwargs) + def SkyBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SkyBlue}",reset_code=self._reset,**kwargs) + def LightSkyBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSkyBlue}",reset_code=self._reset,**kwargs) + def MidnightBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MidnightBlue}",reset_code=self._reset,**kwargs) + def Navy(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Navy}",reset_code=self._reset,**kwargs) + def DarkBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkBlue}",reset_code=self._reset,**kwargs) + def MediumBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumBlue}",reset_code=self._reset,**kwargs) + def Blue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Blue}",reset_code=self._reset,**kwargs) + def RoyalBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.RoyalBlue}",reset_code=self._reset,**kwargs) + def BlueViolet(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.BlueViolet}",reset_code=self._reset,**kwargs) + def Indigo(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Indigo}",reset_code=self._reset,**kwargs) + def DarkSlateBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSlateBlue}",reset_code=self._reset,**kwargs) + def SlateBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SlateBlue}",reset_code=self._reset,**kwargs) + def MediumSlateBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumSlateBlue}",reset_code=self._reset,**kwargs) + def MediumPurple(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumPurple}",reset_code=self._reset,**kwargs) + def DarkMagenta(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkMagenta}",reset_code=self._reset,**kwargs) + def DarkViolet(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkViolet}",reset_code=self._reset,**kwargs) + def DarkOrchid(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkOrchid}",reset_code=self._reset,**kwargs) + def MediumOrchid(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumOrchid}",reset_code=self._reset,**kwargs) + def Purple(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Purple}",reset_code=self._reset,**kwargs) + def Thistle(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Thistle}",reset_code=self._reset,**kwargs) + def Plum(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Plum}",reset_code=self._reset,**kwargs) + def Violet(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Violet}",reset_code=self._reset,**kwargs) + def Magenta(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Magenta}",reset_code=self._reset,**kwargs) + def Orchid(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Orchid}",reset_code=self._reset,**kwargs) + def MediumVioletRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumVioletRed}",reset_code=self._reset,**kwargs) + def PaleVioletRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleVioletRed}",reset_code=self._reset,**kwargs) + def DeepPink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DeepPink}",reset_code=self._reset,**kwargs) + def HotPink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.HotPink}",reset_code=self._reset,**kwargs) + def LightPink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightPink}",reset_code=self._reset,**kwargs) + def Pink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Pink}",reset_code=self._reset,**kwargs) + def AntiqueWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.AntiqueWhite}",reset_code=self._reset,**kwargs) + def Beige(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Beige}",reset_code=self._reset,**kwargs) + def Bisque(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Bisque}",reset_code=self._reset,**kwargs) + def BlanchedAlmond(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.BlanchedAlmond}",reset_code=self._reset,**kwargs) + def Wheat(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Wheat}",reset_code=self._reset,**kwargs) + def CornSilk(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.CornSilk}",reset_code=self._reset,**kwargs) + def LemonChiffon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LemonChiffon}",reset_code=self._reset,**kwargs) + def LightGoldenRodYellow(self, *obj, **kwargs):return NCS(*obj,control_code=f"{self._param_code}{HC.LightGoldenRodYellow}",reset_code=self._reset,**kwargs) + def LightYellow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightYellow}",reset_code=self._reset,**kwargs) + def SaddleBrown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SaddleBrown}",reset_code=self._reset,**kwargs) + def Sienna(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Sienna}",reset_code=self._reset,**kwargs) + def Chocolate(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Chocolate}",reset_code=self._reset,**kwargs) + def Peru(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Peru}",reset_code=self._reset,**kwargs) + def SandyBrown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SandyBrown}",reset_code=self._reset,**kwargs) + def BurlyWood(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.BurlyWood}",reset_code=self._reset,**kwargs) + def Tan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Tan}",reset_code=self._reset,**kwargs) + def RosyBrown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.RosyBrown}",reset_code=self._reset,**kwargs) + def Moccasin(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Moccasin}",reset_code=self._reset,**kwargs) + def NavajoWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.NavajoWhite}",reset_code=self._reset,**kwargs) + def PeachPuff(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PeachPuff}",reset_code=self._reset,**kwargs) + def MistyRose(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MistyRose}",reset_code=self._reset,**kwargs) + def LavenderBlush(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LavenderBlush}",reset_code=self._reset,**kwargs) + def Linen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Linen}",reset_code=self._reset,**kwargs) + def OldLace(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.OldLace}",reset_code=self._reset,**kwargs) + def PapayaWhip(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PapayaWhip}",reset_code=self._reset,**kwargs) + def WeaShell(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.WeaShell}",reset_code=self._reset,**kwargs) + def MintCream(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MintCream}",reset_code=self._reset,**kwargs) + def SlateGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SlateGray}",reset_code=self._reset,**kwargs) + def LightSlateGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSlateGray}",reset_code=self._reset,**kwargs) + def LightSteelBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSteelBlue}",reset_code=self._reset,**kwargs) + def Lavender(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Lavender}",reset_code=self._reset,**kwargs) + def FloralWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.FloralWhite}",reset_code=self._reset,**kwargs) + def AliceBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.AliceBlue}",reset_code=self._reset,**kwargs) + def GhostWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.GhostWhite}",reset_code=self._reset,**kwargs) + def Honeydew(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Honeydew}",reset_code=self._reset,**kwargs) + def Ivory(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Ivory}",reset_code=self._reset,**kwargs) + def Azure(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Azure}",reset_code=self._reset,**kwargs) + def Snow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Snow}",reset_code=self._reset,**kwargs) + def Black(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Black}",reset_code=self._reset,**kwargs) + def DimGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DimGray}",reset_code=self._reset,**kwargs) + def Gray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Gray}",reset_code=self._reset,**kwargs) + def DarkGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkGray}",reset_code=self._reset,**kwargs) + def Silver(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Silver}",reset_code=self._reset,**kwargs) + def LightGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightGray}",reset_code=self._reset,**kwargs) + def Gainsboro(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Gainsboro}",reset_code=self._reset,**kwargs) + def WhiteSmoke(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.WhiteSmoke}",reset_code=self._reset,**kwargs) + def White(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.White}",reset_code=self._reset,**kwargs) \ No newline at end of file From 403af4961cdd7fc7b7509f8a53d090cce3636d52 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 00:24:11 +0200 Subject: [PATCH 27/40] Change; Speedup of NestedColorSequence, RgbControlledNest and StyleNest --- Tests/Functions/test_ANSIsequences.py | 12 +- src/AthenaColor/Functions/ANSIsquences.py | 25 +- .../Console/Styling/Nested/Nested_MakeUp.py | 261 ++++++++++------ .../Styling/Nested/RgbControlledNest.py | 278 +++++++++--------- 4 files changed, 340 insertions(+), 236 deletions(-) diff --git a/Tests/Functions/test_ANSIsequences.py b/Tests/Functions/test_ANSIsequences.py index 75ab812..4211d7c 100644 --- a/Tests/Functions/test_ANSIsequences.py +++ b/Tests/Functions/test_ANSIsequences.py @@ -18,8 +18,8 @@ class Functions_ANSIsequences(unittest.TestCase): def nested(nested): return NestedColorSequence( # objects - "This is a test", - nested, + ("This is a test", + nested), # color/styling, reset and seperation control_code="38;2;128;0;0", reset_code=0, @@ -40,8 +40,8 @@ def test_NestedColorSequence(self): self.assertEqual( NestedColorSequence( # objects - "This is a test", - "For real", + ("This is a test", + "For real"), # color/styling, reset and seperation control_code="38;2;128;0;0", reset_code=0, @@ -54,8 +54,8 @@ def test_NestedColorSequence(self): self.nested(self.nested( NestedColorSequence( # objects - "This is a test", - "For real", + ("This is a test", + "For real"), # color/styling, reset and seperation control_code="38;2;128;0;0", reset_code=0, diff --git a/src/AthenaColor/Functions/ANSIsquences.py b/src/AthenaColor/Functions/ANSIsquences.py index 34719ac..553a7f0 100644 --- a/src/AthenaColor/Functions/ANSIsquences.py +++ b/src/AthenaColor/Functions/ANSIsquences.py @@ -13,12 +13,14 @@ # - All - # ---------------------------------------------------------------------------------------------------------------------- __all__ = [ - "ColorSequence", "NestedColorSequence" + "ColorSequence", "NestedColorSequence","NestedColorSequence_NoReset" ] # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- + + def ColorSequence(control_code:int|str)->str: """ Used for quick assembly of correct Ansi Escape functions @@ -26,18 +28,33 @@ def ColorSequence(control_code:int|str)->str: """ return f'{init.esc}[{control_code}m' -def NestedColorSequence(*obj, control_code:int|str,reset_code:int|str, sep:str=" ") -> str: +def NestedColorSequence(obj:tuple, control_code:int|str, reset_code:int|str, sep:str=" ") -> str: """ Used by Nested Console StyleNest Makeup operations like ForeNest, BackNest, StyleNest. Function wraps every obj in the properly defined control- and reset codes. This is made to prevent style makeup bleed """ + + # SHHH, don't touch this, this is speed 101 init_esc = init.esc color = f'{init_esc}[{control_code}m' reset = f'{init_esc}[{reset_code}m' + text = "" + for o in obj[:-1]: + text += f"{color}{o}{sep}{reset}" # SEP moved to within the color - reset, as previously, it was color-reset anyways + return text + f"{color}{obj[-1]}{reset}" + +def NestedColorSequence_NoReset(obj:tuple, control_code:int|str, sep:str=" ") -> str: + """ + Used by Nested Console StyleNest Makeup operations like ForeNest, BackNest, StyleNest. + Function wraps every obj in the properly defined control- and reset codes. + This is made to prevent style makeup bleed + """ # SHHH, don't touch this, this is speed 101 + init_esc = init.esc + color = f'{init_esc}[{control_code}m' text = "" for o in obj[:-1]: - text += f"{color}{o}{sep}{reset}" # SEP moved to within the color - reset, as previously, it was color-reset anyways - return text + f"{color}{obj[-1]}{reset}" \ No newline at end of file + text += f"{color}{o}{sep}" # SEP moved to within the color - reset, as previously, it was color-reset anyways + return text + f"{color}{obj[-1]}" \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py index 96f71da..680e755 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py @@ -7,7 +7,7 @@ # Custom Library # Custom Packages -from AthenaColor.Functions.ANSIsquences import NestedColorSequence +from AthenaColor.Functions.ANSIsquences import NestedColorSequence,NestedColorSequence_NoReset # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -19,6 +19,9 @@ # ---------------------------------------------------------------------------------------------------------------------- # - StyleNest Sequences - # ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase +NCSNO = NestedColorSequence_NoReset # Done for slight speed increase + class StyleNest: # noinspection PyUnresolvedReferences __all__ = [ @@ -41,97 +44,181 @@ class StyleNest: "NoForeground", "NoBackground" ] - - Reset = partial(NestedColorSequence, control_code=0) - Bold = partial(NestedColorSequence, control_code=1, reset_code=22) - NoBold = partial(NestedColorSequence, control_code=22) - Dim = partial(NestedColorSequence, control_code=2, reset_code=22) - NoDim = partial(NestedColorSequence, control_code=22) - Italic = partial(NestedColorSequence, control_code=3, reset_code=23) - NoItalic = partial(NestedColorSequence, control_code=23) - Underline = partial(NestedColorSequence, control_code=4, reset_code=24) - NoUnderline = partial(NestedColorSequence, control_code=24) - BlinkSlow = partial(NestedColorSequence, control_code=5, reset_code=25) - NoBlinkSlow = partial(NestedColorSequence, control_code=25) - BlinkRapid = partial(NestedColorSequence, control_code=6, reset_code=25) - NoBlinkRapid = partial(NestedColorSequence, control_code=25) - Reversed = partial(NestedColorSequence, control_code=7, reset_code=27) - NoReversed = partial(NestedColorSequence, control_code=27) - Conceal = partial(NestedColorSequence, control_code=8, reset_code=28) - NoConceal = partial(NestedColorSequence, control_code=28) - Crossed = partial(NestedColorSequence, control_code=9, reset_code=29) - NoCrossed = partial(NestedColorSequence, control_code=29) - FontPrimary = partial(NestedColorSequence, control_code=10, reset_code=10) - FontSecond1 = partial(NestedColorSequence, control_code=11, reset_code=10) - FontSecond2 = partial(NestedColorSequence, control_code=12, reset_code=10) - FontSecond3 = partial(NestedColorSequence, control_code=13, reset_code=10) - FontSecond4 = partial(NestedColorSequence, control_code=14, reset_code=10) - FontSecond5 = partial(NestedColorSequence, control_code=15, reset_code=10) - FontSecond6 = partial(NestedColorSequence, control_code=16, reset_code=10) - FontSecond8 = partial(NestedColorSequence, control_code=17, reset_code=10) - FontSecond9 = partial(NestedColorSequence, control_code=18, reset_code=10) - FontSecond10 = partial(NestedColorSequence, control_code=19, reset_code=10) - NoFont = partial(NestedColorSequence, control_code=10) - Fraktur = partial(NestedColorSequence, control_code=20) - UnderlineDouble = partial(NestedColorSequence, control_code=21, reset_code=24) - NoUnderlineDouble = partial(NestedColorSequence, control_code=24) - PropSpacing = partial(NestedColorSequence, control_code=26, reset_code=26) - NoPropSpacing = partial(NestedColorSequence, control_code=26) - NoForeground = partial(NestedColorSequence, control_code=39) - NoBackground = partial(NestedColorSequence, control_code=49) - Frame = partial(NestedColorSequence, control_code=51, reset_code=54) - NoFrame = partial(NestedColorSequence, control_code=54) - Circle = partial(NestedColorSequence, control_code=52, reset_code=54) - NoCircle = partial(NestedColorSequence, control_code=54) - OverLine = partial(NestedColorSequence, control_code=53, reset_code=55) - NoOverLine = partial(NestedColorSequence, control_code=55) - UnderColourDefault = partial(NestedColorSequence, control_code=59) - IdeogramUnderLine = partial(NestedColorSequence, control_code=60, reset_code=65) - IdeogramUnderLineDouble = partial(NestedColorSequence, control_code=61, reset_code=65) - IdeogramOverLine = partial(NestedColorSequence, control_code=62, reset_code=65) - IdeogramOverLineDouble = partial(NestedColorSequence, control_code=63, reset_code=65) - IdeogramStress = partial(NestedColorSequence, control_code=64, reset_code=65) - NoIdeogram = partial(NestedColorSequence, control_code=65) - SuperScript = partial(NestedColorSequence, control_code=73, reset_code=75) - SubScript = partial(NestedColorSequence, control_code=74, reset_code=75) - NoScript = partial(NestedColorSequence, control_code=75) + @staticmethod + def Reset(*obj, sep=" "): return NCSNO(obj, control_code=0, sep=sep) + @staticmethod + def Bold(*obj, sep=" "): return NCS(obj, control_code=1, reset_code=22, sep=sep) + @staticmethod + def NoBold(*obj, sep=" "): return NCSNO(obj, control_code=22, sep=sep) + @staticmethod + def Dim(*obj, sep=" "): return NCS(obj, control_code=2, reset_code=22, sep=sep) + @staticmethod + def NoDim(*obj, sep=" "): return NCSNO(obj, control_code=22, sep=sep) + @staticmethod + def Italic(*obj, sep=" "): return NCS(obj, control_code=3, reset_code=23, sep=sep) + @staticmethod + def NoItalic(*obj, sep=" "): return NCSNO(obj, control_code=23, sep=sep) + @staticmethod + def Underline(*obj, sep=" "): return NCS(obj, control_code=4, reset_code=24, sep=sep) + @staticmethod + def NoUnderline(*obj, sep=" "): return NCSNO(obj, control_code=24, sep=sep) + @staticmethod + def BlinkSlow(*obj, sep=" "): return NCS(obj, control_code=5, reset_code=25, sep=sep) + @staticmethod + def NoBlinkSlow(*obj, sep=" "): return NCSNO(obj, control_code=25, sep=sep) + @staticmethod + def BlinkRapid(*obj, sep=" "): return NCS(obj, control_code=6, reset_code=25, sep=sep) + @staticmethod + def NoBlinkRapid(*obj, sep=" "): return NCSNO(obj, control_code=25, sep=sep) + @staticmethod + def Reversed(*obj, sep=" "): return NCS(obj, control_code=7, reset_code=27, sep=sep) + @staticmethod + def NoReversed(*obj, sep=" "): return NCSNO(obj, control_code=27, sep=sep) + @staticmethod + def Conceal(*obj, sep=" "): return NCS(obj, control_code=8, reset_code=28, sep=sep) + @staticmethod + def NoConceal(*obj, sep=" "): return NCSNO(obj, control_code=28, sep=sep) + @staticmethod + def Crossed(*obj, sep=" "): return NCS(obj, control_code=9, reset_code=29, sep=sep) + @staticmethod + def NoCrossed(*obj, sep=" "): return NCSNO(obj, control_code=29, sep=sep) + @staticmethod + def FontPrimary(*obj, sep=" "): return NCS(obj, control_code=10, reset_code=10, sep=sep) + @staticmethod + def FontSecond1(*obj, sep=" "): return NCS(obj, control_code=11, reset_code=10, sep=sep) + @staticmethod + def FontSecond2(*obj, sep=" "): return NCS(obj, control_code=12, reset_code=10, sep=sep) + @staticmethod + def FontSecond3(*obj, sep=" "): return NCS(obj, control_code=13, reset_code=10, sep=sep) + @staticmethod + def FontSecond4(*obj, sep=" "): return NCS(obj, control_code=14, reset_code=10, sep=sep) + @staticmethod + def FontSecond5(*obj, sep=" "): return NCS(obj, control_code=15, reset_code=10, sep=sep) + @staticmethod + def FontSecond6(*obj, sep=" "): return NCS(obj, control_code=16, reset_code=10, sep=sep) + @staticmethod + def FontSecond8(*obj, sep=" "): return NCS(obj, control_code=17, reset_code=10, sep=sep) + @staticmethod + def FontSecond9(*obj, sep=" "): return NCS(obj, control_code=18, reset_code=10, sep=sep) + @staticmethod + def FontSecond10(*obj, sep=" "): return NCS(obj, control_code=19, reset_code=10, sep=sep) + @staticmethod + def NoFont(*obj, sep=" "): return NCSNO(obj, control_code=10, sep=sep) + @staticmethod + def Fraktur(*obj, sep=" "): return NCSNO(obj, control_code=20, sep=sep) + @staticmethod + def UnderlineDouble(*obj, sep=" "): return NCS(obj, control_code=21, reset_code=24, sep=sep) + @staticmethod + def NoUnderlineDouble(*obj, sep=" "): return NCSNO(obj, control_code=24, sep=sep) + @staticmethod + def PropSpacing(*obj, sep=" "): return NCS(obj, control_code=26, reset_code=26, sep=sep) + @staticmethod + def NoPropSpacing(*obj, sep=" "): return NCSNO(obj, control_code=26, sep=sep) + @staticmethod + def NoForeground(*obj, sep=" "): return NCSNO(obj, control_code=39, sep=sep) + @staticmethod + def NoBackground(*obj, sep=" "): return NCSNO(obj, control_code=49, sep=sep) + @staticmethod + def Frame(*obj, sep=" "): return NCS(obj, control_code=51, reset_code=54, sep=sep) + @staticmethod + def NoFrame(*obj, sep=" "): return NCSNO(obj, control_code=54, sep=sep) + @staticmethod + def Circle(*obj, sep=" "): return NCS(obj, control_code=52, reset_code=54, sep=sep) + @staticmethod + def NoCircle(*obj, sep=" "): return NCSNO(obj, control_code=54, sep=sep) + @staticmethod + def OverLine(*obj, sep=" "): return NCS(obj, control_code=53, reset_code=55, sep=sep) + @staticmethod + def NoOverLine(*obj, sep=" "): return NCSNO(obj, control_code=55, sep=sep) + @staticmethod + def UnderColourDefault(*obj, sep=" "): return NCSNO(obj, control_code=59, sep=sep) + @staticmethod + def IdeogramUnderLine(*obj, sep=" "): return NCS(obj, control_code=60, reset_code=65, sep=sep) + @staticmethod + def IdeogramUnderLineDouble(*obj, sep=" "): return NCS(obj, control_code=61, reset_code=65, sep=sep) + @staticmethod + def IdeogramOverLine(*obj, sep=" "): return NCS(obj, control_code=62, reset_code=65, sep=sep) + @staticmethod + def IdeogramOverLineDouble(*obj, sep=" "): return NCS(obj, control_code=63, reset_code=65, sep=sep) + @staticmethod + def IdeogramStress(*obj, sep=" "): return NCS(obj, control_code=64, reset_code=65, sep=sep) + @staticmethod + def NoIdeogram(*obj, sep=" "): return NCSNO(obj, control_code=65, sep=sep) + @staticmethod + def SuperScript(*obj, sep=" "): return NCS(obj, control_code=73, reset_code=75, sep=sep) + @staticmethod + def SubScript(*obj, sep=" "): return NCS(obj, control_code=74, reset_code=75, sep=sep) + @staticmethod + def NoScript(*obj, sep=" "): return NCS(obj, control_code=75, sep=sep) # ---------------------------------------------------------------------------------------------------------------------- # - BasicNest Sequences - # ---------------------------------------------------------------------------------------------------------------------- class BasicNest: class Fore: - Black = partial(NestedColorSequence, color_code=30, reset_code=39) - Red = partial(NestedColorSequence, color_code=31, reset_code=39) - Green = partial(NestedColorSequence, color_code=32, reset_code=39) - Yellow = partial(NestedColorSequence, color_code=33, reset_code=39) - Blue = partial(NestedColorSequence, color_code=34, reset_code=39) - Magenta = partial(NestedColorSequence, color_code=35, reset_code=39) - Cyan = partial(NestedColorSequence, color_code=36, reset_code=39) - White = partial(NestedColorSequence, color_code=37, reset_code=39) - BrightBlack = partial(NestedColorSequence, color_code=90, reset_code=39) - BrightRed = partial(NestedColorSequence, color_code=91, reset_code=39) - BrightGreen = partial(NestedColorSequence, color_code=92, reset_code=39) - BrightYellow = partial(NestedColorSequence, color_code=93, reset_code=39) - BrightBlue = partial(NestedColorSequence, color_code=94, reset_code=39) - BrightMagenta = partial(NestedColorSequence, color_code=95, reset_code=39) - BrightCyan = partial(NestedColorSequence, color_code=96, reset_code=39) - BrightWhite = partial(NestedColorSequence, color_code=97, reset_code=39) + @staticmethod + def Black(*obj, sep=" "): return NCS(obj, 30, 39, sep=sep) + @staticmethod + def Red(*obj, sep=" "): return NCS(obj, 31, 39, sep=sep) + @staticmethod + def Green(*obj, sep=" "): return NCS(obj, 32, 39, sep=sep) + @staticmethod + def Yellow(*obj, sep=" "): return NCS(obj, 33, 39, sep=sep) + @staticmethod + def Blue(*obj, sep=" "): return NCS(obj, 34, 39, sep=sep) + @staticmethod + def Magenta(*obj, sep=" "): return NCS(obj, 35, 39, sep=sep) + @staticmethod + def Cyan(*obj, sep=" "): return NCS(obj, 36, 39, sep=sep) + @staticmethod + def White(*obj, sep=" "): return NCS(obj, 37, 39, sep=sep) + @staticmethod + def BrightBlack(*obj, sep=" "): return NCS(obj, 90, 39, sep=sep) + @staticmethod + def BrightRed(*obj, sep=" "): return NCS(obj, 91, 39, sep=sep) + @staticmethod + def BrightGreen(*obj, sep=" "): return NCS(obj, 92, 39, sep=sep) + @staticmethod + def BrightYellow(*obj, sep=" "): return NCS(obj, 93, 39, sep=sep) + @staticmethod + def BrightBlue(*obj, sep=" "): return NCS(obj, 94, 39, sep=sep) + @staticmethod + def BrightMagenta(*obj, sep=" "): return NCS(obj, 95, 39, sep=sep) + @staticmethod + def BrightCyan(*obj, sep=" "): return NCS(obj, 96, 39, sep=sep) + @staticmethod + def BrightWhite(*obj, sep=" "): return NCS(obj, 97, 39, sep=sep) class Back: - Black = partial(NestedColorSequence, color_code=40, reset_code=49) - Red = partial(NestedColorSequence, color_code=41, reset_code=49) - Green = partial(NestedColorSequence, color_code=42, reset_code=49) - Yellow = partial(NestedColorSequence, color_code=43, reset_code=49) - Blue = partial(NestedColorSequence, color_code=44, reset_code=49) - Magenta = partial(NestedColorSequence, color_code=45, reset_code=49) - Cyan = partial(NestedColorSequence, color_code=46, reset_code=49) - White = partial(NestedColorSequence, color_code=47, reset_code=49) - BrightBlack = partial(NestedColorSequence, color_code=100, reset_code=49) - BrightRed = partial(NestedColorSequence, color_code=101, reset_code=49) - BrightGreen = partial(NestedColorSequence, color_code=102, reset_code=49) - BrightYellow = partial(NestedColorSequence, color_code=103, reset_code=49) - BrightBlue = partial(NestedColorSequence, color_code=104, reset_code=49) - BrightMagenta = partial(NestedColorSequence, color_code=105, reset_code=49) - BrightCyan = partial(NestedColorSequence, color_code=106, reset_code=49) - BrightWhite = partial(NestedColorSequence, color_code=107, reset_code=49) \ No newline at end of file + @staticmethod + def Black(*obj, sep=" "): return NCS(obj, 40, 49, sep=sep) + @staticmethod + def Red(*obj, sep=" "): return NCS(obj, 41, 49, sep=sep) + @staticmethod + def Green(*obj, sep=" "): return NCS(obj, 42, 49, sep=sep) + @staticmethod + def Yellow(*obj, sep=" "): return NCS(obj, 43, 49, sep=sep) + @staticmethod + def Blue(*obj, sep=" "): return NCS(obj, 44, 49, sep=sep) + @staticmethod + def Magenta(*obj, sep=" "): return NCS(obj, 45, 49, sep=sep) + @staticmethod + def Cyan(*obj, sep=" "): return NCS(obj, 46, 49, sep=sep) + @staticmethod + def White(*obj, sep=" "): return NCS(obj, 47, 49, sep=sep) + @staticmethod + def BrightBlack(*obj, sep=" "): return NCS(obj, 100, 49, sep=sep) + @staticmethod + def BrightRed(*obj, sep=" "): return NCS(obj, 101, 49, sep=sep) + @staticmethod + def BrightGreen(*obj, sep=" "): return NCS(obj, 102, 49, sep=sep) + @staticmethod + def BrightYellow(*obj, sep=" "): return NCS(obj, 103, 49, sep=sep) + @staticmethod + def BrightBlue(*obj, sep=" "): return NCS(obj, 104, 49, sep=sep) + @staticmethod + def BrightMagenta(*obj, sep=" "): return NCS(obj, 105, 49, sep=sep) + @staticmethod + def BrightCyan(*obj, sep=" "): return NCS(obj, 106, 49, sep=sep) + @staticmethod + def BrightWhite(*obj, sep=" "): return NCS(obj, 107, 49, sep=sep) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py index ca9cb5c..8ce4dfd 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py @@ -56,142 +56,142 @@ def rgb(self,*obj, r:int,g:int,b:int, **kwargs) -> str: # - HTML colors - # ------------------------------------------------------------------------------------------------------------------ # No partial methods, as this was increase the speed impact 2-fold - def Maroon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Maroon}",reset_code=self._reset,**kwargs) - def DarkRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkRed}",reset_code=self._reset,**kwargs) - def Brown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Brown}",reset_code=self._reset,**kwargs) - def Firebrick(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Firebrick}",reset_code=self._reset,**kwargs) - def Crimson(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Crimson}",reset_code=self._reset,**kwargs) - def Red(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Red}",reset_code=self._reset,**kwargs) - def Tomato(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Tomato}",reset_code=self._reset,**kwargs) - def Coral(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Coral}",reset_code=self._reset,**kwargs) - def IndianRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.IndianRed}",reset_code=self._reset,**kwargs) - def LightCoral(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightCoral}",reset_code=self._reset,**kwargs) - def DarkSalmon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSalmon}",reset_code=self._reset,**kwargs) - def Salmon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Salmon}",reset_code=self._reset,**kwargs) - def LightSalmon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSalmon}",reset_code=self._reset,**kwargs) - def OrangeRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.OrangeRed}",reset_code=self._reset,**kwargs) - def DarkOrange(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkOrange}",reset_code=self._reset,**kwargs) - def Orange(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Orange}",reset_code=self._reset,**kwargs) - def Gold(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Gold}",reset_code=self._reset,**kwargs) - def DarkGoldenRod(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkGoldenRod}",reset_code=self._reset,**kwargs) - def GoldenRod(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.GoldenRod}",reset_code=self._reset,**kwargs) - def PaleGoldenRod(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleGoldenRod}",reset_code=self._reset,**kwargs) - def DarkKhaki(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkKhaki}",reset_code=self._reset,**kwargs) - def Khaki(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Khaki}",reset_code=self._reset,**kwargs) - def Olive(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Olive}",reset_code=self._reset,**kwargs) - def Yellow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Yellow}",reset_code=self._reset,**kwargs) - def YellowGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.YellowGreen}",reset_code=self._reset,**kwargs) - def DarkOliveGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkOliveGreen}",reset_code=self._reset,**kwargs) - def OliveDrab(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.OliveDrab}",reset_code=self._reset,**kwargs) - def LawnGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LawnGreen}",reset_code=self._reset,**kwargs) - def Chartreuse(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Chartreuse}",reset_code=self._reset,**kwargs) - def GreenYellow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.GreenYellow}",reset_code=self._reset,**kwargs) - def DarkGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkGreen}",reset_code=self._reset,**kwargs) - def Green(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Green}",reset_code=self._reset,**kwargs) - def ForestGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.ForestGreen}",reset_code=self._reset,**kwargs) - def Lime(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Lime}",reset_code=self._reset,**kwargs) - def LimeGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LimeGreen}",reset_code=self._reset,**kwargs) - def LightGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightGreen}",reset_code=self._reset,**kwargs) - def PaleGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleGreen}",reset_code=self._reset,**kwargs) - def DarkSeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSeaGreen}",reset_code=self._reset,**kwargs) - def MediumSpringGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumSpringGreen}",reset_code=self._reset,**kwargs) - def SpringGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SpringGreen}",reset_code=self._reset,**kwargs) - def SeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SeaGreen}",reset_code=self._reset,**kwargs) - def MediumAquaMarine(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumAquaMarine}",reset_code=self._reset,**kwargs) - def MediumSeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumSeaGreen}",reset_code=self._reset,**kwargs) - def LightSeaGreen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSeaGreen}",reset_code=self._reset,**kwargs) - def DarkSlateGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSlateGray}",reset_code=self._reset,**kwargs) - def Teal(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Teal}",reset_code=self._reset,**kwargs) - def DarkCyan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkCyan}",reset_code=self._reset,**kwargs) - def Aqua(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Aqua}",reset_code=self._reset,**kwargs) - def Cyan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Cyan}",reset_code=self._reset,**kwargs) - def LightCyan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightCyan}",reset_code=self._reset,**kwargs) - def DarkTurquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkTurquoise}",reset_code=self._reset,**kwargs) - def Turquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Turquoise}",reset_code=self._reset,**kwargs) - def MediumTurquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumTurquoise}",reset_code=self._reset,**kwargs) - def PaleTurquoise(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleTurquoise}",reset_code=self._reset,**kwargs) - def AquaMarine(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.AquaMarine}",reset_code=self._reset,**kwargs) - def PowderBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PowderBlue}",reset_code=self._reset,**kwargs) - def CadetBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.CadetBlue}",reset_code=self._reset,**kwargs) - def SteelBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SteelBlue}",reset_code=self._reset,**kwargs) - def CornFlowerBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.CornFlowerBlue}",reset_code=self._reset,**kwargs) - def DeepSkyBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DeepSkyBlue}",reset_code=self._reset,**kwargs) - def DodgerBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DodgerBlue}",reset_code=self._reset,**kwargs) - def LightBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightBlue}",reset_code=self._reset,**kwargs) - def SkyBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SkyBlue}",reset_code=self._reset,**kwargs) - def LightSkyBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSkyBlue}",reset_code=self._reset,**kwargs) - def MidnightBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MidnightBlue}",reset_code=self._reset,**kwargs) - def Navy(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Navy}",reset_code=self._reset,**kwargs) - def DarkBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkBlue}",reset_code=self._reset,**kwargs) - def MediumBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumBlue}",reset_code=self._reset,**kwargs) - def Blue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Blue}",reset_code=self._reset,**kwargs) - def RoyalBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.RoyalBlue}",reset_code=self._reset,**kwargs) - def BlueViolet(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.BlueViolet}",reset_code=self._reset,**kwargs) - def Indigo(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Indigo}",reset_code=self._reset,**kwargs) - def DarkSlateBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkSlateBlue}",reset_code=self._reset,**kwargs) - def SlateBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SlateBlue}",reset_code=self._reset,**kwargs) - def MediumSlateBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumSlateBlue}",reset_code=self._reset,**kwargs) - def MediumPurple(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumPurple}",reset_code=self._reset,**kwargs) - def DarkMagenta(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkMagenta}",reset_code=self._reset,**kwargs) - def DarkViolet(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkViolet}",reset_code=self._reset,**kwargs) - def DarkOrchid(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkOrchid}",reset_code=self._reset,**kwargs) - def MediumOrchid(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumOrchid}",reset_code=self._reset,**kwargs) - def Purple(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Purple}",reset_code=self._reset,**kwargs) - def Thistle(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Thistle}",reset_code=self._reset,**kwargs) - def Plum(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Plum}",reset_code=self._reset,**kwargs) - def Violet(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Violet}",reset_code=self._reset,**kwargs) - def Magenta(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Magenta}",reset_code=self._reset,**kwargs) - def Orchid(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Orchid}",reset_code=self._reset,**kwargs) - def MediumVioletRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MediumVioletRed}",reset_code=self._reset,**kwargs) - def PaleVioletRed(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PaleVioletRed}",reset_code=self._reset,**kwargs) - def DeepPink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DeepPink}",reset_code=self._reset,**kwargs) - def HotPink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.HotPink}",reset_code=self._reset,**kwargs) - def LightPink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightPink}",reset_code=self._reset,**kwargs) - def Pink(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Pink}",reset_code=self._reset,**kwargs) - def AntiqueWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.AntiqueWhite}",reset_code=self._reset,**kwargs) - def Beige(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Beige}",reset_code=self._reset,**kwargs) - def Bisque(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Bisque}",reset_code=self._reset,**kwargs) - def BlanchedAlmond(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.BlanchedAlmond}",reset_code=self._reset,**kwargs) - def Wheat(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Wheat}",reset_code=self._reset,**kwargs) - def CornSilk(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.CornSilk}",reset_code=self._reset,**kwargs) - def LemonChiffon(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LemonChiffon}",reset_code=self._reset,**kwargs) - def LightGoldenRodYellow(self, *obj, **kwargs):return NCS(*obj,control_code=f"{self._param_code}{HC.LightGoldenRodYellow}",reset_code=self._reset,**kwargs) - def LightYellow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightYellow}",reset_code=self._reset,**kwargs) - def SaddleBrown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SaddleBrown}",reset_code=self._reset,**kwargs) - def Sienna(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Sienna}",reset_code=self._reset,**kwargs) - def Chocolate(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Chocolate}",reset_code=self._reset,**kwargs) - def Peru(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Peru}",reset_code=self._reset,**kwargs) - def SandyBrown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SandyBrown}",reset_code=self._reset,**kwargs) - def BurlyWood(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.BurlyWood}",reset_code=self._reset,**kwargs) - def Tan(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Tan}",reset_code=self._reset,**kwargs) - def RosyBrown(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.RosyBrown}",reset_code=self._reset,**kwargs) - def Moccasin(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Moccasin}",reset_code=self._reset,**kwargs) - def NavajoWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.NavajoWhite}",reset_code=self._reset,**kwargs) - def PeachPuff(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PeachPuff}",reset_code=self._reset,**kwargs) - def MistyRose(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MistyRose}",reset_code=self._reset,**kwargs) - def LavenderBlush(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LavenderBlush}",reset_code=self._reset,**kwargs) - def Linen(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Linen}",reset_code=self._reset,**kwargs) - def OldLace(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.OldLace}",reset_code=self._reset,**kwargs) - def PapayaWhip(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.PapayaWhip}",reset_code=self._reset,**kwargs) - def WeaShell(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.WeaShell}",reset_code=self._reset,**kwargs) - def MintCream(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.MintCream}",reset_code=self._reset,**kwargs) - def SlateGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.SlateGray}",reset_code=self._reset,**kwargs) - def LightSlateGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSlateGray}",reset_code=self._reset,**kwargs) - def LightSteelBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightSteelBlue}",reset_code=self._reset,**kwargs) - def Lavender(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Lavender}",reset_code=self._reset,**kwargs) - def FloralWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.FloralWhite}",reset_code=self._reset,**kwargs) - def AliceBlue(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.AliceBlue}",reset_code=self._reset,**kwargs) - def GhostWhite(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.GhostWhite}",reset_code=self._reset,**kwargs) - def Honeydew(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Honeydew}",reset_code=self._reset,**kwargs) - def Ivory(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Ivory}",reset_code=self._reset,**kwargs) - def Azure(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Azure}",reset_code=self._reset,**kwargs) - def Snow(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Snow}",reset_code=self._reset,**kwargs) - def Black(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Black}",reset_code=self._reset,**kwargs) - def DimGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DimGray}",reset_code=self._reset,**kwargs) - def Gray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Gray}",reset_code=self._reset,**kwargs) - def DarkGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.DarkGray}",reset_code=self._reset,**kwargs) - def Silver(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Silver}",reset_code=self._reset,**kwargs) - def LightGray(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.LightGray}",reset_code=self._reset,**kwargs) - def Gainsboro(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.Gainsboro}",reset_code=self._reset,**kwargs) - def WhiteSmoke(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.WhiteSmoke}",reset_code=self._reset,**kwargs) - def White(self, *obj, **kwargs): return NCS(*obj,control_code=f"{self._param_code}{HC.White}",reset_code=self._reset,**kwargs) \ No newline at end of file + def Maroon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Maroon}",reset_code=self._reset,sep=sep) + def DarkRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkRed}",reset_code=self._reset,sep=sep) + def Brown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Brown}",reset_code=self._reset,sep=sep) + def Firebrick(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Firebrick}",reset_code=self._reset,sep=sep) + def Crimson(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Crimson}",reset_code=self._reset,sep=sep) + def Red(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Red}",reset_code=self._reset,sep=sep) + def Tomato(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Tomato}",reset_code=self._reset,sep=sep) + def Coral(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Coral}",reset_code=self._reset,sep=sep) + def IndianRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.IndianRed}",reset_code=self._reset,sep=sep) + def LightCoral(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightCoral}",reset_code=self._reset,sep=sep) + def DarkSalmon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSalmon}",reset_code=self._reset,sep=sep) + def Salmon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Salmon}",reset_code=self._reset,sep=sep) + def LightSalmon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSalmon}",reset_code=self._reset,sep=sep) + def OrangeRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.OrangeRed}",reset_code=self._reset,sep=sep) + def DarkOrange(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkOrange}",reset_code=self._reset,sep=sep) + def Orange(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Orange}",reset_code=self._reset,sep=sep) + def Gold(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Gold}",reset_code=self._reset,sep=sep) + def DarkGoldenRod(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkGoldenRod}",reset_code=self._reset,sep=sep) + def GoldenRod(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.GoldenRod}",reset_code=self._reset,sep=sep) + def PaleGoldenRod(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleGoldenRod}",reset_code=self._reset,sep=sep) + def DarkKhaki(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkKhaki}",reset_code=self._reset,sep=sep) + def Khaki(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Khaki}",reset_code=self._reset,sep=sep) + def Olive(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Olive}",reset_code=self._reset,sep=sep) + def Yellow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Yellow}",reset_code=self._reset,sep=sep) + def YellowGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.YellowGreen}",reset_code=self._reset,sep=sep) + def DarkOliveGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkOliveGreen}",reset_code=self._reset,sep=sep) + def OliveDrab(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.OliveDrab}",reset_code=self._reset,sep=sep) + def LawnGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LawnGreen}",reset_code=self._reset,sep=sep) + def Chartreuse(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Chartreuse}",reset_code=self._reset,sep=sep) + def GreenYellow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.GreenYellow}",reset_code=self._reset,sep=sep) + def DarkGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkGreen}",reset_code=self._reset,sep=sep) + def Green(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Green}",reset_code=self._reset,sep=sep) + def ForestGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.ForestGreen}",reset_code=self._reset,sep=sep) + def Lime(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Lime}",reset_code=self._reset,sep=sep) + def LimeGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LimeGreen}",reset_code=self._reset,sep=sep) + def LightGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightGreen}",reset_code=self._reset,sep=sep) + def PaleGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleGreen}",reset_code=self._reset,sep=sep) + def DarkSeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSeaGreen}",reset_code=self._reset,sep=sep) + def MediumSpringGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumSpringGreen}",reset_code=self._reset,sep=sep) + def SpringGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SpringGreen}",reset_code=self._reset,sep=sep) + def SeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SeaGreen}",reset_code=self._reset,sep=sep) + def MediumAquaMarine(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumAquaMarine}",reset_code=self._reset,sep=sep) + def MediumSeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumSeaGreen}",reset_code=self._reset,sep=sep) + def LightSeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSeaGreen}",reset_code=self._reset,sep=sep) + def DarkSlateGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSlateGray}",reset_code=self._reset,sep=sep) + def Teal(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Teal}",reset_code=self._reset,sep=sep) + def DarkCyan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkCyan}",reset_code=self._reset,sep=sep) + def Aqua(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Aqua}",reset_code=self._reset,sep=sep) + def Cyan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Cyan}",reset_code=self._reset,sep=sep) + def LightCyan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightCyan}",reset_code=self._reset,sep=sep) + def DarkTurquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkTurquoise}",reset_code=self._reset,sep=sep) + def Turquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Turquoise}",reset_code=self._reset,sep=sep) + def MediumTurquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumTurquoise}",reset_code=self._reset,sep=sep) + def PaleTurquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleTurquoise}",reset_code=self._reset,sep=sep) + def AquaMarine(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.AquaMarine}",reset_code=self._reset,sep=sep) + def PowderBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PowderBlue}",reset_code=self._reset,sep=sep) + def CadetBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.CadetBlue}",reset_code=self._reset,sep=sep) + def SteelBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SteelBlue}",reset_code=self._reset,sep=sep) + def CornFlowerBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.CornFlowerBlue}",reset_code=self._reset,sep=sep) + def DeepSkyBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DeepSkyBlue}",reset_code=self._reset,sep=sep) + def DodgerBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DodgerBlue}",reset_code=self._reset,sep=sep) + def LightBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightBlue}",reset_code=self._reset,sep=sep) + def SkyBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SkyBlue}",reset_code=self._reset,sep=sep) + def LightSkyBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSkyBlue}",reset_code=self._reset,sep=sep) + def MidnightBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MidnightBlue}",reset_code=self._reset,sep=sep) + def Navy(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Navy}",reset_code=self._reset,sep=sep) + def DarkBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkBlue}",reset_code=self._reset,sep=sep) + def MediumBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumBlue}",reset_code=self._reset,sep=sep) + def Blue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Blue}",reset_code=self._reset,sep=sep) + def RoyalBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.RoyalBlue}",reset_code=self._reset,sep=sep) + def BlueViolet(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.BlueViolet}",reset_code=self._reset,sep=sep) + def Indigo(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Indigo}",reset_code=self._reset,sep=sep) + def DarkSlateBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSlateBlue}",reset_code=self._reset,sep=sep) + def SlateBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SlateBlue}",reset_code=self._reset,sep=sep) + def MediumSlateBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumSlateBlue}",reset_code=self._reset,sep=sep) + def MediumPurple(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumPurple}",reset_code=self._reset,sep=sep) + def DarkMagenta(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkMagenta}",reset_code=self._reset,sep=sep) + def DarkViolet(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkViolet}",reset_code=self._reset,sep=sep) + def DarkOrchid(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkOrchid}",reset_code=self._reset,sep=sep) + def MediumOrchid(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumOrchid}",reset_code=self._reset,sep=sep) + def Purple(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Purple}",reset_code=self._reset,sep=sep) + def Thistle(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Thistle}",reset_code=self._reset,sep=sep) + def Plum(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Plum}",reset_code=self._reset,sep=sep) + def Violet(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Violet}",reset_code=self._reset,sep=sep) + def Magenta(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Magenta}",reset_code=self._reset,sep=sep) + def Orchid(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Orchid}",reset_code=self._reset,sep=sep) + def MediumVioletRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumVioletRed}",reset_code=self._reset,sep=sep) + def PaleVioletRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleVioletRed}",reset_code=self._reset,sep=sep) + def DeepPink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DeepPink}",reset_code=self._reset,sep=sep) + def HotPink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.HotPink}",reset_code=self._reset,sep=sep) + def LightPink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightPink}",reset_code=self._reset,sep=sep) + def Pink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Pink}",reset_code=self._reset,sep=sep) + def AntiqueWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.AntiqueWhite}",reset_code=self._reset,sep=sep) + def Beige(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Beige}",reset_code=self._reset,sep=sep) + def Bisque(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Bisque}",reset_code=self._reset,sep=sep) + def BlanchedAlmond(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.BlanchedAlmond}",reset_code=self._reset,sep=sep) + def Wheat(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Wheat}",reset_code=self._reset,sep=sep) + def CornSilk(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.CornSilk}",reset_code=self._reset,sep=sep) + def LemonChiffon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LemonChiffon}",reset_code=self._reset,sep=sep) + def LightGoldenRodYellow(self, *obj, sep=" "):return NCS(obj,control_code=f"{self._param_code}{HC.LightGoldenRodYellow}",reset_code=self._reset,sep=sep) + def LightYellow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightYellow}",reset_code=self._reset,sep=sep) + def SaddleBrown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SaddleBrown}",reset_code=self._reset,sep=sep) + def Sienna(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Sienna}",reset_code=self._reset,sep=sep) + def Chocolate(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Chocolate}",reset_code=self._reset,sep=sep) + def Peru(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Peru}",reset_code=self._reset,sep=sep) + def SandyBrown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SandyBrown}",reset_code=self._reset,sep=sep) + def BurlyWood(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.BurlyWood}",reset_code=self._reset,sep=sep) + def Tan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Tan}",reset_code=self._reset,sep=sep) + def RosyBrown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.RosyBrown}",reset_code=self._reset,sep=sep) + def Moccasin(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Moccasin}",reset_code=self._reset,sep=sep) + def NavajoWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.NavajoWhite}",reset_code=self._reset,sep=sep) + def PeachPuff(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PeachPuff}",reset_code=self._reset,sep=sep) + def MistyRose(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MistyRose}",reset_code=self._reset,sep=sep) + def LavenderBlush(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LavenderBlush}",reset_code=self._reset,sep=sep) + def Linen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Linen}",reset_code=self._reset,sep=sep) + def OldLace(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.OldLace}",reset_code=self._reset,sep=sep) + def PapayaWhip(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PapayaWhip}",reset_code=self._reset,sep=sep) + def WeaShell(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.WeaShell}",reset_code=self._reset,sep=sep) + def MintCream(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MintCream}",reset_code=self._reset,sep=sep) + def SlateGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SlateGray}",reset_code=self._reset,sep=sep) + def LightSlateGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSlateGray}",reset_code=self._reset,sep=sep) + def LightSteelBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSteelBlue}",reset_code=self._reset,sep=sep) + def Lavender(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Lavender}",reset_code=self._reset,sep=sep) + def FloralWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.FloralWhite}",reset_code=self._reset,sep=sep) + def AliceBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.AliceBlue}",reset_code=self._reset,sep=sep) + def GhostWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.GhostWhite}",reset_code=self._reset,sep=sep) + def Honeydew(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Honeydew}",reset_code=self._reset,sep=sep) + def Ivory(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Ivory}",reset_code=self._reset,sep=sep) + def Azure(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Azure}",reset_code=self._reset,sep=sep) + def Snow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Snow}",reset_code=self._reset,sep=sep) + def Black(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Black}",reset_code=self._reset,sep=sep) + def DimGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DimGray}",reset_code=self._reset,sep=sep) + def Gray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Gray}",reset_code=self._reset,sep=sep) + def DarkGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkGray}",reset_code=self._reset,sep=sep) + def Silver(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Silver}",reset_code=self._reset,sep=sep) + def LightGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightGray}",reset_code=self._reset,sep=sep) + def Gainsboro(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Gainsboro}",reset_code=self._reset,sep=sep) + def WhiteSmoke(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.WhiteSmoke}",reset_code=self._reset,sep=sep) + def White(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.White}",reset_code=self._reset,sep=sep) \ No newline at end of file From 5b9338a3918a17c37db844f1b3edd2b7ca47706b Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 00:30:18 +0200 Subject: [PATCH 28/40] Fix: missed NCSNO --- src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py index 680e755..9956a20 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py @@ -149,7 +149,7 @@ def SuperScript(*obj, sep=" "): return NCS(obj, control_code=73, @staticmethod def SubScript(*obj, sep=" "): return NCS(obj, control_code=74, reset_code=75, sep=sep) @staticmethod - def NoScript(*obj, sep=" "): return NCS(obj, control_code=75, sep=sep) + def NoScript(*obj, sep=" "): return NCSNO(obj, control_code=75, sep=sep) # ---------------------------------------------------------------------------------------------------------------------- # - BasicNest Sequences - From 6bdb9a4cbcae746e4df7da3d98e3a6d3221ce4c2 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 00:50:02 +0200 Subject: [PATCH 29/40] Change: Further Speedup of Nested --- src/AthenaColor/Data/HtmlColors.py | 142 ------ .../Console/Styling/Nested/BackNest.py | 476 ++++++++++++++++++ .../Console/Styling/Nested/ForeNest.py | 476 ++++++++++++++++++ .../Console/Styling/Nested/Nested_Bodies.py | 35 -- .../Console/Styling/Nested/Nested_MakeUp.py | 22 - .../Styling/Nested/RgbControlledNest.py | 197 -------- .../Console/Styling/Nested/UnderlineNest.py | 476 ++++++++++++++++++ src/AthenaColor/__init__.py | 7 +- 8 files changed, 1432 insertions(+), 399 deletions(-) create mode 100644 src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py create mode 100644 src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py delete mode 100644 src/AthenaColor/Objects/Console/Styling/Nested/Nested_Bodies.py delete mode 100644 src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py create mode 100644 src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py diff --git a/src/AthenaColor/Data/HtmlColors.py b/src/AthenaColor/Data/HtmlColors.py index 2c8be9d..b040055 100644 --- a/src/AthenaColor/Data/HtmlColors.py +++ b/src/AthenaColor/Data/HtmlColors.py @@ -12,148 +12,6 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- -class HtmlColorStr: - Maroon = "128;0;0" - DarkRed = "139;0;0" - Brown = "165;42;42" - Firebrick = "178;34;34" - Crimson = "220;20;60" - Red = "255;0;0" - Tomato = "255;99;71" - Coral = "255;127;80" - IndianRed = "205;92;92" - LightCoral = "240;128;128" - DarkSalmon = "233;150;122" - Salmon = "250;128;114" - LightSalmon = "255;160;122" - OrangeRed = "255;69;0" - DarkOrange = "255;140;0" - Orange = "255;165;0" - Gold = "255;215;0" - DarkGoldenRod = "184;134;11" - GoldenRod = "218;165;32" - PaleGoldenRod = "238;232;170" - DarkKhaki = "189;183;107" - Khaki = "240;230;140" - Olive = "128;128;0" - Yellow = "255;255;0" - YellowGreen = "154;205;50" - DarkOliveGreen = "85;107;47" - OliveDrab = "107;142;35" - LawnGreen = "124;252;0" - Chartreuse = "127;255;0" - GreenYellow = "173;255;47" - DarkGreen = "0;100;0" - Green = "0;128;0" - ForestGreen = "34;139;34" - Lime = "0;255;0" - LimeGreen = "50;205;50" - LightGreen = "144;238;144" - PaleGreen = "152;251;152" - DarkSeaGreen = "143;188;143" - MediumSpringGreen = "0;250;154" - SpringGreen = "0;255;127" - SeaGreen = "46;139;87" - MediumAquaMarine = "102;205;170" - MediumSeaGreen = "60;179;113" - LightSeaGreen = "32;178;170" - DarkSlateGray = "47;79 ;79" - Teal = "0;128;128" - DarkCyan = "0;139;139" - Aqua = "0;255;255" - Cyan = "0;255;255" - LightCyan = "224;255;255" - DarkTurquoise = "0;206;209" - Turquoise = "64;224;208" - MediumTurquoise = "72;209;204" - PaleTurquoise = "175;238;238" - AquaMarine = "127;255;212" - PowderBlue = "176;224;230" - CadetBlue = "95;158;160" - SteelBlue = "70;130;180" - CornFlowerBlue = "100;149;237" - DeepSkyBlue = "0;191;255" - DodgerBlue = "30;144;255" - LightBlue = "173;216;230" - SkyBlue = "135;206;235" - LightSkyBlue = "135;206;250" - MidnightBlue = "25;25;112" - Navy = "0;0;128" - DarkBlue = "0;0;139" - MediumBlue = "0;0;205" - Blue = "0;0;255" - RoyalBlue = "65;105;225" - BlueViolet = "138;43;226" - Indigo = "75;0;130" - DarkSlateBlue = "72;61;139" - SlateBlue = "106;90;205" - MediumSlateBlue = "123;104;238" - MediumPurple = "147;112;219" - DarkMagenta = "139;0;139" - DarkViolet = "148;0;211" - DarkOrchid = "153;50;204" - MediumOrchid = "186;85;211" - Purple = "128;0;128" - Thistle = "216;191;216" - Plum = "221;160;221" - Violet = "238;130;238" - Magenta = "255;0;255" - Orchid = "218;112;214" - MediumVioletRed = "199;21;133" - PaleVioletRed = "219;112;147" - DeepPink = "255;20;147" - HotPink = "255;105;180" - LightPink = "255;182;193" - Pink = "255;192;203" - AntiqueWhite = "250;235;215" - Beige = "245;245;220" - Bisque = "255;228;196" - BlanchedAlmond = "255;235;205" - Wheat = "245;222;179" - CornSilk = "255;248;220" - LemonChiffon = "255;250;205" - LightGoldenRodYellow = "250;250;210" - LightYellow = "255;255;224" - SaddleBrown = "139;69;19" - Sienna = "160;82;45" - Chocolate = "210;105;30" - Peru = "205;133;63" - SandyBrown = "244;164;96" - BurlyWood = "222;184;135" - Tan = "210;180;140" - RosyBrown = "188;143;143" - Moccasin = "255;228;181" - NavajoWhite = "255;222;173" - PeachPuff = "255;218;185" - MistyRose = "255;228;225" - LavenderBlush = "255;240;245" - Linen = "250;240;230" - OldLace = "253;245;230" - PapayaWhip = "255;239;213" - WeaShell = "255;245;238" - MintCream = "245;255;250" - SlateGray = "112;128;144" - LightSlateGray = "119;136;153" - LightSteelBlue = "176;196;222" - Lavender = "230;230;250" - FloralWhite = "255;250;240" - AliceBlue = "240;248;255" - GhostWhite = "248;248;255" - Honeydew = "240;255;240" - Ivory = "255;255;240" - Azure = "240;255;255" - Snow = "255;250;250" - Black = "0;0;0" - DimGray = "105;105;105" - Gray = "128;128;128" - DarkGray = "169;169;169" - Silver = "192;192;192" - LightGray = "211;211;211" - Gainsboro = "220;220;220" - WhiteSmoke = "245;245;245" - White = "255;255;255" - - class HtmlColorObjects: Maroon = RGB(128,0 ,0) DarkRed = RGB(139,0 ,0) diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py new file mode 100644 index 0000000..85b43a4 --- /dev/null +++ b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py @@ -0,0 +1,476 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - Package Imports - +# ---------------------------------------------------------------------------------------------------------------------- +# General Packages +from __future__ import annotations + +# Custom Library + +# Custom Packages +from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb +from AthenaColor.Functions.ANSIsquences import NestedColorSequence +from AthenaColor.Functions.General import StrictType + +# ---------------------------------------------------------------------------------------------------------------------- +# - All - +# ---------------------------------------------------------------------------------------------------------------------- +__all__=[ + "BackNest" +] + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase +resetCode=49 +sep_=" " + +# Predefined Strings to speed calls up +Maroon =f"48;2;128;0;0" +DarkRed =f"48;2;139;0;0" +Brown =f"48;2;165;42;42" +Firebrick =f"48;2;178;34;34" +Crimson =f"48;2;220;20;60" +Red =f"48;2;255;0;0" +Tomato =f"48;2;255;99;71" +Coral =f"48;2;255;127;80" +IndianRed =f"48;2;205;92;92" +LightCoral =f"48;2;240;128;128" +DarkSalmon =f"48;2;233;150;122" +Salmon =f"48;2;250;128;114" +LightSalmon =f"48;2;255;160;122" +OrangeRed =f"48;2;255;69;0" +DarkOrange =f"48;2;255;140;0" +Orange =f"48;2;255;165;0" +Gold =f"48;2;255;215;0" +DarkGoldenRod =f"48;2;184;134;11" +GoldenRod =f"48;2;218;165;32" +PaleGoldenRod =f"48;2;238;232;170" +DarkKhaki =f"48;2;189;183;107" +Khaki =f"48;2;240;230;140" +Olive =f"48;2;128;128;0" +Yellow =f"48;2;255;255;0" +YellowGreen =f"48;2;154;205;50" +DarkOliveGreen =f"48;2;85;107;47" +OliveDrab =f"48;2;107;142;35" +LawnGreen =f"48;2;124;252;0" +Chartreuse =f"48;2;127;255;0" +GreenYellow =f"48;2;173;255;47" +DarkGreen =f"48;2;0;100;0" +Green =f"48;2;0;128;0" +ForestGreen =f"48;2;34;139;34" +Lime =f"48;2;0;255;0" +LimeGreen =f"48;2;50;205;50" +LightGreen =f"48;2;144;238;144" +PaleGreen =f"48;2;152;251;152" +DarkSeaGreen =f"48;2;143;188;143" +MediumSpringGreen =f"48;2;0;250;154" +SpringGreen =f"48;2;0;255;127" +SeaGreen =f"48;2;46;139;87" +MediumAquaMarine =f"48;2;102;205;170" +MediumSeaGreen =f"48;2;60;179;113" +LightSeaGreen =f"48;2;32;178;170" +DarkSlateGray =f"48;2;47;79 ;79" +Teal =f"48;2;0;128;128" +DarkCyan =f"48;2;0;139;139" +Aqua =f"48;2;0;255;255" +Cyan =f"48;2;0;255;255" +LightCyan =f"48;2;224;255;255" +DarkTurquoise =f"48;2;0;206;209" +Turquoise =f"48;2;64;224;208" +MediumTurquoise =f"48;2;72;209;204" +PaleTurquoise =f"48;2;175;238;238" +AquaMarine =f"48;2;127;255;212" +PowderBlue =f"48;2;176;224;230" +CadetBlue =f"48;2;95;158;160" +SteelBlue =f"48;2;70;130;180" +CornFlowerBlue =f"48;2;100;149;237" +DeepSkyBlue =f"48;2;0;191;255" +DodgerBlue =f"48;2;30;144;255" +LightBlue =f"48;2;173;216;230" +SkyBlue =f"48;2;135;206;235" +LightSkyBlue =f"48;2;135;206;250" +MidnightBlue =f"48;2;25;25;112" +Navy =f"48;2;0;0;128" +DarkBlue =f"48;2;0;0;139" +MediumBlue =f"48;2;0;0;205" +Blue =f"48;2;0;0;255" +RoyalBlue =f"48;2;65;105;225" +BlueViolet =f"48;2;138;43;226" +Indigo =f"48;2;75;0;130" +DarkSlateBlue =f"48;2;72;61;139" +SlateBlue =f"48;2;106;90;205" +MediumSlateBlue =f"48;2;123;104;238" +MediumPurple =f"48;2;147;112;219" +DarkMagenta =f"48;2;139;0;139" +DarkViolet =f"48;2;148;0;211" +DarkOrchid =f"48;2;153;50;204" +MediumOrchid =f"48;2;186;85;211" +Purple =f"48;2;128;0;128" +Thistle =f"48;2;216;191;216" +Plum =f"48;2;221;160;221" +Violet =f"48;2;238;130;238" +Magenta =f"48;2;255;0;255" +Orchid =f"48;2;218;112;214" +MediumVioletRed =f"48;2;199;21;133" +PaleVioletRed =f"48;2;219;112;147" +DeepPink =f"48;2;255;20;147" +HotPink =f"48;2;255;105;180" +LightPink =f"48;2;255;182;193" +Pink =f"48;2;255;192;203" +AntiqueWhite =f"48;2;250;235;215" +Beige =f"48;2;245;245;220" +Bisque =f"48;2;255;228;196" +BlanchedAlmond =f"48;2;255;235;205" +Wheat =f"48;2;245;222;179" +CornSilk =f"48;2;255;248;220" +LemonChiffon =f"48;2;255;250;205" +LightGoldenRodYellow =f"48;2;250;250;210" +LightYellow =f"48;2;255;255;224" +SaddleBrown =f"48;2;139;69;19" +Sienna =f"48;2;160;82;45" +Chocolate =f"48;2;210;105;30" +Peru =f"48;2;205;133;63" +SandyBrown =f"48;2;244;164;96" +BurlyWood =f"48;2;222;184;135" +Tan =f"48;2;210;180;140" +RosyBrown =f"48;2;188;143;143" +Moccasin =f"48;2;255;228;181" +NavajoWhite =f"48;2;255;222;173" +PeachPuff =f"48;2;255;218;185" +MistyRose =f"48;2;255;228;225" +LavenderBlush =f"48;2;255;240;245" +Linen =f"48;2;250;240;230" +OldLace =f"48;2;253;245;230" +PapayaWhip =f"48;2;255;239;213" +WeaShell =f"48;2;255;245;238" +MintCream =f"48;2;245;255;250" +SlateGray =f"48;2;112;128;144" +LightSlateGray =f"48;2;119;136;153" +LightSteelBlue =f"48;2;176;196;222" +Lavender =f"48;2;230;230;250" +FloralWhite =f"48;2;255;250;240" +AliceBlue =f"48;2;240;248;255" +GhostWhite =f"48;2;248;248;255" +Honeydew =f"48;2;240;255;240" +Ivory =f"48;2;255;255;240" +Azure =f"48;2;240;255;255" +Snow =f"48;2;255;250;250" +Black =f"48;2;0;0;0" +DimGray =f"48;2;105;105;105" +Gray =f"48;2;128;128;128" +DarkGray =f"48;2;169;169;169" +Silver =f"48;2;192;192;192" +LightGray =f"48;2;211;211;211" +Gainsboro =f"48;2;220;220;220" +WhiteSmoke =f"48;2;245;245;245" +White =f"48;2;255;255;255" + +class BackNest: + # ------------------------------------------------------------------------------------------------------------------ + # - Methods - + # ------------------------------------------------------------------------------------------------------------------ + @staticmethod + def custom(*obj, color:RGB|HEX, **kwargs) -> str: + # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' + color = StrictType(color,(RGB,HEX)) + return NestedColorSequence( + *obj, + control_code=f"48;2;{color.r};{color.g};{color.b}", + reset_code=resetCode, + **kwargs + ) + + @staticmethod + def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: + # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' + r,g,b = NormalizeRgb(r, g, b) + return NestedColorSequence( + *obj, + control_code=f"48;2;{r};{g};{b}", + reset_code=resetCode, + **kwargs + ) + + # ------------------------------------------------------------------------------------------------------------------ + # - HTML colors - + # ------------------------------------------------------------------------------------------------------------------ + # No partial methods, as this was increase the speed impact 2-fold + @staticmethod + def Maroon(*obj, sep=sep_): return NCS(obj,Maroon,resetCode,sep) + @staticmethod + def DarkRed(*obj, sep=sep_): return NCS(obj,DarkRed,resetCode,sep) + @staticmethod + def Brown(*obj, sep=sep_): return NCS(obj,Brown,resetCode,sep) + @staticmethod + def Firebrick(*obj, sep=sep_): return NCS(obj,Firebrick,resetCode,sep) + @staticmethod + def Crimson(*obj, sep=sep_): return NCS(obj,Crimson,resetCode,sep) + @staticmethod + def Red(*obj, sep=sep_): return NCS(obj,Red,resetCode,sep) + @staticmethod + def Tomato(*obj, sep=sep_): return NCS(obj,Tomato,resetCode,sep) + @staticmethod + def Coral(*obj, sep=sep_): return NCS(obj,Coral,resetCode,sep) + @staticmethod + def IndianRed(*obj, sep=sep_): return NCS(obj,IndianRed,resetCode,sep) + @staticmethod + def LightCoral(*obj, sep=sep_): return NCS(obj,LightCoral,resetCode,sep) + @staticmethod + def DarkSalmon(*obj, sep=sep_): return NCS(obj,DarkSalmon,resetCode,sep) + @staticmethod + def Salmon(*obj, sep=sep_): return NCS(obj,Salmon,resetCode,sep) + @staticmethod + def LightSalmon(*obj, sep=sep_): return NCS(obj,LightSalmon,resetCode,sep) + @staticmethod + def OrangeRed(*obj, sep=sep_): return NCS(obj,OrangeRed,resetCode,sep) + @staticmethod + def DarkOrange(*obj, sep=sep_): return NCS(obj,DarkOrange,resetCode,sep) + @staticmethod + def Orange(*obj, sep=sep_): return NCS(obj,Orange,resetCode,sep) + @staticmethod + def Gold(*obj, sep=sep_): return NCS(obj,Gold,resetCode,sep) + @staticmethod + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,DarkGoldenRod,resetCode,sep) + @staticmethod + def GoldenRod(*obj, sep=sep_): return NCS(obj,GoldenRod,resetCode,sep) + @staticmethod + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,PaleGoldenRod,resetCode,sep) + @staticmethod + def DarkKhaki(*obj, sep=sep_): return NCS(obj,DarkKhaki,resetCode,sep) + @staticmethod + def Khaki(*obj, sep=sep_): return NCS(obj,Khaki,resetCode,sep) + @staticmethod + def Olive(*obj, sep=sep_): return NCS(obj,Olive,resetCode,sep) + @staticmethod + def Yellow(*obj, sep=sep_): return NCS(obj,Yellow,resetCode,sep) + @staticmethod + def YellowGreen(*obj, sep=sep_): return NCS(obj,YellowGreen,resetCode,sep) + @staticmethod + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,DarkOliveGreen,resetCode,sep) + @staticmethod + def OliveDrab(*obj, sep=sep_): return NCS(obj,OliveDrab,resetCode,sep) + @staticmethod + def LawnGreen(*obj, sep=sep_): return NCS(obj,LawnGreen,resetCode,sep) + @staticmethod + def Chartreuse(*obj, sep=sep_): return NCS(obj,Chartreuse,resetCode,sep) + @staticmethod + def GreenYellow(*obj, sep=sep_): return NCS(obj,GreenYellow,resetCode,sep) + @staticmethod + def DarkGreen(*obj, sep=sep_): return NCS(obj,DarkGreen,resetCode,sep) + @staticmethod + def Green(*obj, sep=sep_): return NCS(obj,Green,resetCode,sep) + @staticmethod + def ForestGreen(*obj, sep=sep_): return NCS(obj,ForestGreen,resetCode,sep) + @staticmethod + def Lime(*obj, sep=sep_): return NCS(obj,Lime,resetCode,sep) + @staticmethod + def LimeGreen(*obj, sep=sep_): return NCS(obj,LimeGreen,resetCode,sep) + @staticmethod + def LightGreen(*obj, sep=sep_): return NCS(obj,LightGreen,resetCode,sep) + @staticmethod + def PaleGreen(*obj, sep=sep_): return NCS(obj,PaleGreen,resetCode,sep) + @staticmethod + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,DarkSeaGreen,resetCode,sep) + @staticmethod + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,MediumSpringGreen,resetCode,sep) + @staticmethod + def SpringGreen(*obj, sep=sep_): return NCS(obj,SpringGreen,resetCode,sep) + @staticmethod + def SeaGreen(*obj, sep=sep_): return NCS(obj,SeaGreen,resetCode,sep) + @staticmethod + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,MediumAquaMarine,resetCode,sep) + @staticmethod + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,MediumSeaGreen,resetCode,sep) + @staticmethod + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,LightSeaGreen,resetCode,sep) + @staticmethod + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,DarkSlateGray,resetCode,sep) + @staticmethod + def Teal(*obj, sep=sep_): return NCS(obj,Teal,resetCode,sep) + @staticmethod + def DarkCyan(*obj, sep=sep_): return NCS(obj,DarkCyan,resetCode,sep) + @staticmethod + def Aqua(*obj, sep=sep_): return NCS(obj,Aqua,resetCode,sep) + @staticmethod + def Cyan(*obj, sep=sep_): return NCS(obj,Cyan,resetCode,sep) + @staticmethod + def LightCyan(*obj, sep=sep_): return NCS(obj,LightCyan,resetCode,sep) + @staticmethod + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,DarkTurquoise,resetCode,sep) + @staticmethod + def Turquoise(*obj, sep=sep_): return NCS(obj,Turquoise,resetCode,sep) + @staticmethod + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,MediumTurquoise,resetCode,sep) + @staticmethod + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,PaleTurquoise,resetCode,sep) + @staticmethod + def AquaMarine(*obj, sep=sep_): return NCS(obj,AquaMarine,resetCode,sep) + @staticmethod + def PowderBlue(*obj, sep=sep_): return NCS(obj,PowderBlue,resetCode,sep) + @staticmethod + def CadetBlue(*obj, sep=sep_): return NCS(obj,CadetBlue,resetCode,sep) + @staticmethod + def SteelBlue(*obj, sep=sep_): return NCS(obj,SteelBlue,resetCode,sep) + @staticmethod + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,CornFlowerBlue,resetCode,sep) + @staticmethod + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,DeepSkyBlue,resetCode,sep) + @staticmethod + def DodgerBlue(*obj, sep=sep_): return NCS(obj,DodgerBlue,resetCode,sep) + @staticmethod + def LightBlue(*obj, sep=sep_): return NCS(obj,LightBlue,resetCode,sep) + @staticmethod + def SkyBlue(*obj, sep=sep_): return NCS(obj,SkyBlue,resetCode,sep) + @staticmethod + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,LightSkyBlue,resetCode,sep) + @staticmethod + def MidnightBlue(*obj, sep=sep_): return NCS(obj,MidnightBlue,resetCode,sep) + @staticmethod + def Navy(*obj, sep=sep_): return NCS(obj,Navy,resetCode,sep) + @staticmethod + def DarkBlue(*obj, sep=sep_): return NCS(obj,DarkBlue,resetCode,sep) + @staticmethod + def MediumBlue(*obj, sep=sep_): return NCS(obj,MediumBlue,resetCode,sep) + @staticmethod + def Blue(*obj, sep=sep_): return NCS(obj,Blue,resetCode,sep) + @staticmethod + def RoyalBlue(*obj, sep=sep_): return NCS(obj,RoyalBlue,resetCode,sep) + @staticmethod + def BlueViolet(*obj, sep=sep_): return NCS(obj,BlueViolet,resetCode,sep) + @staticmethod + def Indigo(*obj, sep=sep_): return NCS(obj,Indigo,resetCode,sep) + @staticmethod + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,DarkSlateBlue,resetCode,sep) + @staticmethod + def SlateBlue(*obj, sep=sep_): return NCS(obj,SlateBlue,resetCode,sep) + @staticmethod + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,MediumSlateBlue,resetCode,sep) + @staticmethod + def MediumPurple(*obj, sep=sep_): return NCS(obj,MediumPurple,resetCode,sep) + @staticmethod + def DarkMagenta(*obj, sep=sep_): return NCS(obj,DarkMagenta,resetCode,sep) + @staticmethod + def DarkViolet(*obj, sep=sep_): return NCS(obj,DarkViolet,resetCode,sep) + @staticmethod + def DarkOrchid(*obj, sep=sep_): return NCS(obj,DarkOrchid,resetCode,sep) + @staticmethod + def MediumOrchid(*obj, sep=sep_): return NCS(obj,MediumOrchid,resetCode,sep) + @staticmethod + def Purple(*obj, sep=sep_): return NCS(obj,Purple,resetCode,sep) + @staticmethod + def Thistle(*obj, sep=sep_): return NCS(obj,Thistle,resetCode,sep) + @staticmethod + def Plum(*obj, sep=sep_): return NCS(obj,Plum,resetCode,sep) + @staticmethod + def Violet(*obj, sep=sep_): return NCS(obj,Violet,resetCode,sep) + @staticmethod + def Magenta(*obj, sep=sep_): return NCS(obj,Magenta,resetCode,sep) + @staticmethod + def Orchid(*obj, sep=sep_): return NCS(obj,Orchid,resetCode,sep) + @staticmethod + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,MediumVioletRed,resetCode,sep) + @staticmethod + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,PaleVioletRed,resetCode,sep) + @staticmethod + def DeepPink(*obj, sep=sep_): return NCS(obj,DeepPink,resetCode,sep) + @staticmethod + def HotPink(*obj, sep=sep_): return NCS(obj,HotPink,resetCode,sep) + @staticmethod + def LightPink(*obj, sep=sep_): return NCS(obj,LightPink,resetCode,sep) + @staticmethod + def Pink(*obj, sep=sep_): return NCS(obj,Pink,resetCode,sep) + @staticmethod + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,AntiqueWhite,resetCode,sep) + @staticmethod + def Beige(*obj, sep=sep_): return NCS(obj,Beige,resetCode,sep) + @staticmethod + def Bisque(*obj, sep=sep_): return NCS(obj,Bisque,resetCode,sep) + @staticmethod + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,BlanchedAlmond,resetCode,sep) + @staticmethod + def Wheat(*obj, sep=sep_): return NCS(obj,Wheat,resetCode,sep) + @staticmethod + def CornSilk(*obj, sep=sep_): return NCS(obj,CornSilk,resetCode,sep) + @staticmethod + def LemonChiffon(*obj, sep=sep_): return NCS(obj,LemonChiffon,resetCode,sep) + @staticmethod + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,LightGoldenRodYellow,resetCode,sep) + @staticmethod + def LightYellow(*obj, sep=sep_): return NCS(obj,LightYellow,resetCode,sep) + @staticmethod + def SaddleBrown(*obj, sep=sep_): return NCS(obj,SaddleBrown,resetCode,sep) + @staticmethod + def Sienna(*obj, sep=sep_): return NCS(obj,Sienna,resetCode,sep) + @staticmethod + def Chocolate(*obj, sep=sep_): return NCS(obj,Chocolate,resetCode,sep) + @staticmethod + def Peru(*obj, sep=sep_): return NCS(obj,Peru,resetCode,sep) + @staticmethod + def SandyBrown(*obj, sep=sep_): return NCS(obj,SandyBrown,resetCode,sep) + @staticmethod + def BurlyWood(*obj, sep=sep_): return NCS(obj,BurlyWood,resetCode,sep) + @staticmethod + def Tan(*obj, sep=sep_): return NCS(obj,Tan,resetCode,sep) + @staticmethod + def RosyBrown(*obj, sep=sep_): return NCS(obj,RosyBrown,resetCode,sep) + @staticmethod + def Moccasin(*obj, sep=sep_): return NCS(obj,Moccasin,resetCode,sep) + @staticmethod + def NavajoWhite(*obj, sep=sep_): return NCS(obj,NavajoWhite,resetCode,sep) + @staticmethod + def PeachPuff(*obj, sep=sep_): return NCS(obj,PeachPuff,resetCode,sep) + @staticmethod + def MistyRose(*obj, sep=sep_): return NCS(obj,MistyRose,resetCode,sep) + @staticmethod + def LavenderBlush(*obj, sep=sep_): return NCS(obj,LavenderBlush,resetCode,sep) + @staticmethod + def Linen(*obj, sep=sep_): return NCS(obj,Linen,resetCode,sep) + @staticmethod + def OldLace(*obj, sep=sep_): return NCS(obj,OldLace,resetCode,sep) + @staticmethod + def PapayaWhip(*obj, sep=sep_): return NCS(obj,PapayaWhip,resetCode,sep) + @staticmethod + def WeaShell(*obj, sep=sep_): return NCS(obj,WeaShell,resetCode,sep) + @staticmethod + def MintCream(*obj, sep=sep_): return NCS(obj,MintCream,resetCode,sep) + @staticmethod + def SlateGray(*obj, sep=sep_): return NCS(obj,SlateGray,resetCode,sep) + @staticmethod + def LightSlateGray(*obj, sep=sep_): return NCS(obj,LightSlateGray,resetCode,sep) + @staticmethod + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,LightSteelBlue,resetCode,sep) + @staticmethod + def Lavender(*obj, sep=sep_): return NCS(obj,Lavender,resetCode,sep) + @staticmethod + def FloralWhite(*obj, sep=sep_): return NCS(obj,FloralWhite,resetCode,sep) + @staticmethod + def AliceBlue(*obj, sep=sep_): return NCS(obj,AliceBlue,resetCode,sep) + @staticmethod + def GhostWhite(*obj, sep=sep_): return NCS(obj,GhostWhite,resetCode,sep) + @staticmethod + def Honeydew(*obj, sep=sep_): return NCS(obj,Honeydew,resetCode,sep) + @staticmethod + def Ivory(*obj, sep=sep_): return NCS(obj,Ivory,resetCode,sep) + @staticmethod + def Azure(*obj, sep=sep_): return NCS(obj,Azure,resetCode,sep) + @staticmethod + def Snow(*obj, sep=sep_): return NCS(obj,Snow,resetCode,sep) + @staticmethod + def Black(*obj, sep=sep_): return NCS(obj,Black,resetCode,sep) + @staticmethod + def DimGray(*obj, sep=sep_): return NCS(obj,DimGray,resetCode,sep) + @staticmethod + def Gray(*obj, sep=sep_): return NCS(obj,Gray,resetCode,sep) + @staticmethod + def DarkGray(*obj, sep=sep_): return NCS(obj,DarkGray,resetCode,sep) + @staticmethod + def Silver(*obj, sep=sep_): return NCS(obj,Silver,resetCode,sep) + @staticmethod + def LightGray(*obj, sep=sep_): return NCS(obj,LightGray,resetCode,sep) + @staticmethod + def Gainsboro(*obj, sep=sep_): return NCS(obj,Gainsboro,resetCode,sep) + @staticmethod + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,WhiteSmoke,resetCode,sep) + @staticmethod + def White(*obj, sep=sep_): return NCS(obj,White,resetCode,sep) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py new file mode 100644 index 0000000..a2ae26f --- /dev/null +++ b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py @@ -0,0 +1,476 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - Package Imports - +# ---------------------------------------------------------------------------------------------------------------------- +# General Packages +from __future__ import annotations + +# Custom Library + +# Custom Packages +from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb +from AthenaColor.Functions.ANSIsquences import NestedColorSequence +from AthenaColor.Functions.General import StrictType + +# ---------------------------------------------------------------------------------------------------------------------- +# - All - +# ---------------------------------------------------------------------------------------------------------------------- +__all__=[ + "ForeNest" +] + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase +resetCode=39 +sep_=" " + +# Predefined Strings to speed calls up +Maroon =f"38;2;128;0;0" +DarkRed =f"38;2;139;0;0" +Brown =f"38;2;165;42;42" +Firebrick =f"38;2;178;34;34" +Crimson =f"38;2;220;20;60" +Red =f"38;2;255;0;0" +Tomato =f"38;2;255;99;71" +Coral =f"38;2;255;127;80" +IndianRed =f"38;2;205;92;92" +LightCoral =f"38;2;240;128;128" +DarkSalmon =f"38;2;233;150;122" +Salmon =f"38;2;250;128;114" +LightSalmon =f"38;2;255;160;122" +OrangeRed =f"38;2;255;69;0" +DarkOrange =f"38;2;255;140;0" +Orange =f"38;2;255;165;0" +Gold =f"38;2;255;215;0" +DarkGoldenRod =f"38;2;184;134;11" +GoldenRod =f"38;2;218;165;32" +PaleGoldenRod =f"38;2;238;232;170" +DarkKhaki =f"38;2;189;183;107" +Khaki =f"38;2;240;230;140" +Olive =f"38;2;128;128;0" +Yellow =f"38;2;255;255;0" +YellowGreen =f"38;2;154;205;50" +DarkOliveGreen =f"38;2;85;107;47" +OliveDrab =f"38;2;107;142;35" +LawnGreen =f"38;2;124;252;0" +Chartreuse =f"38;2;127;255;0" +GreenYellow =f"38;2;173;255;47" +DarkGreen =f"38;2;0;100;0" +Green =f"38;2;0;128;0" +ForestGreen =f"38;2;34;139;34" +Lime =f"38;2;0;255;0" +LimeGreen =f"38;2;50;205;50" +LightGreen =f"38;2;144;238;144" +PaleGreen =f"38;2;152;251;152" +DarkSeaGreen =f"38;2;143;188;143" +MediumSpringGreen =f"38;2;0;250;154" +SpringGreen =f"38;2;0;255;127" +SeaGreen =f"38;2;46;139;87" +MediumAquaMarine =f"38;2;102;205;170" +MediumSeaGreen =f"38;2;60;179;113" +LightSeaGreen =f"38;2;32;178;170" +DarkSlateGray =f"38;2;47;79 ;79" +Teal =f"38;2;0;128;128" +DarkCyan =f"38;2;0;139;139" +Aqua =f"38;2;0;255;255" +Cyan =f"38;2;0;255;255" +LightCyan =f"38;2;224;255;255" +DarkTurquoise =f"38;2;0;206;209" +Turquoise =f"38;2;64;224;208" +MediumTurquoise =f"38;2;72;209;204" +PaleTurquoise =f"38;2;175;238;238" +AquaMarine =f"38;2;127;255;212" +PowderBlue =f"38;2;176;224;230" +CadetBlue =f"38;2;95;158;160" +SteelBlue =f"38;2;70;130;180" +CornFlowerBlue =f"38;2;100;149;237" +DeepSkyBlue =f"38;2;0;191;255" +DodgerBlue =f"38;2;30;144;255" +LightBlue =f"38;2;173;216;230" +SkyBlue =f"38;2;135;206;235" +LightSkyBlue =f"38;2;135;206;250" +MidnightBlue =f"38;2;25;25;112" +Navy =f"38;2;0;0;128" +DarkBlue =f"38;2;0;0;139" +MediumBlue =f"38;2;0;0;205" +Blue =f"38;2;0;0;255" +RoyalBlue =f"38;2;65;105;225" +BlueViolet =f"38;2;138;43;226" +Indigo =f"38;2;75;0;130" +DarkSlateBlue =f"38;2;72;61;139" +SlateBlue =f"38;2;106;90;205" +MediumSlateBlue =f"38;2;123;104;238" +MediumPurple =f"38;2;147;112;219" +DarkMagenta =f"38;2;139;0;139" +DarkViolet =f"38;2;148;0;211" +DarkOrchid =f"38;2;153;50;204" +MediumOrchid =f"38;2;186;85;211" +Purple =f"38;2;128;0;128" +Thistle =f"38;2;216;191;216" +Plum =f"38;2;221;160;221" +Violet =f"38;2;238;130;238" +Magenta =f"38;2;255;0;255" +Orchid =f"38;2;218;112;214" +MediumVioletRed =f"38;2;199;21;133" +PaleVioletRed =f"38;2;219;112;147" +DeepPink =f"38;2;255;20;147" +HotPink =f"38;2;255;105;180" +LightPink =f"38;2;255;182;193" +Pink =f"38;2;255;192;203" +AntiqueWhite =f"38;2;250;235;215" +Beige =f"38;2;245;245;220" +Bisque =f"38;2;255;228;196" +BlanchedAlmond =f"38;2;255;235;205" +Wheat =f"38;2;245;222;179" +CornSilk =f"38;2;255;248;220" +LemonChiffon =f"38;2;255;250;205" +LightGoldenRodYellow =f"38;2;250;250;210" +LightYellow =f"38;2;255;255;224" +SaddleBrown =f"38;2;139;69;19" +Sienna =f"38;2;160;82;45" +Chocolate =f"38;2;210;105;30" +Peru =f"38;2;205;133;63" +SandyBrown =f"38;2;244;164;96" +BurlyWood =f"38;2;222;184;135" +Tan =f"38;2;210;180;140" +RosyBrown =f"38;2;188;143;143" +Moccasin =f"38;2;255;228;181" +NavajoWhite =f"38;2;255;222;173" +PeachPuff =f"38;2;255;218;185" +MistyRose =f"38;2;255;228;225" +LavenderBlush =f"38;2;255;240;245" +Linen =f"38;2;250;240;230" +OldLace =f"38;2;253;245;230" +PapayaWhip =f"38;2;255;239;213" +WeaShell =f"38;2;255;245;238" +MintCream =f"38;2;245;255;250" +SlateGray =f"38;2;112;128;144" +LightSlateGray =f"38;2;119;136;153" +LightSteelBlue =f"38;2;176;196;222" +Lavender =f"38;2;230;230;250" +FloralWhite =f"38;2;255;250;240" +AliceBlue =f"38;2;240;248;255" +GhostWhite =f"38;2;248;248;255" +Honeydew =f"38;2;240;255;240" +Ivory =f"38;2;255;255;240" +Azure =f"38;2;240;255;255" +Snow =f"38;2;255;250;250" +Black =f"38;2;0;0;0" +DimGray =f"38;2;105;105;105" +Gray =f"38;2;128;128;128" +DarkGray =f"38;2;169;169;169" +Silver =f"38;2;192;192;192" +LightGray =f"38;2;211;211;211" +Gainsboro =f"38;2;220;220;220" +WhiteSmoke =f"38;2;245;245;245" +White =f"38;2;255;255;255" + +class ForeNest: + # ------------------------------------------------------------------------------------------------------------------ + # - Methods - + # ------------------------------------------------------------------------------------------------------------------ + @staticmethod + def custom(*obj, color:RGB|HEX, **kwargs) -> str: + # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' + color = StrictType(color,(RGB,HEX)) + return NestedColorSequence( + *obj, + control_code=f"38;2;{color.r};{color.g};{color.b}", + reset_code=resetCode, + **kwargs + ) + + @staticmethod + def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: + # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' + r,g,b = NormalizeRgb(r, g, b) + return NestedColorSequence( + *obj, + control_code=f"38;2;{r};{g};{b}", + reset_code=resetCode, + **kwargs + ) + + # ------------------------------------------------------------------------------------------------------------------ + # - HTML colors - + # ------------------------------------------------------------------------------------------------------------------ + # No partial methods, as this was increase the speed impact 2-fold + @staticmethod + def Maroon(*obj, sep=sep_): return NCS(obj,Maroon,resetCode,sep) + @staticmethod + def DarkRed(*obj, sep=sep_): return NCS(obj,DarkRed,resetCode,sep) + @staticmethod + def Brown(*obj, sep=sep_): return NCS(obj,Brown,resetCode,sep) + @staticmethod + def Firebrick(*obj, sep=sep_): return NCS(obj,Firebrick,resetCode,sep) + @staticmethod + def Crimson(*obj, sep=sep_): return NCS(obj,Crimson,resetCode,sep) + @staticmethod + def Red(*obj, sep=sep_): return NCS(obj,Red,resetCode,sep) + @staticmethod + def Tomato(*obj, sep=sep_): return NCS(obj,Tomato,resetCode,sep) + @staticmethod + def Coral(*obj, sep=sep_): return NCS(obj,Coral,resetCode,sep) + @staticmethod + def IndianRed(*obj, sep=sep_): return NCS(obj,IndianRed,resetCode,sep) + @staticmethod + def LightCoral(*obj, sep=sep_): return NCS(obj,LightCoral,resetCode,sep) + @staticmethod + def DarkSalmon(*obj, sep=sep_): return NCS(obj,DarkSalmon,resetCode,sep) + @staticmethod + def Salmon(*obj, sep=sep_): return NCS(obj,Salmon,resetCode,sep) + @staticmethod + def LightSalmon(*obj, sep=sep_): return NCS(obj,LightSalmon,resetCode,sep) + @staticmethod + def OrangeRed(*obj, sep=sep_): return NCS(obj,OrangeRed,resetCode,sep) + @staticmethod + def DarkOrange(*obj, sep=sep_): return NCS(obj,DarkOrange,resetCode,sep) + @staticmethod + def Orange(*obj, sep=sep_): return NCS(obj,Orange,resetCode,sep) + @staticmethod + def Gold(*obj, sep=sep_): return NCS(obj,Gold,resetCode,sep) + @staticmethod + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,DarkGoldenRod,resetCode,sep) + @staticmethod + def GoldenRod(*obj, sep=sep_): return NCS(obj,GoldenRod,resetCode,sep) + @staticmethod + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,PaleGoldenRod,resetCode,sep) + @staticmethod + def DarkKhaki(*obj, sep=sep_): return NCS(obj,DarkKhaki,resetCode,sep) + @staticmethod + def Khaki(*obj, sep=sep_): return NCS(obj,Khaki,resetCode,sep) + @staticmethod + def Olive(*obj, sep=sep_): return NCS(obj,Olive,resetCode,sep) + @staticmethod + def Yellow(*obj, sep=sep_): return NCS(obj,Yellow,resetCode,sep) + @staticmethod + def YellowGreen(*obj, sep=sep_): return NCS(obj,YellowGreen,resetCode,sep) + @staticmethod + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,DarkOliveGreen,resetCode,sep) + @staticmethod + def OliveDrab(*obj, sep=sep_): return NCS(obj,OliveDrab,resetCode,sep) + @staticmethod + def LawnGreen(*obj, sep=sep_): return NCS(obj,LawnGreen,resetCode,sep) + @staticmethod + def Chartreuse(*obj, sep=sep_): return NCS(obj,Chartreuse,resetCode,sep) + @staticmethod + def GreenYellow(*obj, sep=sep_): return NCS(obj,GreenYellow,resetCode,sep) + @staticmethod + def DarkGreen(*obj, sep=sep_): return NCS(obj,DarkGreen,resetCode,sep) + @staticmethod + def Green(*obj, sep=sep_): return NCS(obj,Green,resetCode,sep) + @staticmethod + def ForestGreen(*obj, sep=sep_): return NCS(obj,ForestGreen,resetCode,sep) + @staticmethod + def Lime(*obj, sep=sep_): return NCS(obj,Lime,resetCode,sep) + @staticmethod + def LimeGreen(*obj, sep=sep_): return NCS(obj,LimeGreen,resetCode,sep) + @staticmethod + def LightGreen(*obj, sep=sep_): return NCS(obj,LightGreen,resetCode,sep) + @staticmethod + def PaleGreen(*obj, sep=sep_): return NCS(obj,PaleGreen,resetCode,sep) + @staticmethod + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,DarkSeaGreen,resetCode,sep) + @staticmethod + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,MediumSpringGreen,resetCode,sep) + @staticmethod + def SpringGreen(*obj, sep=sep_): return NCS(obj,SpringGreen,resetCode,sep) + @staticmethod + def SeaGreen(*obj, sep=sep_): return NCS(obj,SeaGreen,resetCode,sep) + @staticmethod + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,MediumAquaMarine,resetCode,sep) + @staticmethod + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,MediumSeaGreen,resetCode,sep) + @staticmethod + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,LightSeaGreen,resetCode,sep) + @staticmethod + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,DarkSlateGray,resetCode,sep) + @staticmethod + def Teal(*obj, sep=sep_): return NCS(obj,Teal,resetCode,sep) + @staticmethod + def DarkCyan(*obj, sep=sep_): return NCS(obj,DarkCyan,resetCode,sep) + @staticmethod + def Aqua(*obj, sep=sep_): return NCS(obj,Aqua,resetCode,sep) + @staticmethod + def Cyan(*obj, sep=sep_): return NCS(obj,Cyan,resetCode,sep) + @staticmethod + def LightCyan(*obj, sep=sep_): return NCS(obj,LightCyan,resetCode,sep) + @staticmethod + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,DarkTurquoise,resetCode,sep) + @staticmethod + def Turquoise(*obj, sep=sep_): return NCS(obj,Turquoise,resetCode,sep) + @staticmethod + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,MediumTurquoise,resetCode,sep) + @staticmethod + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,PaleTurquoise,resetCode,sep) + @staticmethod + def AquaMarine(*obj, sep=sep_): return NCS(obj,AquaMarine,resetCode,sep) + @staticmethod + def PowderBlue(*obj, sep=sep_): return NCS(obj,PowderBlue,resetCode,sep) + @staticmethod + def CadetBlue(*obj, sep=sep_): return NCS(obj,CadetBlue,resetCode,sep) + @staticmethod + def SteelBlue(*obj, sep=sep_): return NCS(obj,SteelBlue,resetCode,sep) + @staticmethod + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,CornFlowerBlue,resetCode,sep) + @staticmethod + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,DeepSkyBlue,resetCode,sep) + @staticmethod + def DodgerBlue(*obj, sep=sep_): return NCS(obj,DodgerBlue,resetCode,sep) + @staticmethod + def LightBlue(*obj, sep=sep_): return NCS(obj,LightBlue,resetCode,sep) + @staticmethod + def SkyBlue(*obj, sep=sep_): return NCS(obj,SkyBlue,resetCode,sep) + @staticmethod + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,LightSkyBlue,resetCode,sep) + @staticmethod + def MidnightBlue(*obj, sep=sep_): return NCS(obj,MidnightBlue,resetCode,sep) + @staticmethod + def Navy(*obj, sep=sep_): return NCS(obj,Navy,resetCode,sep) + @staticmethod + def DarkBlue(*obj, sep=sep_): return NCS(obj,DarkBlue,resetCode,sep) + @staticmethod + def MediumBlue(*obj, sep=sep_): return NCS(obj,MediumBlue,resetCode,sep) + @staticmethod + def Blue(*obj, sep=sep_): return NCS(obj,Blue,resetCode,sep) + @staticmethod + def RoyalBlue(*obj, sep=sep_): return NCS(obj,RoyalBlue,resetCode,sep) + @staticmethod + def BlueViolet(*obj, sep=sep_): return NCS(obj,BlueViolet,resetCode,sep) + @staticmethod + def Indigo(*obj, sep=sep_): return NCS(obj,Indigo,resetCode,sep) + @staticmethod + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,DarkSlateBlue,resetCode,sep) + @staticmethod + def SlateBlue(*obj, sep=sep_): return NCS(obj,SlateBlue,resetCode,sep) + @staticmethod + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,MediumSlateBlue,resetCode,sep) + @staticmethod + def MediumPurple(*obj, sep=sep_): return NCS(obj,MediumPurple,resetCode,sep) + @staticmethod + def DarkMagenta(*obj, sep=sep_): return NCS(obj,DarkMagenta,resetCode,sep) + @staticmethod + def DarkViolet(*obj, sep=sep_): return NCS(obj,DarkViolet,resetCode,sep) + @staticmethod + def DarkOrchid(*obj, sep=sep_): return NCS(obj,DarkOrchid,resetCode,sep) + @staticmethod + def MediumOrchid(*obj, sep=sep_): return NCS(obj,MediumOrchid,resetCode,sep) + @staticmethod + def Purple(*obj, sep=sep_): return NCS(obj,Purple,resetCode,sep) + @staticmethod + def Thistle(*obj, sep=sep_): return NCS(obj,Thistle,resetCode,sep) + @staticmethod + def Plum(*obj, sep=sep_): return NCS(obj,Plum,resetCode,sep) + @staticmethod + def Violet(*obj, sep=sep_): return NCS(obj,Violet,resetCode,sep) + @staticmethod + def Magenta(*obj, sep=sep_): return NCS(obj,Magenta,resetCode,sep) + @staticmethod + def Orchid(*obj, sep=sep_): return NCS(obj,Orchid,resetCode,sep) + @staticmethod + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,MediumVioletRed,resetCode,sep) + @staticmethod + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,PaleVioletRed,resetCode,sep) + @staticmethod + def DeepPink(*obj, sep=sep_): return NCS(obj,DeepPink,resetCode,sep) + @staticmethod + def HotPink(*obj, sep=sep_): return NCS(obj,HotPink,resetCode,sep) + @staticmethod + def LightPink(*obj, sep=sep_): return NCS(obj,LightPink,resetCode,sep) + @staticmethod + def Pink(*obj, sep=sep_): return NCS(obj,Pink,resetCode,sep) + @staticmethod + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,AntiqueWhite,resetCode,sep) + @staticmethod + def Beige(*obj, sep=sep_): return NCS(obj,Beige,resetCode,sep) + @staticmethod + def Bisque(*obj, sep=sep_): return NCS(obj,Bisque,resetCode,sep) + @staticmethod + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,BlanchedAlmond,resetCode,sep) + @staticmethod + def Wheat(*obj, sep=sep_): return NCS(obj,Wheat,resetCode,sep) + @staticmethod + def CornSilk(*obj, sep=sep_): return NCS(obj,CornSilk,resetCode,sep) + @staticmethod + def LemonChiffon(*obj, sep=sep_): return NCS(obj,LemonChiffon,resetCode,sep) + @staticmethod + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,LightGoldenRodYellow,resetCode,sep) + @staticmethod + def LightYellow(*obj, sep=sep_): return NCS(obj,LightYellow,resetCode,sep) + @staticmethod + def SaddleBrown(*obj, sep=sep_): return NCS(obj,SaddleBrown,resetCode,sep) + @staticmethod + def Sienna(*obj, sep=sep_): return NCS(obj,Sienna,resetCode,sep) + @staticmethod + def Chocolate(*obj, sep=sep_): return NCS(obj,Chocolate,resetCode,sep) + @staticmethod + def Peru(*obj, sep=sep_): return NCS(obj,Peru,resetCode,sep) + @staticmethod + def SandyBrown(*obj, sep=sep_): return NCS(obj,SandyBrown,resetCode,sep) + @staticmethod + def BurlyWood(*obj, sep=sep_): return NCS(obj,BurlyWood,resetCode,sep) + @staticmethod + def Tan(*obj, sep=sep_): return NCS(obj,Tan,resetCode,sep) + @staticmethod + def RosyBrown(*obj, sep=sep_): return NCS(obj,RosyBrown,resetCode,sep) + @staticmethod + def Moccasin(*obj, sep=sep_): return NCS(obj,Moccasin,resetCode,sep) + @staticmethod + def NavajoWhite(*obj, sep=sep_): return NCS(obj,NavajoWhite,resetCode,sep) + @staticmethod + def PeachPuff(*obj, sep=sep_): return NCS(obj,PeachPuff,resetCode,sep) + @staticmethod + def MistyRose(*obj, sep=sep_): return NCS(obj,MistyRose,resetCode,sep) + @staticmethod + def LavenderBlush(*obj, sep=sep_): return NCS(obj,LavenderBlush,resetCode,sep) + @staticmethod + def Linen(*obj, sep=sep_): return NCS(obj,Linen,resetCode,sep) + @staticmethod + def OldLace(*obj, sep=sep_): return NCS(obj,OldLace,resetCode,sep) + @staticmethod + def PapayaWhip(*obj, sep=sep_): return NCS(obj,PapayaWhip,resetCode,sep) + @staticmethod + def WeaShell(*obj, sep=sep_): return NCS(obj,WeaShell,resetCode,sep) + @staticmethod + def MintCream(*obj, sep=sep_): return NCS(obj,MintCream,resetCode,sep) + @staticmethod + def SlateGray(*obj, sep=sep_): return NCS(obj,SlateGray,resetCode,sep) + @staticmethod + def LightSlateGray(*obj, sep=sep_): return NCS(obj,LightSlateGray,resetCode,sep) + @staticmethod + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,LightSteelBlue,resetCode,sep) + @staticmethod + def Lavender(*obj, sep=sep_): return NCS(obj,Lavender,resetCode,sep) + @staticmethod + def FloralWhite(*obj, sep=sep_): return NCS(obj,FloralWhite,resetCode,sep) + @staticmethod + def AliceBlue(*obj, sep=sep_): return NCS(obj,AliceBlue,resetCode,sep) + @staticmethod + def GhostWhite(*obj, sep=sep_): return NCS(obj,GhostWhite,resetCode,sep) + @staticmethod + def Honeydew(*obj, sep=sep_): return NCS(obj,Honeydew,resetCode,sep) + @staticmethod + def Ivory(*obj, sep=sep_): return NCS(obj,Ivory,resetCode,sep) + @staticmethod + def Azure(*obj, sep=sep_): return NCS(obj,Azure,resetCode,sep) + @staticmethod + def Snow(*obj, sep=sep_): return NCS(obj,Snow,resetCode,sep) + @staticmethod + def Black(*obj, sep=sep_): return NCS(obj,Black,resetCode,sep) + @staticmethod + def DimGray(*obj, sep=sep_): return NCS(obj,DimGray,resetCode,sep) + @staticmethod + def Gray(*obj, sep=sep_): return NCS(obj,Gray,resetCode,sep) + @staticmethod + def DarkGray(*obj, sep=sep_): return NCS(obj,DarkGray,resetCode,sep) + @staticmethod + def Silver(*obj, sep=sep_): return NCS(obj,Silver,resetCode,sep) + @staticmethod + def LightGray(*obj, sep=sep_): return NCS(obj,LightGray,resetCode,sep) + @staticmethod + def Gainsboro(*obj, sep=sep_): return NCS(obj,Gainsboro,resetCode,sep) + @staticmethod + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,WhiteSmoke,resetCode,sep) + @staticmethod + def White(*obj, sep=sep_): return NCS(obj,White,resetCode,sep) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_Bodies.py b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_Bodies.py deleted file mode 100644 index 5d880a6..0000000 --- a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_Bodies.py +++ /dev/null @@ -1,35 +0,0 @@ -# ---------------------------------------------------------------------------------------------------------------------- -# - Package Imports - -# ---------------------------------------------------------------------------------------------------------------------- -# General Packages -from __future__ import annotations - -# Custom Library - -# Custom Packages -from .RgbControlledNest import RgbControlledNest - -# ---------------------------------------------------------------------------------------------------------------------- -# - All - -# ---------------------------------------------------------------------------------------------------------------------- -__all__=[ - "ForeNest", "BackNest", "UnderlineNest" -] - -# ---------------------------------------------------------------------------------------------------------------------- -# - Code - -# ---------------------------------------------------------------------------------------------------------------------- -ForeNest = RgbControlledNest( - param_code= f"38;2;", - reset_code=39 -) - -BackNest = RgbControlledNest( - param_code= f"48;2;", - reset_code=49 -) - -UnderlineNest = RgbControlledNest( - param_code= f"58;2;", - reset_code=24 -) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py index 9956a20..8562b99 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py @@ -2,7 +2,6 @@ # - Package Imports - # ---------------------------------------------------------------------------------------------------------------------- # General Packages -from functools import partial # Custom Library @@ -23,27 +22,6 @@ NCSNO = NestedColorSequence_NoReset # Done for slight speed increase class StyleNest: - # noinspection PyUnresolvedReferences - __all__ = [ - "Reset", - "Italic", - "NoItalic", - "Bold", - "NoBold", - "UnderlineNest", - "NoUnderline", - "Crossed", - "NoCrossed", - "Reversed", - "NoReversed", - "Frame", - "NoFrame", - "Circle", - "NoCircle", - "UnderlineDouble", - "NoForeground", - "NoBackground" - ] @staticmethod def Reset(*obj, sep=" "): return NCSNO(obj, control_code=0, sep=sep) @staticmethod diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py deleted file mode 100644 index 8ce4dfd..0000000 --- a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py +++ /dev/null @@ -1,197 +0,0 @@ -# ---------------------------------------------------------------------------------------------------------------------- -# - Package Imports - -# ---------------------------------------------------------------------------------------------------------------------- -# General Packages -from __future__ import annotations - -# Custom Library - -# Custom Packages -from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb -from AthenaColor.Functions.ANSIsquences import NestedColorSequence -from AthenaColor.Data.HtmlColors import HtmlColorStr as HC -from AthenaColor.Functions.General import StrictType - -# ---------------------------------------------------------------------------------------------------------------------- -# - All - -# ---------------------------------------------------------------------------------------------------------------------- -__all__=[ - "RgbControlledNest" -] - -# ---------------------------------------------------------------------------------------------------------------------- -# - Code - -# ---------------------------------------------------------------------------------------------------------------------- -NCS = NestedColorSequence # Done for slight speed increase - -class RgbControlledNest: - def __init__(self, param_code:str,reset_code:int): - self._param_code:str = StrictType(param_code, str) - self._reset:int = StrictType(reset_code, int) - - # ------------------------------------------------------------------------------------------------------------------ - # - Methods - - # ------------------------------------------------------------------------------------------------------------------ - def custom(self,*obj, color:RGB|HEX, **kwargs) -> str: - # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - color = StrictType(color,(RGB,HEX)) - return NestedColorSequence( - *obj, - control_code=f"{self._param_code}{color.r};{color.g};{color.b}", - reset_code=self._reset, - **kwargs - ) - - def rgb(self,*obj, r:int,g:int,b:int, **kwargs) -> str: - # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - r,g,b = NormalizeRgb(r, g, b) - return NestedColorSequence( - *obj, - control_code=f"{self._param_code}{r};{g};{b}", - reset_code=self._reset, - **kwargs - ) - - # ------------------------------------------------------------------------------------------------------------------ - # - HTML colors - - # ------------------------------------------------------------------------------------------------------------------ - # No partial methods, as this was increase the speed impact 2-fold - def Maroon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Maroon}",reset_code=self._reset,sep=sep) - def DarkRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkRed}",reset_code=self._reset,sep=sep) - def Brown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Brown}",reset_code=self._reset,sep=sep) - def Firebrick(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Firebrick}",reset_code=self._reset,sep=sep) - def Crimson(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Crimson}",reset_code=self._reset,sep=sep) - def Red(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Red}",reset_code=self._reset,sep=sep) - def Tomato(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Tomato}",reset_code=self._reset,sep=sep) - def Coral(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Coral}",reset_code=self._reset,sep=sep) - def IndianRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.IndianRed}",reset_code=self._reset,sep=sep) - def LightCoral(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightCoral}",reset_code=self._reset,sep=sep) - def DarkSalmon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSalmon}",reset_code=self._reset,sep=sep) - def Salmon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Salmon}",reset_code=self._reset,sep=sep) - def LightSalmon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSalmon}",reset_code=self._reset,sep=sep) - def OrangeRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.OrangeRed}",reset_code=self._reset,sep=sep) - def DarkOrange(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkOrange}",reset_code=self._reset,sep=sep) - def Orange(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Orange}",reset_code=self._reset,sep=sep) - def Gold(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Gold}",reset_code=self._reset,sep=sep) - def DarkGoldenRod(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkGoldenRod}",reset_code=self._reset,sep=sep) - def GoldenRod(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.GoldenRod}",reset_code=self._reset,sep=sep) - def PaleGoldenRod(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleGoldenRod}",reset_code=self._reset,sep=sep) - def DarkKhaki(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkKhaki}",reset_code=self._reset,sep=sep) - def Khaki(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Khaki}",reset_code=self._reset,sep=sep) - def Olive(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Olive}",reset_code=self._reset,sep=sep) - def Yellow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Yellow}",reset_code=self._reset,sep=sep) - def YellowGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.YellowGreen}",reset_code=self._reset,sep=sep) - def DarkOliveGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkOliveGreen}",reset_code=self._reset,sep=sep) - def OliveDrab(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.OliveDrab}",reset_code=self._reset,sep=sep) - def LawnGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LawnGreen}",reset_code=self._reset,sep=sep) - def Chartreuse(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Chartreuse}",reset_code=self._reset,sep=sep) - def GreenYellow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.GreenYellow}",reset_code=self._reset,sep=sep) - def DarkGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkGreen}",reset_code=self._reset,sep=sep) - def Green(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Green}",reset_code=self._reset,sep=sep) - def ForestGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.ForestGreen}",reset_code=self._reset,sep=sep) - def Lime(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Lime}",reset_code=self._reset,sep=sep) - def LimeGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LimeGreen}",reset_code=self._reset,sep=sep) - def LightGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightGreen}",reset_code=self._reset,sep=sep) - def PaleGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleGreen}",reset_code=self._reset,sep=sep) - def DarkSeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSeaGreen}",reset_code=self._reset,sep=sep) - def MediumSpringGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumSpringGreen}",reset_code=self._reset,sep=sep) - def SpringGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SpringGreen}",reset_code=self._reset,sep=sep) - def SeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SeaGreen}",reset_code=self._reset,sep=sep) - def MediumAquaMarine(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumAquaMarine}",reset_code=self._reset,sep=sep) - def MediumSeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumSeaGreen}",reset_code=self._reset,sep=sep) - def LightSeaGreen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSeaGreen}",reset_code=self._reset,sep=sep) - def DarkSlateGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSlateGray}",reset_code=self._reset,sep=sep) - def Teal(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Teal}",reset_code=self._reset,sep=sep) - def DarkCyan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkCyan}",reset_code=self._reset,sep=sep) - def Aqua(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Aqua}",reset_code=self._reset,sep=sep) - def Cyan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Cyan}",reset_code=self._reset,sep=sep) - def LightCyan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightCyan}",reset_code=self._reset,sep=sep) - def DarkTurquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkTurquoise}",reset_code=self._reset,sep=sep) - def Turquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Turquoise}",reset_code=self._reset,sep=sep) - def MediumTurquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumTurquoise}",reset_code=self._reset,sep=sep) - def PaleTurquoise(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleTurquoise}",reset_code=self._reset,sep=sep) - def AquaMarine(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.AquaMarine}",reset_code=self._reset,sep=sep) - def PowderBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PowderBlue}",reset_code=self._reset,sep=sep) - def CadetBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.CadetBlue}",reset_code=self._reset,sep=sep) - def SteelBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SteelBlue}",reset_code=self._reset,sep=sep) - def CornFlowerBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.CornFlowerBlue}",reset_code=self._reset,sep=sep) - def DeepSkyBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DeepSkyBlue}",reset_code=self._reset,sep=sep) - def DodgerBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DodgerBlue}",reset_code=self._reset,sep=sep) - def LightBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightBlue}",reset_code=self._reset,sep=sep) - def SkyBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SkyBlue}",reset_code=self._reset,sep=sep) - def LightSkyBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSkyBlue}",reset_code=self._reset,sep=sep) - def MidnightBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MidnightBlue}",reset_code=self._reset,sep=sep) - def Navy(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Navy}",reset_code=self._reset,sep=sep) - def DarkBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkBlue}",reset_code=self._reset,sep=sep) - def MediumBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumBlue}",reset_code=self._reset,sep=sep) - def Blue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Blue}",reset_code=self._reset,sep=sep) - def RoyalBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.RoyalBlue}",reset_code=self._reset,sep=sep) - def BlueViolet(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.BlueViolet}",reset_code=self._reset,sep=sep) - def Indigo(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Indigo}",reset_code=self._reset,sep=sep) - def DarkSlateBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkSlateBlue}",reset_code=self._reset,sep=sep) - def SlateBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SlateBlue}",reset_code=self._reset,sep=sep) - def MediumSlateBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumSlateBlue}",reset_code=self._reset,sep=sep) - def MediumPurple(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumPurple}",reset_code=self._reset,sep=sep) - def DarkMagenta(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkMagenta}",reset_code=self._reset,sep=sep) - def DarkViolet(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkViolet}",reset_code=self._reset,sep=sep) - def DarkOrchid(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkOrchid}",reset_code=self._reset,sep=sep) - def MediumOrchid(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumOrchid}",reset_code=self._reset,sep=sep) - def Purple(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Purple}",reset_code=self._reset,sep=sep) - def Thistle(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Thistle}",reset_code=self._reset,sep=sep) - def Plum(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Plum}",reset_code=self._reset,sep=sep) - def Violet(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Violet}",reset_code=self._reset,sep=sep) - def Magenta(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Magenta}",reset_code=self._reset,sep=sep) - def Orchid(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Orchid}",reset_code=self._reset,sep=sep) - def MediumVioletRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MediumVioletRed}",reset_code=self._reset,sep=sep) - def PaleVioletRed(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PaleVioletRed}",reset_code=self._reset,sep=sep) - def DeepPink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DeepPink}",reset_code=self._reset,sep=sep) - def HotPink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.HotPink}",reset_code=self._reset,sep=sep) - def LightPink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightPink}",reset_code=self._reset,sep=sep) - def Pink(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Pink}",reset_code=self._reset,sep=sep) - def AntiqueWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.AntiqueWhite}",reset_code=self._reset,sep=sep) - def Beige(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Beige}",reset_code=self._reset,sep=sep) - def Bisque(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Bisque}",reset_code=self._reset,sep=sep) - def BlanchedAlmond(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.BlanchedAlmond}",reset_code=self._reset,sep=sep) - def Wheat(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Wheat}",reset_code=self._reset,sep=sep) - def CornSilk(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.CornSilk}",reset_code=self._reset,sep=sep) - def LemonChiffon(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LemonChiffon}",reset_code=self._reset,sep=sep) - def LightGoldenRodYellow(self, *obj, sep=" "):return NCS(obj,control_code=f"{self._param_code}{HC.LightGoldenRodYellow}",reset_code=self._reset,sep=sep) - def LightYellow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightYellow}",reset_code=self._reset,sep=sep) - def SaddleBrown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SaddleBrown}",reset_code=self._reset,sep=sep) - def Sienna(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Sienna}",reset_code=self._reset,sep=sep) - def Chocolate(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Chocolate}",reset_code=self._reset,sep=sep) - def Peru(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Peru}",reset_code=self._reset,sep=sep) - def SandyBrown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SandyBrown}",reset_code=self._reset,sep=sep) - def BurlyWood(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.BurlyWood}",reset_code=self._reset,sep=sep) - def Tan(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Tan}",reset_code=self._reset,sep=sep) - def RosyBrown(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.RosyBrown}",reset_code=self._reset,sep=sep) - def Moccasin(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Moccasin}",reset_code=self._reset,sep=sep) - def NavajoWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.NavajoWhite}",reset_code=self._reset,sep=sep) - def PeachPuff(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PeachPuff}",reset_code=self._reset,sep=sep) - def MistyRose(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MistyRose}",reset_code=self._reset,sep=sep) - def LavenderBlush(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LavenderBlush}",reset_code=self._reset,sep=sep) - def Linen(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Linen}",reset_code=self._reset,sep=sep) - def OldLace(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.OldLace}",reset_code=self._reset,sep=sep) - def PapayaWhip(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.PapayaWhip}",reset_code=self._reset,sep=sep) - def WeaShell(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.WeaShell}",reset_code=self._reset,sep=sep) - def MintCream(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.MintCream}",reset_code=self._reset,sep=sep) - def SlateGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.SlateGray}",reset_code=self._reset,sep=sep) - def LightSlateGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSlateGray}",reset_code=self._reset,sep=sep) - def LightSteelBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightSteelBlue}",reset_code=self._reset,sep=sep) - def Lavender(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Lavender}",reset_code=self._reset,sep=sep) - def FloralWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.FloralWhite}",reset_code=self._reset,sep=sep) - def AliceBlue(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.AliceBlue}",reset_code=self._reset,sep=sep) - def GhostWhite(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.GhostWhite}",reset_code=self._reset,sep=sep) - def Honeydew(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Honeydew}",reset_code=self._reset,sep=sep) - def Ivory(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Ivory}",reset_code=self._reset,sep=sep) - def Azure(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Azure}",reset_code=self._reset,sep=sep) - def Snow(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Snow}",reset_code=self._reset,sep=sep) - def Black(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Black}",reset_code=self._reset,sep=sep) - def DimGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DimGray}",reset_code=self._reset,sep=sep) - def Gray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Gray}",reset_code=self._reset,sep=sep) - def DarkGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.DarkGray}",reset_code=self._reset,sep=sep) - def Silver(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Silver}",reset_code=self._reset,sep=sep) - def LightGray(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.LightGray}",reset_code=self._reset,sep=sep) - def Gainsboro(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.Gainsboro}",reset_code=self._reset,sep=sep) - def WhiteSmoke(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.WhiteSmoke}",reset_code=self._reset,sep=sep) - def White(self, *obj, sep=" "): return NCS(obj,control_code=f"{self._param_code}{HC.White}",reset_code=self._reset,sep=sep) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py new file mode 100644 index 0000000..941d92b --- /dev/null +++ b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py @@ -0,0 +1,476 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - Package Imports - +# ---------------------------------------------------------------------------------------------------------------------- +# General Packages +from __future__ import annotations + +# Custom Library + +# Custom Packages +from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb +from AthenaColor.Functions.ANSIsquences import NestedColorSequence +from AthenaColor.Functions.General import StrictType + +# ---------------------------------------------------------------------------------------------------------------------- +# - All - +# ---------------------------------------------------------------------------------------------------------------------- +__all__=[ + "ForeNest" +] + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase +resetCode=59 +sep_=" " + +# Predefined Strings to speed calls up +Maroon =f"58;2;128;0;0" +DarkRed =f"58;2;139;0;0" +Brown =f"58;2;165;42;42" +Firebrick =f"58;2;178;34;34" +Crimson =f"58;2;220;20;60" +Red =f"58;2;255;0;0" +Tomato =f"58;2;255;99;71" +Coral =f"58;2;255;127;80" +IndianRed =f"58;2;205;92;92" +LightCoral =f"58;2;240;128;128" +DarkSalmon =f"58;2;233;150;122" +Salmon =f"58;2;250;128;114" +LightSalmon =f"58;2;255;160;122" +OrangeRed =f"58;2;255;69;0" +DarkOrange =f"58;2;255;140;0" +Orange =f"58;2;255;165;0" +Gold =f"58;2;255;215;0" +DarkGoldenRod =f"58;2;184;134;11" +GoldenRod =f"58;2;218;165;32" +PaleGoldenRod =f"58;2;238;232;170" +DarkKhaki =f"58;2;189;183;107" +Khaki =f"58;2;240;230;140" +Olive =f"58;2;128;128;0" +Yellow =f"58;2;255;255;0" +YellowGreen =f"58;2;154;205;50" +DarkOliveGreen =f"58;2;85;107;47" +OliveDrab =f"58;2;107;142;35" +LawnGreen =f"58;2;124;252;0" +Chartreuse =f"58;2;127;255;0" +GreenYellow =f"58;2;173;255;47" +DarkGreen =f"58;2;0;100;0" +Green =f"58;2;0;128;0" +ForestGreen =f"58;2;34;139;34" +Lime =f"58;2;0;255;0" +LimeGreen =f"58;2;50;205;50" +LightGreen =f"58;2;144;238;144" +PaleGreen =f"58;2;152;251;152" +DarkSeaGreen =f"58;2;143;188;143" +MediumSpringGreen =f"58;2;0;250;154" +SpringGreen =f"58;2;0;255;127" +SeaGreen =f"58;2;46;139;87" +MediumAquaMarine =f"58;2;102;205;170" +MediumSeaGreen =f"58;2;60;179;113" +LightSeaGreen =f"58;2;32;178;170" +DarkSlateGray =f"58;2;47;79 ;79" +Teal =f"58;2;0;128;128" +DarkCyan =f"58;2;0;139;139" +Aqua =f"58;2;0;255;255" +Cyan =f"58;2;0;255;255" +LightCyan =f"58;2;224;255;255" +DarkTurquoise =f"58;2;0;206;209" +Turquoise =f"58;2;64;224;208" +MediumTurquoise =f"58;2;72;209;204" +PaleTurquoise =f"58;2;175;238;238" +AquaMarine =f"58;2;127;255;212" +PowderBlue =f"58;2;176;224;230" +CadetBlue =f"58;2;95;158;160" +SteelBlue =f"58;2;70;130;180" +CornFlowerBlue =f"58;2;100;149;237" +DeepSkyBlue =f"58;2;0;191;255" +DodgerBlue =f"58;2;30;144;255" +LightBlue =f"58;2;173;216;230" +SkyBlue =f"58;2;135;206;235" +LightSkyBlue =f"58;2;135;206;250" +MidnightBlue =f"58;2;25;25;112" +Navy =f"58;2;0;0;128" +DarkBlue =f"58;2;0;0;139" +MediumBlue =f"58;2;0;0;205" +Blue =f"58;2;0;0;255" +RoyalBlue =f"58;2;65;105;225" +BlueViolet =f"58;2;138;43;226" +Indigo =f"58;2;75;0;130" +DarkSlateBlue =f"58;2;72;61;139" +SlateBlue =f"58;2;106;90;205" +MediumSlateBlue =f"58;2;123;104;238" +MediumPurple =f"58;2;147;112;219" +DarkMagenta =f"58;2;139;0;139" +DarkViolet =f"58;2;148;0;211" +DarkOrchid =f"58;2;153;50;204" +MediumOrchid =f"58;2;186;85;211" +Purple =f"58;2;128;0;128" +Thistle =f"58;2;216;191;216" +Plum =f"58;2;221;160;221" +Violet =f"58;2;238;130;238" +Magenta =f"58;2;255;0;255" +Orchid =f"58;2;218;112;214" +MediumVioletRed =f"58;2;199;21;133" +PaleVioletRed =f"58;2;219;112;147" +DeepPink =f"58;2;255;20;147" +HotPink =f"58;2;255;105;180" +LightPink =f"58;2;255;182;193" +Pink =f"58;2;255;192;203" +AntiqueWhite =f"58;2;250;235;215" +Beige =f"58;2;245;245;220" +Bisque =f"58;2;255;228;196" +BlanchedAlmond =f"58;2;255;235;205" +Wheat =f"58;2;245;222;179" +CornSilk =f"58;2;255;248;220" +LemonChiffon =f"58;2;255;250;205" +LightGoldenRodYellow =f"58;2;250;250;210" +LightYellow =f"58;2;255;255;224" +SaddleBrown =f"58;2;139;69;19" +Sienna =f"58;2;160;82;45" +Chocolate =f"58;2;210;105;30" +Peru =f"58;2;205;133;63" +SandyBrown =f"58;2;244;164;96" +BurlyWood =f"58;2;222;184;135" +Tan =f"58;2;210;180;140" +RosyBrown =f"58;2;188;143;143" +Moccasin =f"58;2;255;228;181" +NavajoWhite =f"58;2;255;222;173" +PeachPuff =f"58;2;255;218;185" +MistyRose =f"58;2;255;228;225" +LavenderBlush =f"58;2;255;240;245" +Linen =f"58;2;250;240;230" +OldLace =f"58;2;253;245;230" +PapayaWhip =f"58;2;255;239;213" +WeaShell =f"58;2;255;245;238" +MintCream =f"58;2;245;255;250" +SlateGray =f"58;2;112;128;144" +LightSlateGray =f"58;2;119;136;153" +LightSteelBlue =f"58;2;176;196;222" +Lavender =f"58;2;230;230;250" +FloralWhite =f"58;2;255;250;240" +AliceBlue =f"58;2;240;248;255" +GhostWhite =f"58;2;248;248;255" +Honeydew =f"58;2;240;255;240" +Ivory =f"58;2;255;255;240" +Azure =f"58;2;240;255;255" +Snow =f"58;2;255;250;250" +Black =f"58;2;0;0;0" +DimGray =f"58;2;105;105;105" +Gray =f"58;2;128;128;128" +DarkGray =f"58;2;169;169;169" +Silver =f"58;2;192;192;192" +LightGray =f"58;2;211;211;211" +Gainsboro =f"58;2;220;220;220" +WhiteSmoke =f"58;2;245;245;245" +White =f"58;2;255;255;255" + +class UnderlineNest: + # ------------------------------------------------------------------------------------------------------------------ + # - Methods - + # ------------------------------------------------------------------------------------------------------------------ + @staticmethod + def custom(*obj, color:RGB|HEX, **kwargs) -> str: + # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' + color = StrictType(color,(RGB,HEX)) + return NestedColorSequence( + *obj, + control_code=f"58;2;{color.r};{color.g};{color.b}", + reset_code=resetCode, + **kwargs + ) + + @staticmethod + def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: + # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' + r,g,b = NormalizeRgb(r, g, b) + return NestedColorSequence( + *obj, + control_code=f"58;2;{r};{g};{b}", + reset_code=resetCode, + **kwargs + ) + + # ------------------------------------------------------------------------------------------------------------------ + # - HTML colors - + # ------------------------------------------------------------------------------------------------------------------ + # No partial methods, as this was increase the speed impact 2-fold + @staticmethod + def Maroon( *obj, sep=sep_): return NCS(obj,Maroon,resetCode,sep) + @staticmethod + def DarkRed(*obj, sep=sep_): return NCS(obj,DarkRed,resetCode,sep) + @staticmethod + def Brown(*obj, sep=sep_): return NCS(obj,Brown,resetCode,sep) + @staticmethod + def Firebrick(*obj, sep=sep_): return NCS(obj,Firebrick,resetCode,sep) + @staticmethod + def Crimson(*obj, sep=sep_): return NCS(obj,Crimson,resetCode,sep) + @staticmethod + def Red(*obj, sep=sep_): return NCS(obj,Red,resetCode,sep) + @staticmethod + def Tomato(*obj, sep=sep_): return NCS(obj,Tomato,resetCode,sep) + @staticmethod + def Coral(*obj, sep=sep_): return NCS(obj,Coral,resetCode,sep) + @staticmethod + def IndianRed(*obj, sep=sep_): return NCS(obj,IndianRed,resetCode,sep) + @staticmethod + def LightCoral(*obj, sep=sep_): return NCS(obj,LightCoral,resetCode,sep) + @staticmethod + def DarkSalmon(*obj, sep=sep_): return NCS(obj,DarkSalmon,resetCode,sep) + @staticmethod + def Salmon(*obj, sep=sep_): return NCS(obj,Salmon,resetCode,sep) + @staticmethod + def LightSalmon(*obj, sep=sep_): return NCS(obj,LightSalmon,resetCode,sep) + @staticmethod + def OrangeRed(*obj, sep=sep_): return NCS(obj,OrangeRed,resetCode,sep) + @staticmethod + def DarkOrange(*obj, sep=sep_): return NCS(obj,DarkOrange,resetCode,sep) + @staticmethod + def Orange(*obj, sep=sep_): return NCS(obj,Orange,resetCode,sep) + @staticmethod + def Gold(*obj, sep=sep_): return NCS(obj,Gold,resetCode,sep) + @staticmethod + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,DarkGoldenRod,resetCode,sep) + @staticmethod + def GoldenRod(*obj, sep=sep_): return NCS(obj,GoldenRod,resetCode,sep) + @staticmethod + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,PaleGoldenRod,resetCode,sep) + @staticmethod + def DarkKhaki(*obj, sep=sep_): return NCS(obj,DarkKhaki,resetCode,sep) + @staticmethod + def Khaki(*obj, sep=sep_): return NCS(obj,Khaki,resetCode,sep) + @staticmethod + def Olive(*obj, sep=sep_): return NCS(obj,Olive,resetCode,sep) + @staticmethod + def Yellow(*obj, sep=sep_): return NCS(obj,Yellow,resetCode,sep) + @staticmethod + def YellowGreen(*obj, sep=sep_): return NCS(obj,YellowGreen,resetCode,sep) + @staticmethod + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,DarkOliveGreen,resetCode,sep) + @staticmethod + def OliveDrab(*obj, sep=sep_): return NCS(obj,OliveDrab,resetCode,sep) + @staticmethod + def LawnGreen(*obj, sep=sep_): return NCS(obj,LawnGreen,resetCode,sep) + @staticmethod + def Chartreuse(*obj, sep=sep_): return NCS(obj,Chartreuse,resetCode,sep) + @staticmethod + def GreenYellow(*obj, sep=sep_): return NCS(obj,GreenYellow,resetCode,sep) + @staticmethod + def DarkGreen(*obj, sep=sep_): return NCS(obj,DarkGreen,resetCode,sep) + @staticmethod + def Green(*obj, sep=sep_): return NCS(obj,Green,resetCode,sep) + @staticmethod + def ForestGreen(*obj, sep=sep_): return NCS(obj,ForestGreen,resetCode,sep) + @staticmethod + def Lime(*obj, sep=sep_): return NCS(obj,Lime,resetCode,sep) + @staticmethod + def LimeGreen(*obj, sep=sep_): return NCS(obj,LimeGreen,resetCode,sep) + @staticmethod + def LightGreen(*obj, sep=sep_): return NCS(obj,LightGreen,resetCode,sep) + @staticmethod + def PaleGreen(*obj, sep=sep_): return NCS(obj,PaleGreen,resetCode,sep) + @staticmethod + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,DarkSeaGreen,resetCode,sep) + @staticmethod + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,MediumSpringGreen,resetCode,sep) + @staticmethod + def SpringGreen(*obj, sep=sep_): return NCS(obj,SpringGreen,resetCode,sep) + @staticmethod + def SeaGreen(*obj, sep=sep_): return NCS(obj,SeaGreen,resetCode,sep) + @staticmethod + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,MediumAquaMarine,resetCode,sep) + @staticmethod + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,MediumSeaGreen,resetCode,sep) + @staticmethod + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,LightSeaGreen,resetCode,sep) + @staticmethod + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,DarkSlateGray,resetCode,sep) + @staticmethod + def Teal(*obj, sep=sep_): return NCS(obj,Teal,resetCode,sep) + @staticmethod + def DarkCyan(*obj, sep=sep_): return NCS(obj,DarkCyan,resetCode,sep) + @staticmethod + def Aqua(*obj, sep=sep_): return NCS(obj,Aqua,resetCode,sep) + @staticmethod + def Cyan(*obj, sep=sep_): return NCS(obj,Cyan,resetCode,sep) + @staticmethod + def LightCyan(*obj, sep=sep_): return NCS(obj,LightCyan,resetCode,sep) + @staticmethod + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,DarkTurquoise,resetCode,sep) + @staticmethod + def Turquoise(*obj, sep=sep_): return NCS(obj,Turquoise,resetCode,sep) + @staticmethod + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,MediumTurquoise,resetCode,sep) + @staticmethod + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,PaleTurquoise,resetCode,sep) + @staticmethod + def AquaMarine(*obj, sep=sep_): return NCS(obj,AquaMarine,resetCode,sep) + @staticmethod + def PowderBlue(*obj, sep=sep_): return NCS(obj,PowderBlue,resetCode,sep) + @staticmethod + def CadetBlue(*obj, sep=sep_): return NCS(obj,CadetBlue,resetCode,sep) + @staticmethod + def SteelBlue(*obj, sep=sep_): return NCS(obj,SteelBlue,resetCode,sep) + @staticmethod + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,CornFlowerBlue,resetCode,sep) + @staticmethod + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,DeepSkyBlue,resetCode,sep) + @staticmethod + def DodgerBlue(*obj, sep=sep_): return NCS(obj,DodgerBlue,resetCode,sep) + @staticmethod + def LightBlue(*obj, sep=sep_): return NCS(obj,LightBlue,resetCode,sep) + @staticmethod + def SkyBlue(*obj, sep=sep_): return NCS(obj,SkyBlue,resetCode,sep) + @staticmethod + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,LightSkyBlue,resetCode,sep) + @staticmethod + def MidnightBlue(*obj, sep=sep_): return NCS(obj,MidnightBlue,resetCode,sep) + @staticmethod + def Navy(*obj, sep=sep_): return NCS(obj,Navy,resetCode,sep) + @staticmethod + def DarkBlue(*obj, sep=sep_): return NCS(obj,DarkBlue,resetCode,sep) + @staticmethod + def MediumBlue(*obj, sep=sep_): return NCS(obj,MediumBlue,resetCode,sep) + @staticmethod + def Blue(*obj, sep=sep_): return NCS(obj,Blue,resetCode,sep) + @staticmethod + def RoyalBlue(*obj, sep=sep_): return NCS(obj,RoyalBlue,resetCode,sep) + @staticmethod + def BlueViolet(*obj, sep=sep_): return NCS(obj,BlueViolet,resetCode,sep) + @staticmethod + def Indigo(*obj, sep=sep_): return NCS(obj,Indigo,resetCode,sep) + @staticmethod + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,DarkSlateBlue,resetCode,sep) + @staticmethod + def SlateBlue(*obj, sep=sep_): return NCS(obj,SlateBlue,resetCode,sep) + @staticmethod + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,MediumSlateBlue,resetCode,sep) + @staticmethod + def MediumPurple(*obj, sep=sep_): return NCS(obj,MediumPurple,resetCode,sep) + @staticmethod + def DarkMagenta(*obj, sep=sep_): return NCS(obj,DarkMagenta,resetCode,sep) + @staticmethod + def DarkViolet(*obj, sep=sep_): return NCS(obj,DarkViolet,resetCode,sep) + @staticmethod + def DarkOrchid(*obj, sep=sep_): return NCS(obj,DarkOrchid,resetCode,sep) + @staticmethod + def MediumOrchid(*obj, sep=sep_): return NCS(obj,MediumOrchid,resetCode,sep) + @staticmethod + def Purple(*obj, sep=sep_): return NCS(obj,Purple,resetCode,sep) + @staticmethod + def Thistle(*obj, sep=sep_): return NCS(obj,Thistle,resetCode,sep) + @staticmethod + def Plum(*obj, sep=sep_): return NCS(obj,Plum,resetCode,sep) + @staticmethod + def Violet(*obj, sep=sep_): return NCS(obj,Violet,resetCode,sep) + @staticmethod + def Magenta(*obj, sep=sep_): return NCS(obj,Magenta,resetCode,sep) + @staticmethod + def Orchid(*obj, sep=sep_): return NCS(obj,Orchid,resetCode,sep) + @staticmethod + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,MediumVioletRed,resetCode,sep) + @staticmethod + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,PaleVioletRed,resetCode,sep) + @staticmethod + def DeepPink(*obj, sep=sep_): return NCS(obj,DeepPink,resetCode,sep) + @staticmethod + def HotPink(*obj, sep=sep_): return NCS(obj,HotPink,resetCode,sep) + @staticmethod + def LightPink(*obj, sep=sep_): return NCS(obj,LightPink,resetCode,sep) + @staticmethod + def Pink(*obj, sep=sep_): return NCS(obj,Pink,resetCode,sep) + @staticmethod + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,AntiqueWhite,resetCode,sep) + @staticmethod + def Beige(*obj, sep=sep_): return NCS(obj,Beige,resetCode,sep) + @staticmethod + def Bisque(*obj, sep=sep_): return NCS(obj,Bisque,resetCode,sep) + @staticmethod + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,BlanchedAlmond,resetCode,sep) + @staticmethod + def Wheat(*obj, sep=sep_): return NCS(obj,Wheat,resetCode,sep) + @staticmethod + def CornSilk(*obj, sep=sep_): return NCS(obj,CornSilk,resetCode,sep) + @staticmethod + def LemonChiffon(*obj, sep=sep_): return NCS(obj,LemonChiffon,resetCode,sep) + @staticmethod + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,LightGoldenRodYellow,resetCode,sep) + @staticmethod + def LightYellow(*obj, sep=sep_): return NCS(obj,LightYellow,resetCode,sep) + @staticmethod + def SaddleBrown(*obj, sep=sep_): return NCS(obj,SaddleBrown,resetCode,sep) + @staticmethod + def Sienna(*obj, sep=sep_): return NCS(obj,Sienna,resetCode,sep) + @staticmethod + def Chocolate(*obj, sep=sep_): return NCS(obj,Chocolate,resetCode,sep) + @staticmethod + def Peru(*obj, sep=sep_): return NCS(obj,Peru,resetCode,sep) + @staticmethod + def SandyBrown(*obj, sep=sep_): return NCS(obj,SandyBrown,resetCode,sep) + @staticmethod + def BurlyWood(*obj, sep=sep_): return NCS(obj,BurlyWood,resetCode,sep) + @staticmethod + def Tan(*obj, sep=sep_): return NCS(obj,Tan,resetCode,sep) + @staticmethod + def RosyBrown(*obj, sep=sep_): return NCS(obj,RosyBrown,resetCode,sep) + @staticmethod + def Moccasin(*obj, sep=sep_): return NCS(obj,Moccasin,resetCode,sep) + @staticmethod + def NavajoWhite(*obj, sep=sep_): return NCS(obj,NavajoWhite,resetCode,sep) + @staticmethod + def PeachPuff(*obj, sep=sep_): return NCS(obj,PeachPuff,resetCode,sep) + @staticmethod + def MistyRose(*obj, sep=sep_): return NCS(obj,MistyRose,resetCode,sep) + @staticmethod + def LavenderBlush(*obj, sep=sep_): return NCS(obj,LavenderBlush,resetCode,sep) + @staticmethod + def Linen(*obj, sep=sep_): return NCS(obj,Linen,resetCode,sep) + @staticmethod + def OldLace(*obj, sep=sep_): return NCS(obj,OldLace,resetCode,sep) + @staticmethod + def PapayaWhip(*obj, sep=sep_): return NCS(obj,PapayaWhip,resetCode,sep) + @staticmethod + def WeaShell(*obj, sep=sep_): return NCS(obj,WeaShell,resetCode,sep) + @staticmethod + def MintCream(*obj, sep=sep_): return NCS(obj,MintCream,resetCode,sep) + @staticmethod + def SlateGray(*obj, sep=sep_): return NCS(obj,SlateGray,resetCode,sep) + @staticmethod + def LightSlateGray(*obj, sep=sep_): return NCS(obj,LightSlateGray,resetCode,sep) + @staticmethod + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,LightSteelBlue,resetCode,sep) + @staticmethod + def Lavender(*obj, sep=sep_): return NCS(obj,Lavender,resetCode,sep) + @staticmethod + def FloralWhite(*obj, sep=sep_): return NCS(obj,FloralWhite,resetCode,sep) + @staticmethod + def AliceBlue(*obj, sep=sep_): return NCS(obj,AliceBlue,resetCode,sep) + @staticmethod + def GhostWhite(*obj, sep=sep_): return NCS(obj,GhostWhite,resetCode,sep) + @staticmethod + def Honeydew(*obj, sep=sep_): return NCS(obj,Honeydew,resetCode,sep) + @staticmethod + def Ivory(*obj, sep=sep_): return NCS(obj,Ivory,resetCode,sep) + @staticmethod + def Azure(*obj, sep=sep_): return NCS(obj,Azure,resetCode,sep) + @staticmethod + def Snow(*obj, sep=sep_): return NCS(obj,Snow,resetCode,sep) + @staticmethod + def Black(*obj, sep=sep_): return NCS(obj,Black,resetCode,sep) + @staticmethod + def DimGray(*obj, sep=sep_): return NCS(obj,DimGray,resetCode,sep) + @staticmethod + def Gray(*obj, sep=sep_): return NCS(obj,Gray,resetCode,sep) + @staticmethod + def DarkGray(*obj, sep=sep_): return NCS(obj,DarkGray,resetCode,sep) + @staticmethod + def Silver(*obj, sep=sep_): return NCS(obj,Silver,resetCode,sep) + @staticmethod + def LightGray(*obj, sep=sep_): return NCS(obj,LightGray,resetCode,sep) + @staticmethod + def Gainsboro(*obj, sep=sep_): return NCS(obj,Gainsboro,resetCode,sep) + @staticmethod + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,WhiteSmoke,resetCode,sep) + @staticmethod + def White(*obj, sep=sep_): return NCS(obj,White,resetCode,sep) \ No newline at end of file diff --git a/src/AthenaColor/__init__.py b/src/AthenaColor/__init__.py index ce736f7..414944a 100644 --- a/src/AthenaColor/__init__.py +++ b/src/AthenaColor/__init__.py @@ -25,9 +25,10 @@ from AthenaColor.Objects.Console.Styling.Inline.MakeUp import ( Style,Basic ) -from AthenaColor.Objects.Console.Styling.Nested.Nested_Bodies import ( - ForeNest,BackNest,UnderlineNest -) +from AthenaColor.Objects.Console.Styling.Nested.ForeNest import ForeNest +from AthenaColor.Objects.Console.Styling.Nested.BackNest import BackNest +from AthenaColor.Objects.Console.Styling.Nested.UnderlineNest import UnderlineNest + from AthenaColor.Objects.Console.Styling.Nested.Nested_MakeUp import ( StyleNest,BasicNest ) From e151a8886ee74cfde467d193be6a350142860062 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 00:56:51 +0200 Subject: [PATCH 30/40] Change: Removed Keywords for speedup --- Tests/SpeedTest.py | 2 +- .../Console/Styling/Nested/Nested_MakeUp.py | 171 +++++++++--------- 2 files changed, 87 insertions(+), 86 deletions(-) diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py index 5960650..cd22232 100644 --- a/Tests/SpeedTest.py +++ b/Tests/SpeedTest.py @@ -29,7 +29,7 @@ def TextInline(): def TextNested(): a = ForeNest.Red("SOMETHING") b = StyleNest.Bold("Bold") - c = BackNest.Blue("I'M BLUE") + c = BackNest.Maroon("I'M BLUE") return a,b,c if __name__ == '__main__': diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py index 8562b99..cf417b3 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py @@ -20,114 +20,115 @@ # ---------------------------------------------------------------------------------------------------------------------- NCS = NestedColorSequence # Done for slight speed increase NCSNO = NestedColorSequence_NoReset # Done for slight speed increase +sep_ = " " class StyleNest: @staticmethod - def Reset(*obj, sep=" "): return NCSNO(obj, control_code=0, sep=sep) + def Reset(*obj,sep=sep_): return NCSNO(obj,0,sep) @staticmethod - def Bold(*obj, sep=" "): return NCS(obj, control_code=1, reset_code=22, sep=sep) + def Bold(*obj,sep=sep_): return NCS(obj,1,22,sep) @staticmethod - def NoBold(*obj, sep=" "): return NCSNO(obj, control_code=22, sep=sep) + def NoBold(*obj,sep=sep_): return NCSNO(obj,22,sep) @staticmethod - def Dim(*obj, sep=" "): return NCS(obj, control_code=2, reset_code=22, sep=sep) + def Dim(*obj,sep=sep_): return NCS(obj,2,22,sep) @staticmethod - def NoDim(*obj, sep=" "): return NCSNO(obj, control_code=22, sep=sep) + def NoDim(*obj,sep=sep_): return NCSNO(obj,22,sep) @staticmethod - def Italic(*obj, sep=" "): return NCS(obj, control_code=3, reset_code=23, sep=sep) + def Italic(*obj,sep=sep_): return NCS(obj,3,23,sep) @staticmethod - def NoItalic(*obj, sep=" "): return NCSNO(obj, control_code=23, sep=sep) + def NoItalic(*obj,sep=sep_): return NCSNO(obj,23,sep) @staticmethod - def Underline(*obj, sep=" "): return NCS(obj, control_code=4, reset_code=24, sep=sep) + def Underline(*obj,sep=sep_): return NCS(obj,4,24,sep) @staticmethod - def NoUnderline(*obj, sep=" "): return NCSNO(obj, control_code=24, sep=sep) + def NoUnderline(*obj,sep=sep_): return NCSNO(obj,24,sep) @staticmethod - def BlinkSlow(*obj, sep=" "): return NCS(obj, control_code=5, reset_code=25, sep=sep) + def BlinkSlow(*obj,sep=sep_): return NCS(obj,5,25,sep) @staticmethod - def NoBlinkSlow(*obj, sep=" "): return NCSNO(obj, control_code=25, sep=sep) + def NoBlinkSlow(*obj,sep=sep_): return NCSNO(obj,25,sep) @staticmethod - def BlinkRapid(*obj, sep=" "): return NCS(obj, control_code=6, reset_code=25, sep=sep) + def BlinkRapid(*obj,sep=sep_): return NCS(obj,6,25,sep) @staticmethod - def NoBlinkRapid(*obj, sep=" "): return NCSNO(obj, control_code=25, sep=sep) + def NoBlinkRapid(*obj,sep=sep_): return NCSNO(obj,25,sep) @staticmethod - def Reversed(*obj, sep=" "): return NCS(obj, control_code=7, reset_code=27, sep=sep) + def Reversed(*obj,sep=sep_): return NCS(obj,7,27,sep) @staticmethod - def NoReversed(*obj, sep=" "): return NCSNO(obj, control_code=27, sep=sep) + def NoReversed(*obj,sep=sep_): return NCSNO(obj,27,sep) @staticmethod - def Conceal(*obj, sep=" "): return NCS(obj, control_code=8, reset_code=28, sep=sep) + def Conceal(*obj,sep=sep_): return NCS(obj,8,28,sep) @staticmethod - def NoConceal(*obj, sep=" "): return NCSNO(obj, control_code=28, sep=sep) + def NoConceal(*obj,sep=sep_): return NCSNO(obj,28,sep) @staticmethod - def Crossed(*obj, sep=" "): return NCS(obj, control_code=9, reset_code=29, sep=sep) + def Crossed(*obj,sep=sep_): return NCS(obj,9,29,sep) @staticmethod - def NoCrossed(*obj, sep=" "): return NCSNO(obj, control_code=29, sep=sep) + def NoCrossed(*obj,sep=sep_): return NCSNO(obj,29,sep) @staticmethod - def FontPrimary(*obj, sep=" "): return NCS(obj, control_code=10, reset_code=10, sep=sep) + def FontPrimary(*obj,sep=sep_): return NCS(obj,10,10,sep) @staticmethod - def FontSecond1(*obj, sep=" "): return NCS(obj, control_code=11, reset_code=10, sep=sep) + def FontSecond1(*obj,sep=sep_): return NCS(obj,11,10,sep) @staticmethod - def FontSecond2(*obj, sep=" "): return NCS(obj, control_code=12, reset_code=10, sep=sep) + def FontSecond2(*obj,sep=sep_): return NCS(obj,12,10,sep) @staticmethod - def FontSecond3(*obj, sep=" "): return NCS(obj, control_code=13, reset_code=10, sep=sep) + def FontSecond3(*obj,sep=sep_): return NCS(obj,13,10,sep) @staticmethod - def FontSecond4(*obj, sep=" "): return NCS(obj, control_code=14, reset_code=10, sep=sep) + def FontSecond4(*obj,sep=sep_): return NCS(obj,14,10,sep) @staticmethod - def FontSecond5(*obj, sep=" "): return NCS(obj, control_code=15, reset_code=10, sep=sep) + def FontSecond5(*obj,sep=sep_): return NCS(obj,15,10,sep) @staticmethod - def FontSecond6(*obj, sep=" "): return NCS(obj, control_code=16, reset_code=10, sep=sep) + def FontSecond6(*obj,sep=sep_): return NCS(obj,16,10,sep) @staticmethod - def FontSecond8(*obj, sep=" "): return NCS(obj, control_code=17, reset_code=10, sep=sep) + def FontSecond8(*obj,sep=sep_): return NCS(obj,17,10,sep) @staticmethod - def FontSecond9(*obj, sep=" "): return NCS(obj, control_code=18, reset_code=10, sep=sep) + def FontSecond9(*obj,sep=sep_): return NCS(obj,18,10,sep) @staticmethod - def FontSecond10(*obj, sep=" "): return NCS(obj, control_code=19, reset_code=10, sep=sep) + def FontSecond10(*obj,sep=sep_): return NCS(obj,19,10,sep) @staticmethod - def NoFont(*obj, sep=" "): return NCSNO(obj, control_code=10, sep=sep) + def NoFont(*obj,sep=sep_): return NCSNO(obj,10,sep) @staticmethod - def Fraktur(*obj, sep=" "): return NCSNO(obj, control_code=20, sep=sep) + def Fraktur(*obj,sep=sep_): return NCSNO(obj,20,sep) @staticmethod - def UnderlineDouble(*obj, sep=" "): return NCS(obj, control_code=21, reset_code=24, sep=sep) + def UnderlineDouble(*obj,sep=sep_): return NCS(obj,21,24,sep) @staticmethod - def NoUnderlineDouble(*obj, sep=" "): return NCSNO(obj, control_code=24, sep=sep) + def NoUnderlineDouble(*obj,sep=sep_): return NCSNO(obj,24,sep) @staticmethod - def PropSpacing(*obj, sep=" "): return NCS(obj, control_code=26, reset_code=26, sep=sep) + def PropSpacing(*obj,sep=sep_): return NCS(obj,26,26,sep) @staticmethod - def NoPropSpacing(*obj, sep=" "): return NCSNO(obj, control_code=26, sep=sep) + def NoPropSpacing(*obj,sep=sep_): return NCSNO(obj,26,sep) @staticmethod - def NoForeground(*obj, sep=" "): return NCSNO(obj, control_code=39, sep=sep) + def NoForeground(*obj,sep=sep_): return NCSNO(obj,39,sep) @staticmethod - def NoBackground(*obj, sep=" "): return NCSNO(obj, control_code=49, sep=sep) + def NoBackground(*obj,sep=sep_): return NCSNO(obj,49,sep) @staticmethod - def Frame(*obj, sep=" "): return NCS(obj, control_code=51, reset_code=54, sep=sep) + def Frame(*obj,sep=sep_): return NCS(obj,51,54,sep) @staticmethod - def NoFrame(*obj, sep=" "): return NCSNO(obj, control_code=54, sep=sep) + def NoFrame(*obj,sep=sep_): return NCSNO(obj,54,sep) @staticmethod - def Circle(*obj, sep=" "): return NCS(obj, control_code=52, reset_code=54, sep=sep) + def Circle(*obj,sep=sep_): return NCS(obj,52,54,sep) @staticmethod - def NoCircle(*obj, sep=" "): return NCSNO(obj, control_code=54, sep=sep) + def NoCircle(*obj,sep=sep_): return NCSNO(obj,54,sep) @staticmethod - def OverLine(*obj, sep=" "): return NCS(obj, control_code=53, reset_code=55, sep=sep) + def OverLine(*obj,sep=sep_): return NCS(obj,53,55,sep) @staticmethod - def NoOverLine(*obj, sep=" "): return NCSNO(obj, control_code=55, sep=sep) + def NoOverLine(*obj,sep=sep_): return NCSNO(obj,55,sep) @staticmethod - def UnderColourDefault(*obj, sep=" "): return NCSNO(obj, control_code=59, sep=sep) + def UnderColourDefault(*obj,sep=sep_): return NCSNO(obj,59,sep) @staticmethod - def IdeogramUnderLine(*obj, sep=" "): return NCS(obj, control_code=60, reset_code=65, sep=sep) + def IdeogramUnderLine(*obj,sep=sep_): return NCS(obj,60,65,sep) @staticmethod - def IdeogramUnderLineDouble(*obj, sep=" "): return NCS(obj, control_code=61, reset_code=65, sep=sep) + def IdeogramUnderLineDouble(*obj,sep=sep_): return NCS(obj,61,65,sep) @staticmethod - def IdeogramOverLine(*obj, sep=" "): return NCS(obj, control_code=62, reset_code=65, sep=sep) + def IdeogramOverLine(*obj,sep=sep_): return NCS(obj,62,65,sep) @staticmethod - def IdeogramOverLineDouble(*obj, sep=" "): return NCS(obj, control_code=63, reset_code=65, sep=sep) + def IdeogramOverLineDouble(*obj,sep=sep_): return NCS(obj,63,65,sep) @staticmethod - def IdeogramStress(*obj, sep=" "): return NCS(obj, control_code=64, reset_code=65, sep=sep) + def IdeogramStress(*obj,sep=sep_): return NCS(obj,64,65,sep) @staticmethod - def NoIdeogram(*obj, sep=" "): return NCSNO(obj, control_code=65, sep=sep) + def NoIdeogram(*obj,sep=sep_): return NCSNO(obj,65,sep) @staticmethod - def SuperScript(*obj, sep=" "): return NCS(obj, control_code=73, reset_code=75, sep=sep) + def SuperScript(*obj,sep=sep_): return NCS(obj,73,75,sep) @staticmethod - def SubScript(*obj, sep=" "): return NCS(obj, control_code=74, reset_code=75, sep=sep) + def SubScript(*obj,sep=sep_): return NCS(obj,74,75,sep) @staticmethod - def NoScript(*obj, sep=" "): return NCSNO(obj, control_code=75, sep=sep) + def NoScript(*obj,sep=sep_): return NCSNO(obj,75,sep) # ---------------------------------------------------------------------------------------------------------------------- # - BasicNest Sequences - @@ -135,68 +136,68 @@ def NoScript(*obj, sep=" "): return NCSNO(obj, control_code=7 class BasicNest: class Fore: @staticmethod - def Black(*obj, sep=" "): return NCS(obj, 30, 39, sep=sep) + def Black(*obj,sep=sep_): return NCS(obj, 30, 39,sep) @staticmethod - def Red(*obj, sep=" "): return NCS(obj, 31, 39, sep=sep) + def Red(*obj,sep=sep_): return NCS(obj, 31, 39,sep) @staticmethod - def Green(*obj, sep=" "): return NCS(obj, 32, 39, sep=sep) + def Green(*obj,sep=sep_): return NCS(obj, 32, 39,sep) @staticmethod - def Yellow(*obj, sep=" "): return NCS(obj, 33, 39, sep=sep) + def Yellow(*obj,sep=sep_): return NCS(obj, 33, 39,sep) @staticmethod - def Blue(*obj, sep=" "): return NCS(obj, 34, 39, sep=sep) + def Blue(*obj,sep=sep_): return NCS(obj, 34, 39,sep) @staticmethod - def Magenta(*obj, sep=" "): return NCS(obj, 35, 39, sep=sep) + def Magenta(*obj,sep=sep_): return NCS(obj, 35, 39,sep) @staticmethod - def Cyan(*obj, sep=" "): return NCS(obj, 36, 39, sep=sep) + def Cyan(*obj,sep=sep_): return NCS(obj, 36, 39,sep) @staticmethod - def White(*obj, sep=" "): return NCS(obj, 37, 39, sep=sep) + def White(*obj,sep=sep_): return NCS(obj, 37, 39,sep) @staticmethod - def BrightBlack(*obj, sep=" "): return NCS(obj, 90, 39, sep=sep) + def BrightBlack(*obj,sep=sep_): return NCS(obj, 90, 39,sep) @staticmethod - def BrightRed(*obj, sep=" "): return NCS(obj, 91, 39, sep=sep) + def BrightRed(*obj,sep=sep_): return NCS(obj, 91, 39,sep) @staticmethod - def BrightGreen(*obj, sep=" "): return NCS(obj, 92, 39, sep=sep) + def BrightGreen(*obj,sep=sep_): return NCS(obj, 92, 39,sep) @staticmethod - def BrightYellow(*obj, sep=" "): return NCS(obj, 93, 39, sep=sep) + def BrightYellow(*obj,sep=sep_): return NCS(obj, 93, 39,sep) @staticmethod - def BrightBlue(*obj, sep=" "): return NCS(obj, 94, 39, sep=sep) + def BrightBlue(*obj,sep=sep_): return NCS(obj, 94, 39,sep) @staticmethod - def BrightMagenta(*obj, sep=" "): return NCS(obj, 95, 39, sep=sep) + def BrightMagenta(*obj,sep=sep_): return NCS(obj, 95, 39,sep) @staticmethod - def BrightCyan(*obj, sep=" "): return NCS(obj, 96, 39, sep=sep) + def BrightCyan(*obj,sep=sep_): return NCS(obj, 96, 39,sep) @staticmethod - def BrightWhite(*obj, sep=" "): return NCS(obj, 97, 39, sep=sep) + def BrightWhite(*obj,sep=sep_): return NCS(obj, 97, 39,sep) class Back: @staticmethod - def Black(*obj, sep=" "): return NCS(obj, 40, 49, sep=sep) + def Black(*obj,sep=sep_): return NCS(obj, 40, 49,sep) @staticmethod - def Red(*obj, sep=" "): return NCS(obj, 41, 49, sep=sep) + def Red(*obj,sep=sep_): return NCS(obj, 41, 49,sep) @staticmethod - def Green(*obj, sep=" "): return NCS(obj, 42, 49, sep=sep) + def Green(*obj,sep=sep_): return NCS(obj, 42, 49,sep) @staticmethod - def Yellow(*obj, sep=" "): return NCS(obj, 43, 49, sep=sep) + def Yellow(*obj,sep=sep_): return NCS(obj, 43, 49,sep) @staticmethod - def Blue(*obj, sep=" "): return NCS(obj, 44, 49, sep=sep) + def Blue(*obj,sep=sep_): return NCS(obj, 44, 49,sep) @staticmethod - def Magenta(*obj, sep=" "): return NCS(obj, 45, 49, sep=sep) + def Magenta(*obj,sep=sep_): return NCS(obj, 45, 49,sep) @staticmethod - def Cyan(*obj, sep=" "): return NCS(obj, 46, 49, sep=sep) + def Cyan(*obj,sep=sep_): return NCS(obj, 46, 49,sep) @staticmethod - def White(*obj, sep=" "): return NCS(obj, 47, 49, sep=sep) + def White(*obj,sep=sep_): return NCS(obj, 47, 49,sep) @staticmethod - def BrightBlack(*obj, sep=" "): return NCS(obj, 100, 49, sep=sep) + def BrightBlack(*obj,sep=sep_): return NCS(obj, 100, 49,sep) @staticmethod - def BrightRed(*obj, sep=" "): return NCS(obj, 101, 49, sep=sep) + def BrightRed(*obj,sep=sep_): return NCS(obj, 101, 49,sep) @staticmethod - def BrightGreen(*obj, sep=" "): return NCS(obj, 102, 49, sep=sep) + def BrightGreen(*obj,sep=sep_): return NCS(obj, 102, 49,sep) @staticmethod - def BrightYellow(*obj, sep=" "): return NCS(obj, 103, 49, sep=sep) + def BrightYellow(*obj,sep=sep_): return NCS(obj, 103, 49,sep) @staticmethod - def BrightBlue(*obj, sep=" "): return NCS(obj, 104, 49, sep=sep) + def BrightBlue(*obj,sep=sep_): return NCS(obj, 104, 49,sep) @staticmethod - def BrightMagenta(*obj, sep=" "): return NCS(obj, 105, 49, sep=sep) + def BrightMagenta(*obj,sep=sep_): return NCS(obj, 105, 49,sep) @staticmethod - def BrightCyan(*obj, sep=" "): return NCS(obj, 106, 49, sep=sep) + def BrightCyan(*obj,sep=sep_): return NCS(obj, 106, 49,sep) @staticmethod - def BrightWhite(*obj, sep=" "): return NCS(obj, 107, 49, sep=sep) \ No newline at end of file + def BrightWhite(*obj,sep=sep_): return NCS(obj, 107, 49,sep) \ No newline at end of file From 051ecfe3ecb08ff02232e6b35773539a2a77b566 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 13:02:39 +0200 Subject: [PATCH 31/40] Change: Speedup of System --- Tests/Functions/test_ANSIsequences.py | 12 +- src/AthenaColor/Functions/ANSIsquences.py | 17 +- .../Console/Styling/Nested/BackNest.py | 434 ++++++----------- .../Console/Styling/Nested/ForeNest.py | 434 ++++++----------- .../Console/Styling/Nested/Nested_MakeUp.py | 171 +++---- .../Console/Styling/Nested/UnderlineNest.py | 437 ++++++------------ 6 files changed, 541 insertions(+), 964 deletions(-) diff --git a/Tests/Functions/test_ANSIsequences.py b/Tests/Functions/test_ANSIsequences.py index 4211d7c..3cdd5af 100644 --- a/Tests/Functions/test_ANSIsequences.py +++ b/Tests/Functions/test_ANSIsequences.py @@ -21,8 +21,8 @@ def nested(nested): ("This is a test", nested), # color/styling, reset and seperation - control_code="38;2;128;0;0", - reset_code=0, + color_code="\033[38;2;128;0;0m", + reset_code="\033[0m", sep="\n" ) @@ -43,8 +43,8 @@ def test_NestedColorSequence(self): ("This is a test", "For real"), # color/styling, reset and seperation - control_code="38;2;128;0;0", - reset_code=0, + color_code="\033[38;2;128;0;0m", + reset_code="\033[0m", sep="\n" ), f"""This is a test @@ -57,8 +57,8 @@ def test_NestedColorSequence(self): ("This is a test", "For real"), # color/styling, reset and seperation - control_code="38;2;128;0;0", - reset_code=0, + color_code="\033[38;2;128;0;0m", + reset_code="\033[0m", sep="\n" ))), f"""This is a test diff --git a/src/AthenaColor/Functions/ANSIsquences.py b/src/AthenaColor/Functions/ANSIsquences.py index 553a7f0..a585bef 100644 --- a/src/AthenaColor/Functions/ANSIsquences.py +++ b/src/AthenaColor/Functions/ANSIsquences.py @@ -28,7 +28,7 @@ def ColorSequence(control_code:int|str)->str: """ return f'{init.esc}[{control_code}m' -def NestedColorSequence(obj:tuple, control_code:int|str, reset_code:int|str, sep:str=" ") -> str: +def NestedColorSequence(obj:tuple, color_code:str, reset_code:int|str, sep:str=" ") -> str: """ Used by Nested Console StyleNest Makeup operations like ForeNest, BackNest, StyleNest. Function wraps every obj in the properly defined control- and reset codes. @@ -36,15 +36,12 @@ def NestedColorSequence(obj:tuple, control_code:int|str, reset_code:int|str, sep """ # SHHH, don't touch this, this is speed 101 - init_esc = init.esc - color = f'{init_esc}[{control_code}m' - reset = f'{init_esc}[{reset_code}m' text = "" for o in obj[:-1]: - text += f"{color}{o}{sep}{reset}" # SEP moved to within the color - reset, as previously, it was color-reset anyways - return text + f"{color}{obj[-1]}{reset}" + text += f"{color_code}{o}{sep}{reset_code}" # SEP moved to within the color - reset, as previously, it was color-reset anyways + return text + f"{color_code}{obj[-1]}{reset_code}" -def NestedColorSequence_NoReset(obj:tuple, control_code:int|str, sep:str=" ") -> str: +def NestedColorSequence_NoReset(obj:tuple, color_code:int|str, sep:str=" ") -> str: """ Used by Nested Console StyleNest Makeup operations like ForeNest, BackNest, StyleNest. Function wraps every obj in the properly defined control- and reset codes. @@ -52,9 +49,7 @@ def NestedColorSequence_NoReset(obj:tuple, control_code:int|str, sep:str=" ") -> """ # SHHH, don't touch this, this is speed 101 - init_esc = init.esc - color = f'{init_esc}[{control_code}m' text = "" for o in obj[:-1]: - text += f"{color}{o}{sep}" # SEP moved to within the color - reset, as previously, it was color-reset anyways - return text + f"{color}{obj[-1]}" \ No newline at end of file + text += f"{color_code}{o}{sep}" # SEP moved to within the color - reset, as previously, it was color-reset anyways + return text + f"{color_code}{obj[-1]}" \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py index 85b43a4..313bf56 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py @@ -10,6 +10,8 @@ from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence from AthenaColor.Functions.General import StrictType +from AthenaColor.Objects.Console.Styling.Inline.Bodies import Back +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -22,150 +24,8 @@ # - Code - # ---------------------------------------------------------------------------------------------------------------------- NCS = NestedColorSequence # Done for slight speed increase -resetCode=49 sep_=" " -# Predefined Strings to speed calls up -Maroon =f"48;2;128;0;0" -DarkRed =f"48;2;139;0;0" -Brown =f"48;2;165;42;42" -Firebrick =f"48;2;178;34;34" -Crimson =f"48;2;220;20;60" -Red =f"48;2;255;0;0" -Tomato =f"48;2;255;99;71" -Coral =f"48;2;255;127;80" -IndianRed =f"48;2;205;92;92" -LightCoral =f"48;2;240;128;128" -DarkSalmon =f"48;2;233;150;122" -Salmon =f"48;2;250;128;114" -LightSalmon =f"48;2;255;160;122" -OrangeRed =f"48;2;255;69;0" -DarkOrange =f"48;2;255;140;0" -Orange =f"48;2;255;165;0" -Gold =f"48;2;255;215;0" -DarkGoldenRod =f"48;2;184;134;11" -GoldenRod =f"48;2;218;165;32" -PaleGoldenRod =f"48;2;238;232;170" -DarkKhaki =f"48;2;189;183;107" -Khaki =f"48;2;240;230;140" -Olive =f"48;2;128;128;0" -Yellow =f"48;2;255;255;0" -YellowGreen =f"48;2;154;205;50" -DarkOliveGreen =f"48;2;85;107;47" -OliveDrab =f"48;2;107;142;35" -LawnGreen =f"48;2;124;252;0" -Chartreuse =f"48;2;127;255;0" -GreenYellow =f"48;2;173;255;47" -DarkGreen =f"48;2;0;100;0" -Green =f"48;2;0;128;0" -ForestGreen =f"48;2;34;139;34" -Lime =f"48;2;0;255;0" -LimeGreen =f"48;2;50;205;50" -LightGreen =f"48;2;144;238;144" -PaleGreen =f"48;2;152;251;152" -DarkSeaGreen =f"48;2;143;188;143" -MediumSpringGreen =f"48;2;0;250;154" -SpringGreen =f"48;2;0;255;127" -SeaGreen =f"48;2;46;139;87" -MediumAquaMarine =f"48;2;102;205;170" -MediumSeaGreen =f"48;2;60;179;113" -LightSeaGreen =f"48;2;32;178;170" -DarkSlateGray =f"48;2;47;79 ;79" -Teal =f"48;2;0;128;128" -DarkCyan =f"48;2;0;139;139" -Aqua =f"48;2;0;255;255" -Cyan =f"48;2;0;255;255" -LightCyan =f"48;2;224;255;255" -DarkTurquoise =f"48;2;0;206;209" -Turquoise =f"48;2;64;224;208" -MediumTurquoise =f"48;2;72;209;204" -PaleTurquoise =f"48;2;175;238;238" -AquaMarine =f"48;2;127;255;212" -PowderBlue =f"48;2;176;224;230" -CadetBlue =f"48;2;95;158;160" -SteelBlue =f"48;2;70;130;180" -CornFlowerBlue =f"48;2;100;149;237" -DeepSkyBlue =f"48;2;0;191;255" -DodgerBlue =f"48;2;30;144;255" -LightBlue =f"48;2;173;216;230" -SkyBlue =f"48;2;135;206;235" -LightSkyBlue =f"48;2;135;206;250" -MidnightBlue =f"48;2;25;25;112" -Navy =f"48;2;0;0;128" -DarkBlue =f"48;2;0;0;139" -MediumBlue =f"48;2;0;0;205" -Blue =f"48;2;0;0;255" -RoyalBlue =f"48;2;65;105;225" -BlueViolet =f"48;2;138;43;226" -Indigo =f"48;2;75;0;130" -DarkSlateBlue =f"48;2;72;61;139" -SlateBlue =f"48;2;106;90;205" -MediumSlateBlue =f"48;2;123;104;238" -MediumPurple =f"48;2;147;112;219" -DarkMagenta =f"48;2;139;0;139" -DarkViolet =f"48;2;148;0;211" -DarkOrchid =f"48;2;153;50;204" -MediumOrchid =f"48;2;186;85;211" -Purple =f"48;2;128;0;128" -Thistle =f"48;2;216;191;216" -Plum =f"48;2;221;160;221" -Violet =f"48;2;238;130;238" -Magenta =f"48;2;255;0;255" -Orchid =f"48;2;218;112;214" -MediumVioletRed =f"48;2;199;21;133" -PaleVioletRed =f"48;2;219;112;147" -DeepPink =f"48;2;255;20;147" -HotPink =f"48;2;255;105;180" -LightPink =f"48;2;255;182;193" -Pink =f"48;2;255;192;203" -AntiqueWhite =f"48;2;250;235;215" -Beige =f"48;2;245;245;220" -Bisque =f"48;2;255;228;196" -BlanchedAlmond =f"48;2;255;235;205" -Wheat =f"48;2;245;222;179" -CornSilk =f"48;2;255;248;220" -LemonChiffon =f"48;2;255;250;205" -LightGoldenRodYellow =f"48;2;250;250;210" -LightYellow =f"48;2;255;255;224" -SaddleBrown =f"48;2;139;69;19" -Sienna =f"48;2;160;82;45" -Chocolate =f"48;2;210;105;30" -Peru =f"48;2;205;133;63" -SandyBrown =f"48;2;244;164;96" -BurlyWood =f"48;2;222;184;135" -Tan =f"48;2;210;180;140" -RosyBrown =f"48;2;188;143;143" -Moccasin =f"48;2;255;228;181" -NavajoWhite =f"48;2;255;222;173" -PeachPuff =f"48;2;255;218;185" -MistyRose =f"48;2;255;228;225" -LavenderBlush =f"48;2;255;240;245" -Linen =f"48;2;250;240;230" -OldLace =f"48;2;253;245;230" -PapayaWhip =f"48;2;255;239;213" -WeaShell =f"48;2;255;245;238" -MintCream =f"48;2;245;255;250" -SlateGray =f"48;2;112;128;144" -LightSlateGray =f"48;2;119;136;153" -LightSteelBlue =f"48;2;176;196;222" -Lavender =f"48;2;230;230;250" -FloralWhite =f"48;2;255;250;240" -AliceBlue =f"48;2;240;248;255" -GhostWhite =f"48;2;248;248;255" -Honeydew =f"48;2;240;255;240" -Ivory =f"48;2;255;255;240" -Azure =f"48;2;240;255;255" -Snow =f"48;2;255;250;250" -Black =f"48;2;0;0;0" -DimGray =f"48;2;105;105;105" -Gray =f"48;2;128;128;128" -DarkGray =f"48;2;169;169;169" -Silver =f"48;2;192;192;192" -LightGray =f"48;2;211;211;211" -Gainsboro =f"48;2;220;220;220" -WhiteSmoke =f"48;2;245;245;245" -White =f"48;2;255;255;255" - class BackNest: # ------------------------------------------------------------------------------------------------------------------ # - Methods - @@ -175,9 +35,9 @@ def custom(*obj, color:RGB|HEX, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' color = StrictType(color,(RGB,HEX)) return NestedColorSequence( - *obj, - control_code=f"48;2;{color.r};{color.g};{color.b}", - reset_code=resetCode, + obj, + f"\033[48;2;{color.r};{color.g};{color.b}m", + Style.NoBackground, **kwargs ) @@ -186,9 +46,9 @@ def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' r,g,b = NormalizeRgb(r, g, b) return NestedColorSequence( - *obj, - control_code=f"48;2;{r};{g};{b}", - reset_code=resetCode, + obj, + f"\033[48;2;{r};{g};{b}m", + Style.NoBackground, **kwargs ) @@ -197,280 +57,280 @@ def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: # ------------------------------------------------------------------------------------------------------------------ # No partial methods, as this was increase the speed impact 2-fold @staticmethod - def Maroon(*obj, sep=sep_): return NCS(obj,Maroon,resetCode,sep) + def Maroon(*obj, sep=sep_): return NCS(obj,Back.Maroon,Style.NoBackground,sep) @staticmethod - def DarkRed(*obj, sep=sep_): return NCS(obj,DarkRed,resetCode,sep) + def DarkRed(*obj, sep=sep_): return NCS(obj,Back.DarkRed,Style.NoBackground,sep) @staticmethod - def Brown(*obj, sep=sep_): return NCS(obj,Brown,resetCode,sep) + def Brown(*obj, sep=sep_): return NCS(obj,Back.Brown,Style.NoBackground,sep) @staticmethod - def Firebrick(*obj, sep=sep_): return NCS(obj,Firebrick,resetCode,sep) + def Firebrick(*obj, sep=sep_): return NCS(obj,Back.Firebrick,Style.NoBackground,sep) @staticmethod - def Crimson(*obj, sep=sep_): return NCS(obj,Crimson,resetCode,sep) + def Crimson(*obj, sep=sep_): return NCS(obj,Back.Crimson,Style.NoBackground,sep) @staticmethod - def Red(*obj, sep=sep_): return NCS(obj,Red,resetCode,sep) + def Red(*obj, sep=sep_): return NCS(obj,Back.Red,Style.NoBackground,sep) @staticmethod - def Tomato(*obj, sep=sep_): return NCS(obj,Tomato,resetCode,sep) + def Tomato(*obj, sep=sep_): return NCS(obj,Back.Tomato,Style.NoBackground,sep) @staticmethod - def Coral(*obj, sep=sep_): return NCS(obj,Coral,resetCode,sep) + def Coral(*obj, sep=sep_): return NCS(obj,Back.Coral,Style.NoBackground,sep) @staticmethod - def IndianRed(*obj, sep=sep_): return NCS(obj,IndianRed,resetCode,sep) + def IndianRed(*obj, sep=sep_): return NCS(obj,Back.IndianRed,Style.NoBackground,sep) @staticmethod - def LightCoral(*obj, sep=sep_): return NCS(obj,LightCoral,resetCode,sep) + def LightCoral(*obj, sep=sep_): return NCS(obj,Back.LightCoral,Style.NoBackground,sep) @staticmethod - def DarkSalmon(*obj, sep=sep_): return NCS(obj,DarkSalmon,resetCode,sep) + def DarkSalmon(*obj, sep=sep_): return NCS(obj,Back.DarkSalmon,Style.NoBackground,sep) @staticmethod - def Salmon(*obj, sep=sep_): return NCS(obj,Salmon,resetCode,sep) + def Salmon(*obj, sep=sep_): return NCS(obj,Back.Salmon,Style.NoBackground,sep) @staticmethod - def LightSalmon(*obj, sep=sep_): return NCS(obj,LightSalmon,resetCode,sep) + def LightSalmon(*obj, sep=sep_): return NCS(obj,Back.LightSalmon,Style.NoBackground,sep) @staticmethod - def OrangeRed(*obj, sep=sep_): return NCS(obj,OrangeRed,resetCode,sep) + def OrangeRed(*obj, sep=sep_): return NCS(obj,Back.OrangeRed,Style.NoBackground,sep) @staticmethod - def DarkOrange(*obj, sep=sep_): return NCS(obj,DarkOrange,resetCode,sep) + def DarkOrange(*obj, sep=sep_): return NCS(obj,Back.DarkOrange,Style.NoBackground,sep) @staticmethod - def Orange(*obj, sep=sep_): return NCS(obj,Orange,resetCode,sep) + def Orange(*obj, sep=sep_): return NCS(obj,Back.Orange,Style.NoBackground,sep) @staticmethod - def Gold(*obj, sep=sep_): return NCS(obj,Gold,resetCode,sep) + def Gold(*obj, sep=sep_): return NCS(obj,Back.Gold,Style.NoBackground,sep) @staticmethod - def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,DarkGoldenRod,resetCode,sep) + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,Back.DarkGoldenRod,Style.NoBackground,sep) @staticmethod - def GoldenRod(*obj, sep=sep_): return NCS(obj,GoldenRod,resetCode,sep) + def GoldenRod(*obj, sep=sep_): return NCS(obj,Back.GoldenRod,Style.NoBackground,sep) @staticmethod - def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,PaleGoldenRod,resetCode,sep) + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,Back.PaleGoldenRod,Style.NoBackground,sep) @staticmethod - def DarkKhaki(*obj, sep=sep_): return NCS(obj,DarkKhaki,resetCode,sep) + def DarkKhaki(*obj, sep=sep_): return NCS(obj,Back.DarkKhaki,Style.NoBackground,sep) @staticmethod - def Khaki(*obj, sep=sep_): return NCS(obj,Khaki,resetCode,sep) + def Khaki(*obj, sep=sep_): return NCS(obj,Back.Khaki,Style.NoBackground,sep) @staticmethod - def Olive(*obj, sep=sep_): return NCS(obj,Olive,resetCode,sep) + def Olive(*obj, sep=sep_): return NCS(obj,Back.Olive,Style.NoBackground,sep) @staticmethod - def Yellow(*obj, sep=sep_): return NCS(obj,Yellow,resetCode,sep) + def Yellow(*obj, sep=sep_): return NCS(obj,Back.Yellow,Style.NoBackground,sep) @staticmethod - def YellowGreen(*obj, sep=sep_): return NCS(obj,YellowGreen,resetCode,sep) + def YellowGreen(*obj, sep=sep_): return NCS(obj,Back.YellowGreen,Style.NoBackground,sep) @staticmethod - def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,DarkOliveGreen,resetCode,sep) + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,Back.DarkOliveGreen,Style.NoBackground,sep) @staticmethod - def OliveDrab(*obj, sep=sep_): return NCS(obj,OliveDrab,resetCode,sep) + def OliveDrab(*obj, sep=sep_): return NCS(obj,Back.OliveDrab,Style.NoBackground,sep) @staticmethod - def LawnGreen(*obj, sep=sep_): return NCS(obj,LawnGreen,resetCode,sep) + def LawnGreen(*obj, sep=sep_): return NCS(obj,Back.LawnGreen,Style.NoBackground,sep) @staticmethod - def Chartreuse(*obj, sep=sep_): return NCS(obj,Chartreuse,resetCode,sep) + def Chartreuse(*obj, sep=sep_): return NCS(obj,Back.Chartreuse,Style.NoBackground,sep) @staticmethod - def GreenYellow(*obj, sep=sep_): return NCS(obj,GreenYellow,resetCode,sep) + def GreenYellow(*obj, sep=sep_): return NCS(obj,Back.GreenYellow,Style.NoBackground,sep) @staticmethod - def DarkGreen(*obj, sep=sep_): return NCS(obj,DarkGreen,resetCode,sep) + def DarkGreen(*obj, sep=sep_): return NCS(obj,Back.DarkGreen,Style.NoBackground,sep) @staticmethod - def Green(*obj, sep=sep_): return NCS(obj,Green,resetCode,sep) + def Green(*obj, sep=sep_): return NCS(obj,Back.Green,Style.NoBackground,sep) @staticmethod - def ForestGreen(*obj, sep=sep_): return NCS(obj,ForestGreen,resetCode,sep) + def ForestGreen(*obj, sep=sep_): return NCS(obj,Back.ForestGreen,Style.NoBackground,sep) @staticmethod - def Lime(*obj, sep=sep_): return NCS(obj,Lime,resetCode,sep) + def Lime(*obj, sep=sep_): return NCS(obj,Back.Lime,Style.NoBackground,sep) @staticmethod - def LimeGreen(*obj, sep=sep_): return NCS(obj,LimeGreen,resetCode,sep) + def LimeGreen(*obj, sep=sep_): return NCS(obj,Back.LimeGreen,Style.NoBackground,sep) @staticmethod - def LightGreen(*obj, sep=sep_): return NCS(obj,LightGreen,resetCode,sep) + def LightGreen(*obj, sep=sep_): return NCS(obj,Back.LightGreen,Style.NoBackground,sep) @staticmethod - def PaleGreen(*obj, sep=sep_): return NCS(obj,PaleGreen,resetCode,sep) + def PaleGreen(*obj, sep=sep_): return NCS(obj,Back.PaleGreen,Style.NoBackground,sep) @staticmethod - def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,DarkSeaGreen,resetCode,sep) + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,Back.DarkSeaGreen,Style.NoBackground,sep) @staticmethod - def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,MediumSpringGreen,resetCode,sep) + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,Back.MediumSpringGreen,Style.NoBackground,sep) @staticmethod - def SpringGreen(*obj, sep=sep_): return NCS(obj,SpringGreen,resetCode,sep) + def SpringGreen(*obj, sep=sep_): return NCS(obj,Back.SpringGreen,Style.NoBackground,sep) @staticmethod - def SeaGreen(*obj, sep=sep_): return NCS(obj,SeaGreen,resetCode,sep) + def SeaGreen(*obj, sep=sep_): return NCS(obj,Back.SeaGreen,Style.NoBackground,sep) @staticmethod - def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,MediumAquaMarine,resetCode,sep) + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,Back.MediumAquaMarine,Style.NoBackground,sep) @staticmethod - def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,MediumSeaGreen,resetCode,sep) + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,Back.MediumSeaGreen,Style.NoBackground,sep) @staticmethod - def LightSeaGreen(*obj, sep=sep_): return NCS(obj,LightSeaGreen,resetCode,sep) + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,Back.LightSeaGreen,Style.NoBackground,sep) @staticmethod - def DarkSlateGray(*obj, sep=sep_): return NCS(obj,DarkSlateGray,resetCode,sep) + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,Back.DarkSlateGray,Style.NoBackground,sep) @staticmethod - def Teal(*obj, sep=sep_): return NCS(obj,Teal,resetCode,sep) + def Teal(*obj, sep=sep_): return NCS(obj,Back.Teal,Style.NoBackground,sep) @staticmethod - def DarkCyan(*obj, sep=sep_): return NCS(obj,DarkCyan,resetCode,sep) + def DarkCyan(*obj, sep=sep_): return NCS(obj,Back.DarkCyan,Style.NoBackground,sep) @staticmethod - def Aqua(*obj, sep=sep_): return NCS(obj,Aqua,resetCode,sep) + def Aqua(*obj, sep=sep_): return NCS(obj,Back.Aqua,Style.NoBackground,sep) @staticmethod - def Cyan(*obj, sep=sep_): return NCS(obj,Cyan,resetCode,sep) + def Cyan(*obj, sep=sep_): return NCS(obj,Back.Cyan,Style.NoBackground,sep) @staticmethod - def LightCyan(*obj, sep=sep_): return NCS(obj,LightCyan,resetCode,sep) + def LightCyan(*obj, sep=sep_): return NCS(obj,Back.LightCyan,Style.NoBackground,sep) @staticmethod - def DarkTurquoise(*obj, sep=sep_): return NCS(obj,DarkTurquoise,resetCode,sep) + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,Back.DarkTurquoise,Style.NoBackground,sep) @staticmethod - def Turquoise(*obj, sep=sep_): return NCS(obj,Turquoise,resetCode,sep) + def Turquoise(*obj, sep=sep_): return NCS(obj,Back.Turquoise,Style.NoBackground,sep) @staticmethod - def MediumTurquoise(*obj, sep=sep_): return NCS(obj,MediumTurquoise,resetCode,sep) + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,Back.MediumTurquoise,Style.NoBackground,sep) @staticmethod - def PaleTurquoise(*obj, sep=sep_): return NCS(obj,PaleTurquoise,resetCode,sep) + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,Back.PaleTurquoise,Style.NoBackground,sep) @staticmethod - def AquaMarine(*obj, sep=sep_): return NCS(obj,AquaMarine,resetCode,sep) + def AquaMarine(*obj, sep=sep_): return NCS(obj,Back.AquaMarine,Style.NoBackground,sep) @staticmethod - def PowderBlue(*obj, sep=sep_): return NCS(obj,PowderBlue,resetCode,sep) + def PowderBlue(*obj, sep=sep_): return NCS(obj,Back.PowderBlue,Style.NoBackground,sep) @staticmethod - def CadetBlue(*obj, sep=sep_): return NCS(obj,CadetBlue,resetCode,sep) + def CadetBlue(*obj, sep=sep_): return NCS(obj,Back.CadetBlue,Style.NoBackground,sep) @staticmethod - def SteelBlue(*obj, sep=sep_): return NCS(obj,SteelBlue,resetCode,sep) + def SteelBlue(*obj, sep=sep_): return NCS(obj,Back.SteelBlue,Style.NoBackground,sep) @staticmethod - def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,CornFlowerBlue,resetCode,sep) + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,Back.CornFlowerBlue,Style.NoBackground,sep) @staticmethod - def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,DeepSkyBlue,resetCode,sep) + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,Back.DeepSkyBlue,Style.NoBackground,sep) @staticmethod - def DodgerBlue(*obj, sep=sep_): return NCS(obj,DodgerBlue,resetCode,sep) + def DodgerBlue(*obj, sep=sep_): return NCS(obj,Back.DodgerBlue,Style.NoBackground,sep) @staticmethod - def LightBlue(*obj, sep=sep_): return NCS(obj,LightBlue,resetCode,sep) + def LightBlue(*obj, sep=sep_): return NCS(obj,Back.LightBlue,Style.NoBackground,sep) @staticmethod - def SkyBlue(*obj, sep=sep_): return NCS(obj,SkyBlue,resetCode,sep) + def SkyBlue(*obj, sep=sep_): return NCS(obj,Back.SkyBlue,Style.NoBackground,sep) @staticmethod - def LightSkyBlue(*obj, sep=sep_): return NCS(obj,LightSkyBlue,resetCode,sep) + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,Back.LightSkyBlue,Style.NoBackground,sep) @staticmethod - def MidnightBlue(*obj, sep=sep_): return NCS(obj,MidnightBlue,resetCode,sep) + def MidnightBlue(*obj, sep=sep_): return NCS(obj,Back.MidnightBlue,Style.NoBackground,sep) @staticmethod - def Navy(*obj, sep=sep_): return NCS(obj,Navy,resetCode,sep) + def Navy(*obj, sep=sep_): return NCS(obj,Back.Navy,Style.NoBackground,sep) @staticmethod - def DarkBlue(*obj, sep=sep_): return NCS(obj,DarkBlue,resetCode,sep) + def DarkBlue(*obj, sep=sep_): return NCS(obj,Back.DarkBlue,Style.NoBackground,sep) @staticmethod - def MediumBlue(*obj, sep=sep_): return NCS(obj,MediumBlue,resetCode,sep) + def MediumBlue(*obj, sep=sep_): return NCS(obj,Back.MediumBlue,Style.NoBackground,sep) @staticmethod - def Blue(*obj, sep=sep_): return NCS(obj,Blue,resetCode,sep) + def Blue(*obj, sep=sep_): return NCS(obj,Back.Blue,Style.NoBackground,sep) @staticmethod - def RoyalBlue(*obj, sep=sep_): return NCS(obj,RoyalBlue,resetCode,sep) + def RoyalBlue(*obj, sep=sep_): return NCS(obj,Back.RoyalBlue,Style.NoBackground,sep) @staticmethod - def BlueViolet(*obj, sep=sep_): return NCS(obj,BlueViolet,resetCode,sep) + def BlueViolet(*obj, sep=sep_): return NCS(obj,Back.BlueViolet,Style.NoBackground,sep) @staticmethod - def Indigo(*obj, sep=sep_): return NCS(obj,Indigo,resetCode,sep) + def Indigo(*obj, sep=sep_): return NCS(obj,Back.Indigo,Style.NoBackground,sep) @staticmethod - def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,DarkSlateBlue,resetCode,sep) + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,Back.DarkSlateBlue,Style.NoBackground,sep) @staticmethod - def SlateBlue(*obj, sep=sep_): return NCS(obj,SlateBlue,resetCode,sep) + def SlateBlue(*obj, sep=sep_): return NCS(obj,Back.SlateBlue,Style.NoBackground,sep) @staticmethod - def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,MediumSlateBlue,resetCode,sep) + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,Back.MediumSlateBlue,Style.NoBackground,sep) @staticmethod - def MediumPurple(*obj, sep=sep_): return NCS(obj,MediumPurple,resetCode,sep) + def MediumPurple(*obj, sep=sep_): return NCS(obj,Back.MediumPurple,Style.NoBackground,sep) @staticmethod - def DarkMagenta(*obj, sep=sep_): return NCS(obj,DarkMagenta,resetCode,sep) + def DarkMagenta(*obj, sep=sep_): return NCS(obj,Back.DarkMagenta,Style.NoBackground,sep) @staticmethod - def DarkViolet(*obj, sep=sep_): return NCS(obj,DarkViolet,resetCode,sep) + def DarkViolet(*obj, sep=sep_): return NCS(obj,Back.DarkViolet,Style.NoBackground,sep) @staticmethod - def DarkOrchid(*obj, sep=sep_): return NCS(obj,DarkOrchid,resetCode,sep) + def DarkOrchid(*obj, sep=sep_): return NCS(obj,Back.DarkOrchid,Style.NoBackground,sep) @staticmethod - def MediumOrchid(*obj, sep=sep_): return NCS(obj,MediumOrchid,resetCode,sep) + def MediumOrchid(*obj, sep=sep_): return NCS(obj,Back.MediumOrchid,Style.NoBackground,sep) @staticmethod - def Purple(*obj, sep=sep_): return NCS(obj,Purple,resetCode,sep) + def Purple(*obj, sep=sep_): return NCS(obj,Back.Purple,Style.NoBackground,sep) @staticmethod - def Thistle(*obj, sep=sep_): return NCS(obj,Thistle,resetCode,sep) + def Thistle(*obj, sep=sep_): return NCS(obj,Back.Thistle,Style.NoBackground,sep) @staticmethod - def Plum(*obj, sep=sep_): return NCS(obj,Plum,resetCode,sep) + def Plum(*obj, sep=sep_): return NCS(obj,Back.Plum,Style.NoBackground,sep) @staticmethod - def Violet(*obj, sep=sep_): return NCS(obj,Violet,resetCode,sep) + def Violet(*obj, sep=sep_): return NCS(obj,Back.Violet,Style.NoBackground,sep) @staticmethod - def Magenta(*obj, sep=sep_): return NCS(obj,Magenta,resetCode,sep) + def Magenta(*obj, sep=sep_): return NCS(obj,Back.Magenta,Style.NoBackground,sep) @staticmethod - def Orchid(*obj, sep=sep_): return NCS(obj,Orchid,resetCode,sep) + def Orchid(*obj, sep=sep_): return NCS(obj,Back.Orchid,Style.NoBackground,sep) @staticmethod - def MediumVioletRed(*obj, sep=sep_): return NCS(obj,MediumVioletRed,resetCode,sep) + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,Back.MediumVioletRed,Style.NoBackground,sep) @staticmethod - def PaleVioletRed(*obj, sep=sep_): return NCS(obj,PaleVioletRed,resetCode,sep) + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,Back.PaleVioletRed,Style.NoBackground,sep) @staticmethod - def DeepPink(*obj, sep=sep_): return NCS(obj,DeepPink,resetCode,sep) + def DeepPink(*obj, sep=sep_): return NCS(obj,Back.DeepPink,Style.NoBackground,sep) @staticmethod - def HotPink(*obj, sep=sep_): return NCS(obj,HotPink,resetCode,sep) + def HotPink(*obj, sep=sep_): return NCS(obj,Back.HotPink,Style.NoBackground,sep) @staticmethod - def LightPink(*obj, sep=sep_): return NCS(obj,LightPink,resetCode,sep) + def LightPink(*obj, sep=sep_): return NCS(obj,Back.LightPink,Style.NoBackground,sep) @staticmethod - def Pink(*obj, sep=sep_): return NCS(obj,Pink,resetCode,sep) + def Pink(*obj, sep=sep_): return NCS(obj,Back.Pink,Style.NoBackground,sep) @staticmethod - def AntiqueWhite(*obj, sep=sep_): return NCS(obj,AntiqueWhite,resetCode,sep) + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,Back.AntiqueWhite,Style.NoBackground,sep) @staticmethod - def Beige(*obj, sep=sep_): return NCS(obj,Beige,resetCode,sep) + def Beige(*obj, sep=sep_): return NCS(obj,Back.Beige,Style.NoBackground,sep) @staticmethod - def Bisque(*obj, sep=sep_): return NCS(obj,Bisque,resetCode,sep) + def Bisque(*obj, sep=sep_): return NCS(obj,Back.Bisque,Style.NoBackground,sep) @staticmethod - def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,BlanchedAlmond,resetCode,sep) + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,Back.BlanchedAlmond,Style.NoBackground,sep) @staticmethod - def Wheat(*obj, sep=sep_): return NCS(obj,Wheat,resetCode,sep) + def Wheat(*obj, sep=sep_): return NCS(obj,Back.Wheat,Style.NoBackground,sep) @staticmethod - def CornSilk(*obj, sep=sep_): return NCS(obj,CornSilk,resetCode,sep) + def CornSilk(*obj, sep=sep_): return NCS(obj,Back.CornSilk,Style.NoBackground,sep) @staticmethod - def LemonChiffon(*obj, sep=sep_): return NCS(obj,LemonChiffon,resetCode,sep) + def LemonChiffon(*obj, sep=sep_): return NCS(obj,Back.LemonChiffon,Style.NoBackground,sep) @staticmethod - def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,LightGoldenRodYellow,resetCode,sep) + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,Back.LightGoldenRodYellow,Style.NoBackground,sep) @staticmethod - def LightYellow(*obj, sep=sep_): return NCS(obj,LightYellow,resetCode,sep) + def LightYellow(*obj, sep=sep_): return NCS(obj,Back.LightYellow,Style.NoBackground,sep) @staticmethod - def SaddleBrown(*obj, sep=sep_): return NCS(obj,SaddleBrown,resetCode,sep) + def SaddleBrown(*obj, sep=sep_): return NCS(obj,Back.SaddleBrown,Style.NoBackground,sep) @staticmethod - def Sienna(*obj, sep=sep_): return NCS(obj,Sienna,resetCode,sep) + def Sienna(*obj, sep=sep_): return NCS(obj,Back.Sienna,Style.NoBackground,sep) @staticmethod - def Chocolate(*obj, sep=sep_): return NCS(obj,Chocolate,resetCode,sep) + def Chocolate(*obj, sep=sep_): return NCS(obj,Back.Chocolate,Style.NoBackground,sep) @staticmethod - def Peru(*obj, sep=sep_): return NCS(obj,Peru,resetCode,sep) + def Peru(*obj, sep=sep_): return NCS(obj,Back.Peru,Style.NoBackground,sep) @staticmethod - def SandyBrown(*obj, sep=sep_): return NCS(obj,SandyBrown,resetCode,sep) + def SandyBrown(*obj, sep=sep_): return NCS(obj,Back.SandyBrown,Style.NoBackground,sep) @staticmethod - def BurlyWood(*obj, sep=sep_): return NCS(obj,BurlyWood,resetCode,sep) + def BurlyWood(*obj, sep=sep_): return NCS(obj,Back.BurlyWood,Style.NoBackground,sep) @staticmethod - def Tan(*obj, sep=sep_): return NCS(obj,Tan,resetCode,sep) + def Tan(*obj, sep=sep_): return NCS(obj,Back.Tan,Style.NoBackground,sep) @staticmethod - def RosyBrown(*obj, sep=sep_): return NCS(obj,RosyBrown,resetCode,sep) + def RosyBrown(*obj, sep=sep_): return NCS(obj,Back.RosyBrown,Style.NoBackground,sep) @staticmethod - def Moccasin(*obj, sep=sep_): return NCS(obj,Moccasin,resetCode,sep) + def Moccasin(*obj, sep=sep_): return NCS(obj,Back.Moccasin,Style.NoBackground,sep) @staticmethod - def NavajoWhite(*obj, sep=sep_): return NCS(obj,NavajoWhite,resetCode,sep) + def NavajoWhite(*obj, sep=sep_): return NCS(obj,Back.NavajoWhite,Style.NoBackground,sep) @staticmethod - def PeachPuff(*obj, sep=sep_): return NCS(obj,PeachPuff,resetCode,sep) + def PeachPuff(*obj, sep=sep_): return NCS(obj,Back.PeachPuff,Style.NoBackground,sep) @staticmethod - def MistyRose(*obj, sep=sep_): return NCS(obj,MistyRose,resetCode,sep) + def MistyRose(*obj, sep=sep_): return NCS(obj,Back.MistyRose,Style.NoBackground,sep) @staticmethod - def LavenderBlush(*obj, sep=sep_): return NCS(obj,LavenderBlush,resetCode,sep) + def LavenderBlush(*obj, sep=sep_): return NCS(obj,Back.LavenderBlush,Style.NoBackground,sep) @staticmethod - def Linen(*obj, sep=sep_): return NCS(obj,Linen,resetCode,sep) + def Linen(*obj, sep=sep_): return NCS(obj,Back.Linen,Style.NoBackground,sep) @staticmethod - def OldLace(*obj, sep=sep_): return NCS(obj,OldLace,resetCode,sep) + def OldLace(*obj, sep=sep_): return NCS(obj,Back.OldLace,Style.NoBackground,sep) @staticmethod - def PapayaWhip(*obj, sep=sep_): return NCS(obj,PapayaWhip,resetCode,sep) + def PapayaWhip(*obj, sep=sep_): return NCS(obj,Back.PapayaWhip,Style.NoBackground,sep) @staticmethod - def WeaShell(*obj, sep=sep_): return NCS(obj,WeaShell,resetCode,sep) + def WeaShell(*obj, sep=sep_): return NCS(obj,Back.WeaShell,Style.NoBackground,sep) @staticmethod - def MintCream(*obj, sep=sep_): return NCS(obj,MintCream,resetCode,sep) + def MintCream(*obj, sep=sep_): return NCS(obj,Back.MintCream,Style.NoBackground,sep) @staticmethod - def SlateGray(*obj, sep=sep_): return NCS(obj,SlateGray,resetCode,sep) + def SlateGray(*obj, sep=sep_): return NCS(obj,Back.SlateGray,Style.NoBackground,sep) @staticmethod - def LightSlateGray(*obj, sep=sep_): return NCS(obj,LightSlateGray,resetCode,sep) + def LightSlateGray(*obj, sep=sep_): return NCS(obj,Back.LightSlateGray,Style.NoBackground,sep) @staticmethod - def LightSteelBlue(*obj, sep=sep_): return NCS(obj,LightSteelBlue,resetCode,sep) + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,Back.LightSteelBlue,Style.NoBackground,sep) @staticmethod - def Lavender(*obj, sep=sep_): return NCS(obj,Lavender,resetCode,sep) + def Lavender(*obj, sep=sep_): return NCS(obj,Back.Lavender,Style.NoBackground,sep) @staticmethod - def FloralWhite(*obj, sep=sep_): return NCS(obj,FloralWhite,resetCode,sep) + def FloralWhite(*obj, sep=sep_): return NCS(obj,Back.FloralWhite,Style.NoBackground,sep) @staticmethod - def AliceBlue(*obj, sep=sep_): return NCS(obj,AliceBlue,resetCode,sep) + def AliceBlue(*obj, sep=sep_): return NCS(obj,Back.AliceBlue,Style.NoBackground,sep) @staticmethod - def GhostWhite(*obj, sep=sep_): return NCS(obj,GhostWhite,resetCode,sep) + def GhostWhite(*obj, sep=sep_): return NCS(obj,Back.GhostWhite,Style.NoBackground,sep) @staticmethod - def Honeydew(*obj, sep=sep_): return NCS(obj,Honeydew,resetCode,sep) + def Honeydew(*obj, sep=sep_): return NCS(obj,Back.Honeydew,Style.NoBackground,sep) @staticmethod - def Ivory(*obj, sep=sep_): return NCS(obj,Ivory,resetCode,sep) + def Ivory(*obj, sep=sep_): return NCS(obj,Back.Ivory,Style.NoBackground,sep) @staticmethod - def Azure(*obj, sep=sep_): return NCS(obj,Azure,resetCode,sep) + def Azure(*obj, sep=sep_): return NCS(obj,Back.Azure,Style.NoBackground,sep) @staticmethod - def Snow(*obj, sep=sep_): return NCS(obj,Snow,resetCode,sep) + def Snow(*obj, sep=sep_): return NCS(obj,Back.Snow,Style.NoBackground,sep) @staticmethod - def Black(*obj, sep=sep_): return NCS(obj,Black,resetCode,sep) + def Black(*obj, sep=sep_): return NCS(obj,Back.Black,Style.NoBackground,sep) @staticmethod - def DimGray(*obj, sep=sep_): return NCS(obj,DimGray,resetCode,sep) + def DimGray(*obj, sep=sep_): return NCS(obj,Back.DimGray,Style.NoBackground,sep) @staticmethod - def Gray(*obj, sep=sep_): return NCS(obj,Gray,resetCode,sep) + def Gray(*obj, sep=sep_): return NCS(obj,Back.Gray,Style.NoBackground,sep) @staticmethod - def DarkGray(*obj, sep=sep_): return NCS(obj,DarkGray,resetCode,sep) + def DarkGray(*obj, sep=sep_): return NCS(obj,Back.DarkGray,Style.NoBackground,sep) @staticmethod - def Silver(*obj, sep=sep_): return NCS(obj,Silver,resetCode,sep) + def Silver(*obj, sep=sep_): return NCS(obj,Back.Silver,Style.NoBackground,sep) @staticmethod - def LightGray(*obj, sep=sep_): return NCS(obj,LightGray,resetCode,sep) + def LightGray(*obj, sep=sep_): return NCS(obj,Back.LightGray,Style.NoBackground,sep) @staticmethod - def Gainsboro(*obj, sep=sep_): return NCS(obj,Gainsboro,resetCode,sep) + def Gainsboro(*obj, sep=sep_): return NCS(obj,Back.Gainsboro,Style.NoBackground,sep) @staticmethod - def WhiteSmoke(*obj, sep=sep_): return NCS(obj,WhiteSmoke,resetCode,sep) + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,Back.WhiteSmoke,Style.NoBackground,sep) @staticmethod - def White(*obj, sep=sep_): return NCS(obj,White,resetCode,sep) \ No newline at end of file + def White(*obj, sep=sep_): return NCS(obj,Back.White,Style.NoBackground,sep) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py index a2ae26f..3eaca0a 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py @@ -10,6 +10,8 @@ from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence from AthenaColor.Functions.General import StrictType +from AthenaColor.Objects.Console.Styling.Inline.Bodies import Fore +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -22,150 +24,8 @@ # - Code - # ---------------------------------------------------------------------------------------------------------------------- NCS = NestedColorSequence # Done for slight speed increase -resetCode=39 sep_=" " -# Predefined Strings to speed calls up -Maroon =f"38;2;128;0;0" -DarkRed =f"38;2;139;0;0" -Brown =f"38;2;165;42;42" -Firebrick =f"38;2;178;34;34" -Crimson =f"38;2;220;20;60" -Red =f"38;2;255;0;0" -Tomato =f"38;2;255;99;71" -Coral =f"38;2;255;127;80" -IndianRed =f"38;2;205;92;92" -LightCoral =f"38;2;240;128;128" -DarkSalmon =f"38;2;233;150;122" -Salmon =f"38;2;250;128;114" -LightSalmon =f"38;2;255;160;122" -OrangeRed =f"38;2;255;69;0" -DarkOrange =f"38;2;255;140;0" -Orange =f"38;2;255;165;0" -Gold =f"38;2;255;215;0" -DarkGoldenRod =f"38;2;184;134;11" -GoldenRod =f"38;2;218;165;32" -PaleGoldenRod =f"38;2;238;232;170" -DarkKhaki =f"38;2;189;183;107" -Khaki =f"38;2;240;230;140" -Olive =f"38;2;128;128;0" -Yellow =f"38;2;255;255;0" -YellowGreen =f"38;2;154;205;50" -DarkOliveGreen =f"38;2;85;107;47" -OliveDrab =f"38;2;107;142;35" -LawnGreen =f"38;2;124;252;0" -Chartreuse =f"38;2;127;255;0" -GreenYellow =f"38;2;173;255;47" -DarkGreen =f"38;2;0;100;0" -Green =f"38;2;0;128;0" -ForestGreen =f"38;2;34;139;34" -Lime =f"38;2;0;255;0" -LimeGreen =f"38;2;50;205;50" -LightGreen =f"38;2;144;238;144" -PaleGreen =f"38;2;152;251;152" -DarkSeaGreen =f"38;2;143;188;143" -MediumSpringGreen =f"38;2;0;250;154" -SpringGreen =f"38;2;0;255;127" -SeaGreen =f"38;2;46;139;87" -MediumAquaMarine =f"38;2;102;205;170" -MediumSeaGreen =f"38;2;60;179;113" -LightSeaGreen =f"38;2;32;178;170" -DarkSlateGray =f"38;2;47;79 ;79" -Teal =f"38;2;0;128;128" -DarkCyan =f"38;2;0;139;139" -Aqua =f"38;2;0;255;255" -Cyan =f"38;2;0;255;255" -LightCyan =f"38;2;224;255;255" -DarkTurquoise =f"38;2;0;206;209" -Turquoise =f"38;2;64;224;208" -MediumTurquoise =f"38;2;72;209;204" -PaleTurquoise =f"38;2;175;238;238" -AquaMarine =f"38;2;127;255;212" -PowderBlue =f"38;2;176;224;230" -CadetBlue =f"38;2;95;158;160" -SteelBlue =f"38;2;70;130;180" -CornFlowerBlue =f"38;2;100;149;237" -DeepSkyBlue =f"38;2;0;191;255" -DodgerBlue =f"38;2;30;144;255" -LightBlue =f"38;2;173;216;230" -SkyBlue =f"38;2;135;206;235" -LightSkyBlue =f"38;2;135;206;250" -MidnightBlue =f"38;2;25;25;112" -Navy =f"38;2;0;0;128" -DarkBlue =f"38;2;0;0;139" -MediumBlue =f"38;2;0;0;205" -Blue =f"38;2;0;0;255" -RoyalBlue =f"38;2;65;105;225" -BlueViolet =f"38;2;138;43;226" -Indigo =f"38;2;75;0;130" -DarkSlateBlue =f"38;2;72;61;139" -SlateBlue =f"38;2;106;90;205" -MediumSlateBlue =f"38;2;123;104;238" -MediumPurple =f"38;2;147;112;219" -DarkMagenta =f"38;2;139;0;139" -DarkViolet =f"38;2;148;0;211" -DarkOrchid =f"38;2;153;50;204" -MediumOrchid =f"38;2;186;85;211" -Purple =f"38;2;128;0;128" -Thistle =f"38;2;216;191;216" -Plum =f"38;2;221;160;221" -Violet =f"38;2;238;130;238" -Magenta =f"38;2;255;0;255" -Orchid =f"38;2;218;112;214" -MediumVioletRed =f"38;2;199;21;133" -PaleVioletRed =f"38;2;219;112;147" -DeepPink =f"38;2;255;20;147" -HotPink =f"38;2;255;105;180" -LightPink =f"38;2;255;182;193" -Pink =f"38;2;255;192;203" -AntiqueWhite =f"38;2;250;235;215" -Beige =f"38;2;245;245;220" -Bisque =f"38;2;255;228;196" -BlanchedAlmond =f"38;2;255;235;205" -Wheat =f"38;2;245;222;179" -CornSilk =f"38;2;255;248;220" -LemonChiffon =f"38;2;255;250;205" -LightGoldenRodYellow =f"38;2;250;250;210" -LightYellow =f"38;2;255;255;224" -SaddleBrown =f"38;2;139;69;19" -Sienna =f"38;2;160;82;45" -Chocolate =f"38;2;210;105;30" -Peru =f"38;2;205;133;63" -SandyBrown =f"38;2;244;164;96" -BurlyWood =f"38;2;222;184;135" -Tan =f"38;2;210;180;140" -RosyBrown =f"38;2;188;143;143" -Moccasin =f"38;2;255;228;181" -NavajoWhite =f"38;2;255;222;173" -PeachPuff =f"38;2;255;218;185" -MistyRose =f"38;2;255;228;225" -LavenderBlush =f"38;2;255;240;245" -Linen =f"38;2;250;240;230" -OldLace =f"38;2;253;245;230" -PapayaWhip =f"38;2;255;239;213" -WeaShell =f"38;2;255;245;238" -MintCream =f"38;2;245;255;250" -SlateGray =f"38;2;112;128;144" -LightSlateGray =f"38;2;119;136;153" -LightSteelBlue =f"38;2;176;196;222" -Lavender =f"38;2;230;230;250" -FloralWhite =f"38;2;255;250;240" -AliceBlue =f"38;2;240;248;255" -GhostWhite =f"38;2;248;248;255" -Honeydew =f"38;2;240;255;240" -Ivory =f"38;2;255;255;240" -Azure =f"38;2;240;255;255" -Snow =f"38;2;255;250;250" -Black =f"38;2;0;0;0" -DimGray =f"38;2;105;105;105" -Gray =f"38;2;128;128;128" -DarkGray =f"38;2;169;169;169" -Silver =f"38;2;192;192;192" -LightGray =f"38;2;211;211;211" -Gainsboro =f"38;2;220;220;220" -WhiteSmoke =f"38;2;245;245;245" -White =f"38;2;255;255;255" - class ForeNest: # ------------------------------------------------------------------------------------------------------------------ # - Methods - @@ -175,9 +35,9 @@ def custom(*obj, color:RGB|HEX, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' color = StrictType(color,(RGB,HEX)) return NestedColorSequence( - *obj, - control_code=f"38;2;{color.r};{color.g};{color.b}", - reset_code=resetCode, + obj, + f"\033[38;2;{color.r};{color.g};{color.b}m", + Style.NoForeground, **kwargs ) @@ -186,9 +46,9 @@ def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' r,g,b = NormalizeRgb(r, g, b) return NestedColorSequence( - *obj, - control_code=f"38;2;{r};{g};{b}", - reset_code=resetCode, + obj, + f"\033[38;2;{r};{g};{b}m", + Style.NoForeground, **kwargs ) @@ -197,280 +57,280 @@ def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: # ------------------------------------------------------------------------------------------------------------------ # No partial methods, as this was increase the speed impact 2-fold @staticmethod - def Maroon(*obj, sep=sep_): return NCS(obj,Maroon,resetCode,sep) + def Maroon(*obj, sep=sep_): return NCS(obj,Fore.Maroon,Style.NoForeground,sep) @staticmethod - def DarkRed(*obj, sep=sep_): return NCS(obj,DarkRed,resetCode,sep) + def DarkRed(*obj, sep=sep_): return NCS(obj,Fore.DarkRed,Style.NoForeground,sep) @staticmethod - def Brown(*obj, sep=sep_): return NCS(obj,Brown,resetCode,sep) + def Brown(*obj, sep=sep_): return NCS(obj,Fore.Brown,Style.NoForeground,sep) @staticmethod - def Firebrick(*obj, sep=sep_): return NCS(obj,Firebrick,resetCode,sep) + def Firebrick(*obj, sep=sep_): return NCS(obj,Fore.Firebrick,Style.NoForeground,sep) @staticmethod - def Crimson(*obj, sep=sep_): return NCS(obj,Crimson,resetCode,sep) + def Crimson(*obj, sep=sep_): return NCS(obj,Fore.Crimson,Style.NoForeground,sep) @staticmethod - def Red(*obj, sep=sep_): return NCS(obj,Red,resetCode,sep) + def Red(*obj, sep=sep_): return NCS(obj,Fore.Red,Style.NoForeground,sep) @staticmethod - def Tomato(*obj, sep=sep_): return NCS(obj,Tomato,resetCode,sep) + def Tomato(*obj, sep=sep_): return NCS(obj,Fore.Tomato,Style.NoForeground,sep) @staticmethod - def Coral(*obj, sep=sep_): return NCS(obj,Coral,resetCode,sep) + def Coral(*obj, sep=sep_): return NCS(obj,Fore.Coral,Style.NoForeground,sep) @staticmethod - def IndianRed(*obj, sep=sep_): return NCS(obj,IndianRed,resetCode,sep) + def IndianRed(*obj, sep=sep_): return NCS(obj,Fore.IndianRed,Style.NoForeground,sep) @staticmethod - def LightCoral(*obj, sep=sep_): return NCS(obj,LightCoral,resetCode,sep) + def LightCoral(*obj, sep=sep_): return NCS(obj,Fore.LightCoral,Style.NoForeground,sep) @staticmethod - def DarkSalmon(*obj, sep=sep_): return NCS(obj,DarkSalmon,resetCode,sep) + def DarkSalmon(*obj, sep=sep_): return NCS(obj,Fore.DarkSalmon,Style.NoForeground,sep) @staticmethod - def Salmon(*obj, sep=sep_): return NCS(obj,Salmon,resetCode,sep) + def Salmon(*obj, sep=sep_): return NCS(obj,Fore.Salmon,Style.NoForeground,sep) @staticmethod - def LightSalmon(*obj, sep=sep_): return NCS(obj,LightSalmon,resetCode,sep) + def LightSalmon(*obj, sep=sep_): return NCS(obj,Fore.LightSalmon,Style.NoForeground,sep) @staticmethod - def OrangeRed(*obj, sep=sep_): return NCS(obj,OrangeRed,resetCode,sep) + def OrangeRed(*obj, sep=sep_): return NCS(obj,Fore.OrangeRed,Style.NoForeground,sep) @staticmethod - def DarkOrange(*obj, sep=sep_): return NCS(obj,DarkOrange,resetCode,sep) + def DarkOrange(*obj, sep=sep_): return NCS(obj,Fore.DarkOrange,Style.NoForeground,sep) @staticmethod - def Orange(*obj, sep=sep_): return NCS(obj,Orange,resetCode,sep) + def Orange(*obj, sep=sep_): return NCS(obj,Fore.Orange,Style.NoForeground,sep) @staticmethod - def Gold(*obj, sep=sep_): return NCS(obj,Gold,resetCode,sep) + def Gold(*obj, sep=sep_): return NCS(obj,Fore.Gold,Style.NoForeground,sep) @staticmethod - def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,DarkGoldenRod,resetCode,sep) + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,Fore.DarkGoldenRod,Style.NoForeground,sep) @staticmethod - def GoldenRod(*obj, sep=sep_): return NCS(obj,GoldenRod,resetCode,sep) + def GoldenRod(*obj, sep=sep_): return NCS(obj,Fore.GoldenRod,Style.NoForeground,sep) @staticmethod - def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,PaleGoldenRod,resetCode,sep) + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,Fore.PaleGoldenRod,Style.NoForeground,sep) @staticmethod - def DarkKhaki(*obj, sep=sep_): return NCS(obj,DarkKhaki,resetCode,sep) + def DarkKhaki(*obj, sep=sep_): return NCS(obj,Fore.DarkKhaki,Style.NoForeground,sep) @staticmethod - def Khaki(*obj, sep=sep_): return NCS(obj,Khaki,resetCode,sep) + def Khaki(*obj, sep=sep_): return NCS(obj,Fore.Khaki,Style.NoForeground,sep) @staticmethod - def Olive(*obj, sep=sep_): return NCS(obj,Olive,resetCode,sep) + def Olive(*obj, sep=sep_): return NCS(obj,Fore.Olive,Style.NoForeground,sep) @staticmethod - def Yellow(*obj, sep=sep_): return NCS(obj,Yellow,resetCode,sep) + def Yellow(*obj, sep=sep_): return NCS(obj,Fore.Yellow,Style.NoForeground,sep) @staticmethod - def YellowGreen(*obj, sep=sep_): return NCS(obj,YellowGreen,resetCode,sep) + def YellowGreen(*obj, sep=sep_): return NCS(obj,Fore.YellowGreen,Style.NoForeground,sep) @staticmethod - def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,DarkOliveGreen,resetCode,sep) + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,Fore.DarkOliveGreen,Style.NoForeground,sep) @staticmethod - def OliveDrab(*obj, sep=sep_): return NCS(obj,OliveDrab,resetCode,sep) + def OliveDrab(*obj, sep=sep_): return NCS(obj,Fore.OliveDrab,Style.NoForeground,sep) @staticmethod - def LawnGreen(*obj, sep=sep_): return NCS(obj,LawnGreen,resetCode,sep) + def LawnGreen(*obj, sep=sep_): return NCS(obj,Fore.LawnGreen,Style.NoForeground,sep) @staticmethod - def Chartreuse(*obj, sep=sep_): return NCS(obj,Chartreuse,resetCode,sep) + def Chartreuse(*obj, sep=sep_): return NCS(obj,Fore.Chartreuse,Style.NoForeground,sep) @staticmethod - def GreenYellow(*obj, sep=sep_): return NCS(obj,GreenYellow,resetCode,sep) + def GreenYellow(*obj, sep=sep_): return NCS(obj,Fore.GreenYellow,Style.NoForeground,sep) @staticmethod - def DarkGreen(*obj, sep=sep_): return NCS(obj,DarkGreen,resetCode,sep) + def DarkGreen(*obj, sep=sep_): return NCS(obj,Fore.DarkGreen,Style.NoForeground,sep) @staticmethod - def Green(*obj, sep=sep_): return NCS(obj,Green,resetCode,sep) + def Green(*obj, sep=sep_): return NCS(obj,Fore.Green,Style.NoForeground,sep) @staticmethod - def ForestGreen(*obj, sep=sep_): return NCS(obj,ForestGreen,resetCode,sep) + def ForestGreen(*obj, sep=sep_): return NCS(obj,Fore.ForestGreen,Style.NoForeground,sep) @staticmethod - def Lime(*obj, sep=sep_): return NCS(obj,Lime,resetCode,sep) + def Lime(*obj, sep=sep_): return NCS(obj,Fore.Lime,Style.NoForeground,sep) @staticmethod - def LimeGreen(*obj, sep=sep_): return NCS(obj,LimeGreen,resetCode,sep) + def LimeGreen(*obj, sep=sep_): return NCS(obj,Fore.LimeGreen,Style.NoForeground,sep) @staticmethod - def LightGreen(*obj, sep=sep_): return NCS(obj,LightGreen,resetCode,sep) + def LightGreen(*obj, sep=sep_): return NCS(obj,Fore.LightGreen,Style.NoForeground,sep) @staticmethod - def PaleGreen(*obj, sep=sep_): return NCS(obj,PaleGreen,resetCode,sep) + def PaleGreen(*obj, sep=sep_): return NCS(obj,Fore.PaleGreen,Style.NoForeground,sep) @staticmethod - def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,DarkSeaGreen,resetCode,sep) + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,Fore.DarkSeaGreen,Style.NoForeground,sep) @staticmethod - def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,MediumSpringGreen,resetCode,sep) + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,Fore.MediumSpringGreen,Style.NoForeground,sep) @staticmethod - def SpringGreen(*obj, sep=sep_): return NCS(obj,SpringGreen,resetCode,sep) + def SpringGreen(*obj, sep=sep_): return NCS(obj,Fore.SpringGreen,Style.NoForeground,sep) @staticmethod - def SeaGreen(*obj, sep=sep_): return NCS(obj,SeaGreen,resetCode,sep) + def SeaGreen(*obj, sep=sep_): return NCS(obj,Fore.SeaGreen,Style.NoForeground,sep) @staticmethod - def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,MediumAquaMarine,resetCode,sep) + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,Fore.MediumAquaMarine,Style.NoForeground,sep) @staticmethod - def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,MediumSeaGreen,resetCode,sep) + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,Fore.MediumSeaGreen,Style.NoForeground,sep) @staticmethod - def LightSeaGreen(*obj, sep=sep_): return NCS(obj,LightSeaGreen,resetCode,sep) + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,Fore.LightSeaGreen,Style.NoForeground,sep) @staticmethod - def DarkSlateGray(*obj, sep=sep_): return NCS(obj,DarkSlateGray,resetCode,sep) + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,Fore.DarkSlateGray,Style.NoForeground,sep) @staticmethod - def Teal(*obj, sep=sep_): return NCS(obj,Teal,resetCode,sep) + def Teal(*obj, sep=sep_): return NCS(obj,Fore.Teal,Style.NoForeground,sep) @staticmethod - def DarkCyan(*obj, sep=sep_): return NCS(obj,DarkCyan,resetCode,sep) + def DarkCyan(*obj, sep=sep_): return NCS(obj,Fore.DarkCyan,Style.NoForeground,sep) @staticmethod - def Aqua(*obj, sep=sep_): return NCS(obj,Aqua,resetCode,sep) + def Aqua(*obj, sep=sep_): return NCS(obj,Fore.Aqua,Style.NoForeground,sep) @staticmethod - def Cyan(*obj, sep=sep_): return NCS(obj,Cyan,resetCode,sep) + def Cyan(*obj, sep=sep_): return NCS(obj,Fore.Cyan,Style.NoForeground,sep) @staticmethod - def LightCyan(*obj, sep=sep_): return NCS(obj,LightCyan,resetCode,sep) + def LightCyan(*obj, sep=sep_): return NCS(obj,Fore.LightCyan,Style.NoForeground,sep) @staticmethod - def DarkTurquoise(*obj, sep=sep_): return NCS(obj,DarkTurquoise,resetCode,sep) + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,Fore.DarkTurquoise,Style.NoForeground,sep) @staticmethod - def Turquoise(*obj, sep=sep_): return NCS(obj,Turquoise,resetCode,sep) + def Turquoise(*obj, sep=sep_): return NCS(obj,Fore.Turquoise,Style.NoForeground,sep) @staticmethod - def MediumTurquoise(*obj, sep=sep_): return NCS(obj,MediumTurquoise,resetCode,sep) + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,Fore.MediumTurquoise,Style.NoForeground,sep) @staticmethod - def PaleTurquoise(*obj, sep=sep_): return NCS(obj,PaleTurquoise,resetCode,sep) + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,Fore.PaleTurquoise,Style.NoForeground,sep) @staticmethod - def AquaMarine(*obj, sep=sep_): return NCS(obj,AquaMarine,resetCode,sep) + def AquaMarine(*obj, sep=sep_): return NCS(obj,Fore.AquaMarine,Style.NoForeground,sep) @staticmethod - def PowderBlue(*obj, sep=sep_): return NCS(obj,PowderBlue,resetCode,sep) + def PowderBlue(*obj, sep=sep_): return NCS(obj,Fore.PowderBlue,Style.NoForeground,sep) @staticmethod - def CadetBlue(*obj, sep=sep_): return NCS(obj,CadetBlue,resetCode,sep) + def CadetBlue(*obj, sep=sep_): return NCS(obj,Fore.CadetBlue,Style.NoForeground,sep) @staticmethod - def SteelBlue(*obj, sep=sep_): return NCS(obj,SteelBlue,resetCode,sep) + def SteelBlue(*obj, sep=sep_): return NCS(obj,Fore.SteelBlue,Style.NoForeground,sep) @staticmethod - def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,CornFlowerBlue,resetCode,sep) + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,Fore.CornFlowerBlue,Style.NoForeground,sep) @staticmethod - def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,DeepSkyBlue,resetCode,sep) + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,Fore.DeepSkyBlue,Style.NoForeground,sep) @staticmethod - def DodgerBlue(*obj, sep=sep_): return NCS(obj,DodgerBlue,resetCode,sep) + def DodgerBlue(*obj, sep=sep_): return NCS(obj,Fore.DodgerBlue,Style.NoForeground,sep) @staticmethod - def LightBlue(*obj, sep=sep_): return NCS(obj,LightBlue,resetCode,sep) + def LightBlue(*obj, sep=sep_): return NCS(obj,Fore.LightBlue,Style.NoForeground,sep) @staticmethod - def SkyBlue(*obj, sep=sep_): return NCS(obj,SkyBlue,resetCode,sep) + def SkyBlue(*obj, sep=sep_): return NCS(obj,Fore.SkyBlue,Style.NoForeground,sep) @staticmethod - def LightSkyBlue(*obj, sep=sep_): return NCS(obj,LightSkyBlue,resetCode,sep) + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,Fore.LightSkyBlue,Style.NoForeground,sep) @staticmethod - def MidnightBlue(*obj, sep=sep_): return NCS(obj,MidnightBlue,resetCode,sep) + def MidnightBlue(*obj, sep=sep_): return NCS(obj,Fore.MidnightBlue,Style.NoForeground,sep) @staticmethod - def Navy(*obj, sep=sep_): return NCS(obj,Navy,resetCode,sep) + def Navy(*obj, sep=sep_): return NCS(obj,Fore.Navy,Style.NoForeground,sep) @staticmethod - def DarkBlue(*obj, sep=sep_): return NCS(obj,DarkBlue,resetCode,sep) + def DarkBlue(*obj, sep=sep_): return NCS(obj,Fore.DarkBlue,Style.NoForeground,sep) @staticmethod - def MediumBlue(*obj, sep=sep_): return NCS(obj,MediumBlue,resetCode,sep) + def MediumBlue(*obj, sep=sep_): return NCS(obj,Fore.MediumBlue,Style.NoForeground,sep) @staticmethod - def Blue(*obj, sep=sep_): return NCS(obj,Blue,resetCode,sep) + def Blue(*obj, sep=sep_): return NCS(obj,Fore.Blue,Style.NoForeground,sep) @staticmethod - def RoyalBlue(*obj, sep=sep_): return NCS(obj,RoyalBlue,resetCode,sep) + def RoyalBlue(*obj, sep=sep_): return NCS(obj,Fore.RoyalBlue,Style.NoForeground,sep) @staticmethod - def BlueViolet(*obj, sep=sep_): return NCS(obj,BlueViolet,resetCode,sep) + def BlueViolet(*obj, sep=sep_): return NCS(obj,Fore.BlueViolet,Style.NoForeground,sep) @staticmethod - def Indigo(*obj, sep=sep_): return NCS(obj,Indigo,resetCode,sep) + def Indigo(*obj, sep=sep_): return NCS(obj,Fore.Indigo,Style.NoForeground,sep) @staticmethod - def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,DarkSlateBlue,resetCode,sep) + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,Fore.DarkSlateBlue,Style.NoForeground,sep) @staticmethod - def SlateBlue(*obj, sep=sep_): return NCS(obj,SlateBlue,resetCode,sep) + def SlateBlue(*obj, sep=sep_): return NCS(obj,Fore.SlateBlue,Style.NoForeground,sep) @staticmethod - def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,MediumSlateBlue,resetCode,sep) + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,Fore.MediumSlateBlue,Style.NoForeground,sep) @staticmethod - def MediumPurple(*obj, sep=sep_): return NCS(obj,MediumPurple,resetCode,sep) + def MediumPurple(*obj, sep=sep_): return NCS(obj,Fore.MediumPurple,Style.NoForeground,sep) @staticmethod - def DarkMagenta(*obj, sep=sep_): return NCS(obj,DarkMagenta,resetCode,sep) + def DarkMagenta(*obj, sep=sep_): return NCS(obj,Fore.DarkMagenta,Style.NoForeground,sep) @staticmethod - def DarkViolet(*obj, sep=sep_): return NCS(obj,DarkViolet,resetCode,sep) + def DarkViolet(*obj, sep=sep_): return NCS(obj,Fore.DarkViolet,Style.NoForeground,sep) @staticmethod - def DarkOrchid(*obj, sep=sep_): return NCS(obj,DarkOrchid,resetCode,sep) + def DarkOrchid(*obj, sep=sep_): return NCS(obj,Fore.DarkOrchid,Style.NoForeground,sep) @staticmethod - def MediumOrchid(*obj, sep=sep_): return NCS(obj,MediumOrchid,resetCode,sep) + def MediumOrchid(*obj, sep=sep_): return NCS(obj,Fore.MediumOrchid,Style.NoForeground,sep) @staticmethod - def Purple(*obj, sep=sep_): return NCS(obj,Purple,resetCode,sep) + def Purple(*obj, sep=sep_): return NCS(obj,Fore.Purple,Style.NoForeground,sep) @staticmethod - def Thistle(*obj, sep=sep_): return NCS(obj,Thistle,resetCode,sep) + def Thistle(*obj, sep=sep_): return NCS(obj,Fore.Thistle,Style.NoForeground,sep) @staticmethod - def Plum(*obj, sep=sep_): return NCS(obj,Plum,resetCode,sep) + def Plum(*obj, sep=sep_): return NCS(obj,Fore.Plum,Style.NoForeground,sep) @staticmethod - def Violet(*obj, sep=sep_): return NCS(obj,Violet,resetCode,sep) + def Violet(*obj, sep=sep_): return NCS(obj,Fore.Violet,Style.NoForeground,sep) @staticmethod - def Magenta(*obj, sep=sep_): return NCS(obj,Magenta,resetCode,sep) + def Magenta(*obj, sep=sep_): return NCS(obj,Fore.Magenta,Style.NoForeground,sep) @staticmethod - def Orchid(*obj, sep=sep_): return NCS(obj,Orchid,resetCode,sep) + def Orchid(*obj, sep=sep_): return NCS(obj,Fore.Orchid,Style.NoForeground,sep) @staticmethod - def MediumVioletRed(*obj, sep=sep_): return NCS(obj,MediumVioletRed,resetCode,sep) + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,Fore.MediumVioletRed,Style.NoForeground,sep) @staticmethod - def PaleVioletRed(*obj, sep=sep_): return NCS(obj,PaleVioletRed,resetCode,sep) + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,Fore.PaleVioletRed,Style.NoForeground,sep) @staticmethod - def DeepPink(*obj, sep=sep_): return NCS(obj,DeepPink,resetCode,sep) + def DeepPink(*obj, sep=sep_): return NCS(obj,Fore.DeepPink,Style.NoForeground,sep) @staticmethod - def HotPink(*obj, sep=sep_): return NCS(obj,HotPink,resetCode,sep) + def HotPink(*obj, sep=sep_): return NCS(obj,Fore.HotPink,Style.NoForeground,sep) @staticmethod - def LightPink(*obj, sep=sep_): return NCS(obj,LightPink,resetCode,sep) + def LightPink(*obj, sep=sep_): return NCS(obj,Fore.LightPink,Style.NoForeground,sep) @staticmethod - def Pink(*obj, sep=sep_): return NCS(obj,Pink,resetCode,sep) + def Pink(*obj, sep=sep_): return NCS(obj,Fore.Pink,Style.NoForeground,sep) @staticmethod - def AntiqueWhite(*obj, sep=sep_): return NCS(obj,AntiqueWhite,resetCode,sep) + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,Fore.AntiqueWhite,Style.NoForeground,sep) @staticmethod - def Beige(*obj, sep=sep_): return NCS(obj,Beige,resetCode,sep) + def Beige(*obj, sep=sep_): return NCS(obj,Fore.Beige,Style.NoForeground,sep) @staticmethod - def Bisque(*obj, sep=sep_): return NCS(obj,Bisque,resetCode,sep) + def Bisque(*obj, sep=sep_): return NCS(obj,Fore.Bisque,Style.NoForeground,sep) @staticmethod - def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,BlanchedAlmond,resetCode,sep) + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,Fore.BlanchedAlmond,Style.NoForeground,sep) @staticmethod - def Wheat(*obj, sep=sep_): return NCS(obj,Wheat,resetCode,sep) + def Wheat(*obj, sep=sep_): return NCS(obj,Fore.Wheat,Style.NoForeground,sep) @staticmethod - def CornSilk(*obj, sep=sep_): return NCS(obj,CornSilk,resetCode,sep) + def CornSilk(*obj, sep=sep_): return NCS(obj,Fore.CornSilk,Style.NoForeground,sep) @staticmethod - def LemonChiffon(*obj, sep=sep_): return NCS(obj,LemonChiffon,resetCode,sep) + def LemonChiffon(*obj, sep=sep_): return NCS(obj,Fore.LemonChiffon,Style.NoForeground,sep) @staticmethod - def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,LightGoldenRodYellow,resetCode,sep) + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,Fore.LightGoldenRodYellow,Style.NoForeground,sep) @staticmethod - def LightYellow(*obj, sep=sep_): return NCS(obj,LightYellow,resetCode,sep) + def LightYellow(*obj, sep=sep_): return NCS(obj,Fore.LightYellow,Style.NoForeground,sep) @staticmethod - def SaddleBrown(*obj, sep=sep_): return NCS(obj,SaddleBrown,resetCode,sep) + def SaddleBrown(*obj, sep=sep_): return NCS(obj,Fore.SaddleBrown,Style.NoForeground,sep) @staticmethod - def Sienna(*obj, sep=sep_): return NCS(obj,Sienna,resetCode,sep) + def Sienna(*obj, sep=sep_): return NCS(obj,Fore.Sienna,Style.NoForeground,sep) @staticmethod - def Chocolate(*obj, sep=sep_): return NCS(obj,Chocolate,resetCode,sep) + def Chocolate(*obj, sep=sep_): return NCS(obj,Fore.Chocolate,Style.NoForeground,sep) @staticmethod - def Peru(*obj, sep=sep_): return NCS(obj,Peru,resetCode,sep) + def Peru(*obj, sep=sep_): return NCS(obj,Fore.Peru,Style.NoForeground,sep) @staticmethod - def SandyBrown(*obj, sep=sep_): return NCS(obj,SandyBrown,resetCode,sep) + def SandyBrown(*obj, sep=sep_): return NCS(obj,Fore.SandyBrown,Style.NoForeground,sep) @staticmethod - def BurlyWood(*obj, sep=sep_): return NCS(obj,BurlyWood,resetCode,sep) + def BurlyWood(*obj, sep=sep_): return NCS(obj,Fore.BurlyWood,Style.NoForeground,sep) @staticmethod - def Tan(*obj, sep=sep_): return NCS(obj,Tan,resetCode,sep) + def Tan(*obj, sep=sep_): return NCS(obj,Fore.Tan,Style.NoForeground,sep) @staticmethod - def RosyBrown(*obj, sep=sep_): return NCS(obj,RosyBrown,resetCode,sep) + def RosyBrown(*obj, sep=sep_): return NCS(obj,Fore.RosyBrown,Style.NoForeground,sep) @staticmethod - def Moccasin(*obj, sep=sep_): return NCS(obj,Moccasin,resetCode,sep) + def Moccasin(*obj, sep=sep_): return NCS(obj,Fore.Moccasin,Style.NoForeground,sep) @staticmethod - def NavajoWhite(*obj, sep=sep_): return NCS(obj,NavajoWhite,resetCode,sep) + def NavajoWhite(*obj, sep=sep_): return NCS(obj,Fore.NavajoWhite,Style.NoForeground,sep) @staticmethod - def PeachPuff(*obj, sep=sep_): return NCS(obj,PeachPuff,resetCode,sep) + def PeachPuff(*obj, sep=sep_): return NCS(obj,Fore.PeachPuff,Style.NoForeground,sep) @staticmethod - def MistyRose(*obj, sep=sep_): return NCS(obj,MistyRose,resetCode,sep) + def MistyRose(*obj, sep=sep_): return NCS(obj,Fore.MistyRose,Style.NoForeground,sep) @staticmethod - def LavenderBlush(*obj, sep=sep_): return NCS(obj,LavenderBlush,resetCode,sep) + def LavenderBlush(*obj, sep=sep_): return NCS(obj,Fore.LavenderBlush,Style.NoForeground,sep) @staticmethod - def Linen(*obj, sep=sep_): return NCS(obj,Linen,resetCode,sep) + def Linen(*obj, sep=sep_): return NCS(obj,Fore.Linen,Style.NoForeground,sep) @staticmethod - def OldLace(*obj, sep=sep_): return NCS(obj,OldLace,resetCode,sep) + def OldLace(*obj, sep=sep_): return NCS(obj,Fore.OldLace,Style.NoForeground,sep) @staticmethod - def PapayaWhip(*obj, sep=sep_): return NCS(obj,PapayaWhip,resetCode,sep) + def PapayaWhip(*obj, sep=sep_): return NCS(obj,Fore.PapayaWhip,Style.NoForeground,sep) @staticmethod - def WeaShell(*obj, sep=sep_): return NCS(obj,WeaShell,resetCode,sep) + def WeaShell(*obj, sep=sep_): return NCS(obj,Fore.WeaShell,Style.NoForeground,sep) @staticmethod - def MintCream(*obj, sep=sep_): return NCS(obj,MintCream,resetCode,sep) + def MintCream(*obj, sep=sep_): return NCS(obj,Fore.MintCream,Style.NoForeground,sep) @staticmethod - def SlateGray(*obj, sep=sep_): return NCS(obj,SlateGray,resetCode,sep) + def SlateGray(*obj, sep=sep_): return NCS(obj,Fore.SlateGray,Style.NoForeground,sep) @staticmethod - def LightSlateGray(*obj, sep=sep_): return NCS(obj,LightSlateGray,resetCode,sep) + def LightSlateGray(*obj, sep=sep_): return NCS(obj,Fore.LightSlateGray,Style.NoForeground,sep) @staticmethod - def LightSteelBlue(*obj, sep=sep_): return NCS(obj,LightSteelBlue,resetCode,sep) + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,Fore.LightSteelBlue,Style.NoForeground,sep) @staticmethod - def Lavender(*obj, sep=sep_): return NCS(obj,Lavender,resetCode,sep) + def Lavender(*obj, sep=sep_): return NCS(obj,Fore.Lavender,Style.NoForeground,sep) @staticmethod - def FloralWhite(*obj, sep=sep_): return NCS(obj,FloralWhite,resetCode,sep) + def FloralWhite(*obj, sep=sep_): return NCS(obj,Fore.FloralWhite,Style.NoForeground,sep) @staticmethod - def AliceBlue(*obj, sep=sep_): return NCS(obj,AliceBlue,resetCode,sep) + def AliceBlue(*obj, sep=sep_): return NCS(obj,Fore.AliceBlue,Style.NoForeground,sep) @staticmethod - def GhostWhite(*obj, sep=sep_): return NCS(obj,GhostWhite,resetCode,sep) + def GhostWhite(*obj, sep=sep_): return NCS(obj,Fore.GhostWhite,Style.NoForeground,sep) @staticmethod - def Honeydew(*obj, sep=sep_): return NCS(obj,Honeydew,resetCode,sep) + def Honeydew(*obj, sep=sep_): return NCS(obj,Fore.Honeydew,Style.NoForeground,sep) @staticmethod - def Ivory(*obj, sep=sep_): return NCS(obj,Ivory,resetCode,sep) + def Ivory(*obj, sep=sep_): return NCS(obj,Fore.Ivory,Style.NoForeground,sep) @staticmethod - def Azure(*obj, sep=sep_): return NCS(obj,Azure,resetCode,sep) + def Azure(*obj, sep=sep_): return NCS(obj,Fore.Azure,Style.NoForeground,sep) @staticmethod - def Snow(*obj, sep=sep_): return NCS(obj,Snow,resetCode,sep) + def Snow(*obj, sep=sep_): return NCS(obj,Fore.Snow,Style.NoForeground,sep) @staticmethod - def Black(*obj, sep=sep_): return NCS(obj,Black,resetCode,sep) + def Black(*obj, sep=sep_): return NCS(obj,Fore.Black,Style.NoForeground,sep) @staticmethod - def DimGray(*obj, sep=sep_): return NCS(obj,DimGray,resetCode,sep) + def DimGray(*obj, sep=sep_): return NCS(obj,Fore.DimGray,Style.NoForeground,sep) @staticmethod - def Gray(*obj, sep=sep_): return NCS(obj,Gray,resetCode,sep) + def Gray(*obj, sep=sep_): return NCS(obj,Fore.Gray,Style.NoForeground,sep) @staticmethod - def DarkGray(*obj, sep=sep_): return NCS(obj,DarkGray,resetCode,sep) + def DarkGray(*obj, sep=sep_): return NCS(obj,Fore.DarkGray,Style.NoForeground,sep) @staticmethod - def Silver(*obj, sep=sep_): return NCS(obj,Silver,resetCode,sep) + def Silver(*obj, sep=sep_): return NCS(obj,Fore.Silver,Style.NoForeground,sep) @staticmethod - def LightGray(*obj, sep=sep_): return NCS(obj,LightGray,resetCode,sep) + def LightGray(*obj, sep=sep_): return NCS(obj,Fore.LightGray,Style.NoForeground,sep) @staticmethod - def Gainsboro(*obj, sep=sep_): return NCS(obj,Gainsboro,resetCode,sep) + def Gainsboro(*obj, sep=sep_): return NCS(obj,Fore.Gainsboro,Style.NoForeground,sep) @staticmethod - def WhiteSmoke(*obj, sep=sep_): return NCS(obj,WhiteSmoke,resetCode,sep) + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,Fore.WhiteSmoke,Style.NoForeground,sep) @staticmethod - def White(*obj, sep=sep_): return NCS(obj,White,resetCode,sep) \ No newline at end of file + def White(*obj, sep=sep_): return NCS(obj,Fore.White,Style.NoForeground,sep) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py index cf417b3..c09b338 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py @@ -7,6 +7,7 @@ # Custom Packages from AthenaColor.Functions.ANSIsquences import NestedColorSequence,NestedColorSequence_NoReset +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style, Basic # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -24,111 +25,111 @@ class StyleNest: @staticmethod - def Reset(*obj,sep=sep_): return NCSNO(obj,0,sep) + def Reset(*obj,sep=sep_): return NCSNO(obj,Style.Reset,sep) @staticmethod - def Bold(*obj,sep=sep_): return NCS(obj,1,22,sep) + def Bold(*obj,sep=sep_): return NCS(obj,Style.Bold,Style.NoBold,sep) @staticmethod - def NoBold(*obj,sep=sep_): return NCSNO(obj,22,sep) + def NoBold(*obj,sep=sep_): return NCSNO(obj,Style.NoBold,sep) @staticmethod - def Dim(*obj,sep=sep_): return NCS(obj,2,22,sep) + def Dim(*obj,sep=sep_): return NCS(obj,Style.Dim,Style.NoBold,sep) @staticmethod - def NoDim(*obj,sep=sep_): return NCSNO(obj,22,sep) + def NoDim(*obj,sep=sep_): return NCSNO(obj,Style.NoBold,sep) @staticmethod - def Italic(*obj,sep=sep_): return NCS(obj,3,23,sep) + def Italic(*obj,sep=sep_): return NCS(obj,Style.Italic,Style.NoItalic,sep) @staticmethod - def NoItalic(*obj,sep=sep_): return NCSNO(obj,23,sep) + def NoItalic(*obj,sep=sep_): return NCSNO(obj,Style.NoItalic,sep) @staticmethod - def Underline(*obj,sep=sep_): return NCS(obj,4,24,sep) + def Underline(*obj,sep=sep_): return NCS(obj,Style.Underline,Style.NoUnderline,sep) @staticmethod - def NoUnderline(*obj,sep=sep_): return NCSNO(obj,24,sep) + def NoUnderline(*obj,sep=sep_): return NCSNO(obj,Style.NoUnderline,sep) @staticmethod - def BlinkSlow(*obj,sep=sep_): return NCS(obj,5,25,sep) + def BlinkSlow(*obj,sep=sep_): return NCS(obj,Style.BlinkSlow,Style.NoBlinkSlow,sep) @staticmethod - def NoBlinkSlow(*obj,sep=sep_): return NCSNO(obj,25,sep) + def NoBlinkSlow(*obj,sep=sep_): return NCSNO(obj,Style.NoBlinkSlow,sep) @staticmethod - def BlinkRapid(*obj,sep=sep_): return NCS(obj,6,25,sep) + def BlinkRapid(*obj,sep=sep_): return NCS(obj,Style.BlinkRapid,Style.NoBlinkRapid,sep) @staticmethod - def NoBlinkRapid(*obj,sep=sep_): return NCSNO(obj,25,sep) + def NoBlinkRapid(*obj,sep=sep_): return NCSNO(obj,Style.NoBlinkRapid,sep) @staticmethod - def Reversed(*obj,sep=sep_): return NCS(obj,7,27,sep) + def Reversed(*obj,sep=sep_): return NCS(obj,Style.Reversed,Style.NoReversed,sep) @staticmethod - def NoReversed(*obj,sep=sep_): return NCSNO(obj,27,sep) + def NoReversed(*obj,sep=sep_): return NCSNO(obj,Style.NoReversed,sep) @staticmethod - def Conceal(*obj,sep=sep_): return NCS(obj,8,28,sep) + def Conceal(*obj,sep=sep_): return NCS(obj,Style.Conceal,Style.NoConceal,sep) @staticmethod - def NoConceal(*obj,sep=sep_): return NCSNO(obj,28,sep) + def NoConceal(*obj,sep=sep_): return NCSNO(obj,Style.NoConceal,sep) @staticmethod - def Crossed(*obj,sep=sep_): return NCS(obj,9,29,sep) + def Crossed(*obj,sep=sep_): return NCS(obj,Style.Crossed,Style.NoCrossed,sep) @staticmethod - def NoCrossed(*obj,sep=sep_): return NCSNO(obj,29,sep) + def NoCrossed(*obj,sep=sep_): return NCSNO(obj,Style.NoCrossed,sep) @staticmethod - def FontPrimary(*obj,sep=sep_): return NCS(obj,10,10,sep) + def FontPrimary(*obj,sep=sep_): return NCS(obj,Style.NoFont,Style.NoFont,sep) @staticmethod - def FontSecond1(*obj,sep=sep_): return NCS(obj,11,10,sep) + def FontSecond1(*obj,sep=sep_): return NCS(obj,Style.FontSecond1,Style.NoFont,sep) @staticmethod - def FontSecond2(*obj,sep=sep_): return NCS(obj,12,10,sep) + def FontSecond2(*obj,sep=sep_): return NCS(obj,Style.FontSecond2,Style.NoFont,sep) @staticmethod - def FontSecond3(*obj,sep=sep_): return NCS(obj,13,10,sep) + def FontSecond3(*obj,sep=sep_): return NCS(obj,Style.FontSecond3,Style.NoFont,sep) @staticmethod - def FontSecond4(*obj,sep=sep_): return NCS(obj,14,10,sep) + def FontSecond4(*obj,sep=sep_): return NCS(obj,Style.FontSecond4,Style.NoFont,sep) @staticmethod - def FontSecond5(*obj,sep=sep_): return NCS(obj,15,10,sep) + def FontSecond5(*obj,sep=sep_): return NCS(obj,Style.FontSecond5,Style.NoFont,sep) @staticmethod - def FontSecond6(*obj,sep=sep_): return NCS(obj,16,10,sep) + def FontSecond6(*obj,sep=sep_): return NCS(obj,Style.FontSecond6,Style.NoFont,sep) @staticmethod - def FontSecond8(*obj,sep=sep_): return NCS(obj,17,10,sep) + def FontSecond8(*obj,sep=sep_): return NCS(obj,Style.FontSecond8,Style.NoFont,sep) @staticmethod - def FontSecond9(*obj,sep=sep_): return NCS(obj,18,10,sep) + def FontSecond9(*obj,sep=sep_): return NCS(obj,Style.FontSecond9,Style.NoFont,sep) @staticmethod - def FontSecond10(*obj,sep=sep_): return NCS(obj,19,10,sep) + def FontSecond10(*obj,sep=sep_): return NCS(obj,Style.FontSecond10,Style.NoFont,sep) @staticmethod - def NoFont(*obj,sep=sep_): return NCSNO(obj,10,sep) + def NoFont(*obj,sep=sep_): return NCSNO(obj,Style.NoFont,sep) @staticmethod - def Fraktur(*obj,sep=sep_): return NCSNO(obj,20,sep) + def Fraktur(*obj,sep=sep_): return NCSNO(obj,Style.Fraktur,sep) @staticmethod - def UnderlineDouble(*obj,sep=sep_): return NCS(obj,21,24,sep) + def UnderlineDouble(*obj,sep=sep_): return NCS(obj,Style.UnderlineDouble,Style.NoUnderline,sep) @staticmethod - def NoUnderlineDouble(*obj,sep=sep_): return NCSNO(obj,24,sep) + def NoUnderlineDouble(*obj,sep=sep_): return NCSNO(obj,Style.NoUnderline,sep) @staticmethod - def PropSpacing(*obj,sep=sep_): return NCS(obj,26,26,sep) + def PropSpacing(*obj,sep=sep_): return NCS(obj,Style.PropSpacing,Style.NoPropSpacing,sep) @staticmethod - def NoPropSpacing(*obj,sep=sep_): return NCSNO(obj,26,sep) + def NoPropSpacing(*obj,sep=sep_): return NCSNO(obj,Style.NoPropSpacing,sep) @staticmethod - def NoForeground(*obj,sep=sep_): return NCSNO(obj,39,sep) + def NoForeground(*obj,sep=sep_): return NCSNO(obj,Style.NoForeground,sep) @staticmethod - def NoBackground(*obj,sep=sep_): return NCSNO(obj,49,sep) + def NoBackground(*obj,sep=sep_): return NCSNO(obj,Style.NoBackground,sep) @staticmethod - def Frame(*obj,sep=sep_): return NCS(obj,51,54,sep) + def Frame(*obj,sep=sep_): return NCS(obj,Style.Frame,Style.NoFrame,sep) @staticmethod - def NoFrame(*obj,sep=sep_): return NCSNO(obj,54,sep) + def NoFrame(*obj,sep=sep_): return NCSNO(obj,Style.NoFrame,sep) @staticmethod - def Circle(*obj,sep=sep_): return NCS(obj,52,54,sep) + def Circle(*obj,sep=sep_): return NCS(obj,Style.Circle,Style.NoFrame,sep) @staticmethod - def NoCircle(*obj,sep=sep_): return NCSNO(obj,54,sep) + def NoCircle(*obj,sep=sep_): return NCSNO(obj,Style.NoFrame,sep) @staticmethod - def OverLine(*obj,sep=sep_): return NCS(obj,53,55,sep) + def OverLine(*obj,sep=sep_): return NCS(obj,Style.OverLine,Style.NoOverLine,sep) @staticmethod - def NoOverLine(*obj,sep=sep_): return NCSNO(obj,55,sep) + def NoOverLine(*obj,sep=sep_): return NCSNO(obj,Style.NoOverLine,sep) @staticmethod - def UnderColourDefault(*obj,sep=sep_): return NCSNO(obj,59,sep) + def UnderColourDefault(*obj,sep=sep_): return NCSNO(obj,Style.UnderColourDefault,sep) @staticmethod - def IdeogramUnderLine(*obj,sep=sep_): return NCS(obj,60,65,sep) + def IdeogramUnderLine(*obj,sep=sep_): return NCS(obj,Style.IdeogramUnderLine,Style.NoIdeogram,sep) @staticmethod - def IdeogramUnderLineDouble(*obj,sep=sep_): return NCS(obj,61,65,sep) + def IdeogramUnderLineDouble(*obj,sep=sep_): return NCS(obj,Style.IdeogramUnderLineDouble,Style.NoIdeogram,sep) @staticmethod - def IdeogramOverLine(*obj,sep=sep_): return NCS(obj,62,65,sep) + def IdeogramOverLine(*obj,sep=sep_): return NCS(obj,Style.IdeogramOverLine,Style.NoIdeogram,sep) @staticmethod - def IdeogramOverLineDouble(*obj,sep=sep_): return NCS(obj,63,65,sep) + def IdeogramOverLineDouble(*obj,sep=sep_): return NCS(obj,Style.IdeogramOverLineDouble,Style.NoIdeogram,sep) @staticmethod - def IdeogramStress(*obj,sep=sep_): return NCS(obj,64,65,sep) + def IdeogramStress(*obj,sep=sep_): return NCS(obj,Style.IdeogramStress,Style.NoIdeogram,sep) @staticmethod - def NoIdeogram(*obj,sep=sep_): return NCSNO(obj,65,sep) + def NoIdeogram(*obj,sep=sep_): return NCSNO(obj,Style.NoIdeogram,sep) @staticmethod - def SuperScript(*obj,sep=sep_): return NCS(obj,73,75,sep) + def SuperScript(*obj,sep=sep_): return NCS(obj,Style.SuperScript,Style.NoScript,sep) @staticmethod - def SubScript(*obj,sep=sep_): return NCS(obj,74,75,sep) + def SubScript(*obj,sep=sep_): return NCS(obj,Style.SubScript,Style.NoScript,sep) @staticmethod - def NoScript(*obj,sep=sep_): return NCSNO(obj,75,sep) + def NoScript(*obj,sep=sep_): return NCSNO(obj,Style.NoScript,sep) # ---------------------------------------------------------------------------------------------------------------------- # - BasicNest Sequences - @@ -136,68 +137,68 @@ def NoScript(*obj,sep=sep_): return NCSNO(obj,75,sep) class BasicNest: class Fore: @staticmethod - def Black(*obj,sep=sep_): return NCS(obj, 30, 39,sep) + def Black(*obj,sep=sep_): return NCS(obj, Basic.Fore.Black, Style.NoForeground,sep) @staticmethod - def Red(*obj,sep=sep_): return NCS(obj, 31, 39,sep) + def Red(*obj,sep=sep_): return NCS(obj, Basic.Fore.Red, Style.NoForeground,sep) @staticmethod - def Green(*obj,sep=sep_): return NCS(obj, 32, 39,sep) + def Green(*obj,sep=sep_): return NCS(obj, Basic.Fore.Green, Style.NoForeground,sep) @staticmethod - def Yellow(*obj,sep=sep_): return NCS(obj, 33, 39,sep) + def Yellow(*obj,sep=sep_): return NCS(obj, Basic.Fore.Yellow, Style.NoForeground,sep) @staticmethod - def Blue(*obj,sep=sep_): return NCS(obj, 34, 39,sep) + def Blue(*obj,sep=sep_): return NCS(obj, Basic.Fore.Blue, Style.NoForeground,sep) @staticmethod - def Magenta(*obj,sep=sep_): return NCS(obj, 35, 39,sep) + def Magenta(*obj,sep=sep_): return NCS(obj, Basic.Fore.Magenta, Style.NoForeground,sep) @staticmethod - def Cyan(*obj,sep=sep_): return NCS(obj, 36, 39,sep) + def Cyan(*obj,sep=sep_): return NCS(obj, Basic.Fore.Cyan, Style.NoForeground,sep) @staticmethod - def White(*obj,sep=sep_): return NCS(obj, 37, 39,sep) + def White(*obj,sep=sep_): return NCS(obj, Basic.Fore.White, Style.NoForeground,sep) @staticmethod - def BrightBlack(*obj,sep=sep_): return NCS(obj, 90, 39,sep) + def BrightBlack(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightBlack, Style.NoForeground,sep) @staticmethod - def BrightRed(*obj,sep=sep_): return NCS(obj, 91, 39,sep) + def BrightRed(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightRed, Style.NoForeground,sep) @staticmethod - def BrightGreen(*obj,sep=sep_): return NCS(obj, 92, 39,sep) + def BrightGreen(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightGreen, Style.NoForeground,sep) @staticmethod - def BrightYellow(*obj,sep=sep_): return NCS(obj, 93, 39,sep) + def BrightYellow(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightYellow, Style.NoForeground,sep) @staticmethod - def BrightBlue(*obj,sep=sep_): return NCS(obj, 94, 39,sep) + def BrightBlue(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightBlue, Style.NoForeground,sep) @staticmethod - def BrightMagenta(*obj,sep=sep_): return NCS(obj, 95, 39,sep) + def BrightMagenta(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightMagenta, Style.NoForeground,sep) @staticmethod - def BrightCyan(*obj,sep=sep_): return NCS(obj, 96, 39,sep) + def BrightCyan(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightCyan, Style.NoForeground,sep) @staticmethod - def BrightWhite(*obj,sep=sep_): return NCS(obj, 97, 39,sep) + def BrightWhite(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightWhite, Style.NoForeground,sep) class Back: @staticmethod - def Black(*obj,sep=sep_): return NCS(obj, 40, 49,sep) + def Black(*obj,sep=sep_): return NCS(obj, Basic.Back.Black, Style.NoBackground,sep) @staticmethod - def Red(*obj,sep=sep_): return NCS(obj, 41, 49,sep) + def Red(*obj,sep=sep_): return NCS(obj, Basic.Back.Red, Style.NoBackground,sep) @staticmethod - def Green(*obj,sep=sep_): return NCS(obj, 42, 49,sep) + def Green(*obj,sep=sep_): return NCS(obj, Basic.Back.Green, Style.NoBackground,sep) @staticmethod - def Yellow(*obj,sep=sep_): return NCS(obj, 43, 49,sep) + def Yellow(*obj,sep=sep_): return NCS(obj, Basic.Back.Yellow, Style.NoBackground,sep) @staticmethod - def Blue(*obj,sep=sep_): return NCS(obj, 44, 49,sep) + def Blue(*obj,sep=sep_): return NCS(obj, Basic.Back.Blue, Style.NoBackground,sep) @staticmethod - def Magenta(*obj,sep=sep_): return NCS(obj, 45, 49,sep) + def Magenta(*obj,sep=sep_): return NCS(obj, Basic.Back.Magenta, Style.NoBackground,sep) @staticmethod - def Cyan(*obj,sep=sep_): return NCS(obj, 46, 49,sep) + def Cyan(*obj,sep=sep_): return NCS(obj, Basic.Back.Cyan, Style.NoBackground,sep) @staticmethod - def White(*obj,sep=sep_): return NCS(obj, 47, 49,sep) + def White(*obj,sep=sep_): return NCS(obj, Basic.Back.White, Style.NoBackground,sep) @staticmethod - def BrightBlack(*obj,sep=sep_): return NCS(obj, 100, 49,sep) + def BrightBlack(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightBlack, Style.NoBackground,sep) @staticmethod - def BrightRed(*obj,sep=sep_): return NCS(obj, 101, 49,sep) + def BrightRed(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightRed, Style.NoBackground,sep) @staticmethod - def BrightGreen(*obj,sep=sep_): return NCS(obj, 102, 49,sep) + def BrightGreen(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightGreen, Style.NoBackground,sep) @staticmethod - def BrightYellow(*obj,sep=sep_): return NCS(obj, 103, 49,sep) + def BrightYellow(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightYellow, Style.NoBackground,sep) @staticmethod - def BrightBlue(*obj,sep=sep_): return NCS(obj, 104, 49,sep) + def BrightBlue(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightBlue, Style.NoBackground,sep) @staticmethod - def BrightMagenta(*obj,sep=sep_): return NCS(obj, 105, 49,sep) + def BrightMagenta(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightMagenta, Style.NoBackground,sep) @staticmethod - def BrightCyan(*obj,sep=sep_): return NCS(obj, 106, 49,sep) + def BrightCyan(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightCyan, Style.NoBackground,sep) @staticmethod - def BrightWhite(*obj,sep=sep_): return NCS(obj, 107, 49,sep) \ No newline at end of file + def BrightWhite(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightWhite, Style.NoBackground,sep) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py index 941d92b..dbb2fb8 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py @@ -10,162 +10,23 @@ from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence from AthenaColor.Functions.General import StrictType +from AthenaColor.Objects.Console.Styling.Inline.Bodies import Underline +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style + # ---------------------------------------------------------------------------------------------------------------------- # - All - # ---------------------------------------------------------------------------------------------------------------------- __all__=[ - "ForeNest" + "UnderlineNest" ] # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- NCS = NestedColorSequence # Done for slight speed increase -resetCode=59 sep_=" " -# Predefined Strings to speed calls up -Maroon =f"58;2;128;0;0" -DarkRed =f"58;2;139;0;0" -Brown =f"58;2;165;42;42" -Firebrick =f"58;2;178;34;34" -Crimson =f"58;2;220;20;60" -Red =f"58;2;255;0;0" -Tomato =f"58;2;255;99;71" -Coral =f"58;2;255;127;80" -IndianRed =f"58;2;205;92;92" -LightCoral =f"58;2;240;128;128" -DarkSalmon =f"58;2;233;150;122" -Salmon =f"58;2;250;128;114" -LightSalmon =f"58;2;255;160;122" -OrangeRed =f"58;2;255;69;0" -DarkOrange =f"58;2;255;140;0" -Orange =f"58;2;255;165;0" -Gold =f"58;2;255;215;0" -DarkGoldenRod =f"58;2;184;134;11" -GoldenRod =f"58;2;218;165;32" -PaleGoldenRod =f"58;2;238;232;170" -DarkKhaki =f"58;2;189;183;107" -Khaki =f"58;2;240;230;140" -Olive =f"58;2;128;128;0" -Yellow =f"58;2;255;255;0" -YellowGreen =f"58;2;154;205;50" -DarkOliveGreen =f"58;2;85;107;47" -OliveDrab =f"58;2;107;142;35" -LawnGreen =f"58;2;124;252;0" -Chartreuse =f"58;2;127;255;0" -GreenYellow =f"58;2;173;255;47" -DarkGreen =f"58;2;0;100;0" -Green =f"58;2;0;128;0" -ForestGreen =f"58;2;34;139;34" -Lime =f"58;2;0;255;0" -LimeGreen =f"58;2;50;205;50" -LightGreen =f"58;2;144;238;144" -PaleGreen =f"58;2;152;251;152" -DarkSeaGreen =f"58;2;143;188;143" -MediumSpringGreen =f"58;2;0;250;154" -SpringGreen =f"58;2;0;255;127" -SeaGreen =f"58;2;46;139;87" -MediumAquaMarine =f"58;2;102;205;170" -MediumSeaGreen =f"58;2;60;179;113" -LightSeaGreen =f"58;2;32;178;170" -DarkSlateGray =f"58;2;47;79 ;79" -Teal =f"58;2;0;128;128" -DarkCyan =f"58;2;0;139;139" -Aqua =f"58;2;0;255;255" -Cyan =f"58;2;0;255;255" -LightCyan =f"58;2;224;255;255" -DarkTurquoise =f"58;2;0;206;209" -Turquoise =f"58;2;64;224;208" -MediumTurquoise =f"58;2;72;209;204" -PaleTurquoise =f"58;2;175;238;238" -AquaMarine =f"58;2;127;255;212" -PowderBlue =f"58;2;176;224;230" -CadetBlue =f"58;2;95;158;160" -SteelBlue =f"58;2;70;130;180" -CornFlowerBlue =f"58;2;100;149;237" -DeepSkyBlue =f"58;2;0;191;255" -DodgerBlue =f"58;2;30;144;255" -LightBlue =f"58;2;173;216;230" -SkyBlue =f"58;2;135;206;235" -LightSkyBlue =f"58;2;135;206;250" -MidnightBlue =f"58;2;25;25;112" -Navy =f"58;2;0;0;128" -DarkBlue =f"58;2;0;0;139" -MediumBlue =f"58;2;0;0;205" -Blue =f"58;2;0;0;255" -RoyalBlue =f"58;2;65;105;225" -BlueViolet =f"58;2;138;43;226" -Indigo =f"58;2;75;0;130" -DarkSlateBlue =f"58;2;72;61;139" -SlateBlue =f"58;2;106;90;205" -MediumSlateBlue =f"58;2;123;104;238" -MediumPurple =f"58;2;147;112;219" -DarkMagenta =f"58;2;139;0;139" -DarkViolet =f"58;2;148;0;211" -DarkOrchid =f"58;2;153;50;204" -MediumOrchid =f"58;2;186;85;211" -Purple =f"58;2;128;0;128" -Thistle =f"58;2;216;191;216" -Plum =f"58;2;221;160;221" -Violet =f"58;2;238;130;238" -Magenta =f"58;2;255;0;255" -Orchid =f"58;2;218;112;214" -MediumVioletRed =f"58;2;199;21;133" -PaleVioletRed =f"58;2;219;112;147" -DeepPink =f"58;2;255;20;147" -HotPink =f"58;2;255;105;180" -LightPink =f"58;2;255;182;193" -Pink =f"58;2;255;192;203" -AntiqueWhite =f"58;2;250;235;215" -Beige =f"58;2;245;245;220" -Bisque =f"58;2;255;228;196" -BlanchedAlmond =f"58;2;255;235;205" -Wheat =f"58;2;245;222;179" -CornSilk =f"58;2;255;248;220" -LemonChiffon =f"58;2;255;250;205" -LightGoldenRodYellow =f"58;2;250;250;210" -LightYellow =f"58;2;255;255;224" -SaddleBrown =f"58;2;139;69;19" -Sienna =f"58;2;160;82;45" -Chocolate =f"58;2;210;105;30" -Peru =f"58;2;205;133;63" -SandyBrown =f"58;2;244;164;96" -BurlyWood =f"58;2;222;184;135" -Tan =f"58;2;210;180;140" -RosyBrown =f"58;2;188;143;143" -Moccasin =f"58;2;255;228;181" -NavajoWhite =f"58;2;255;222;173" -PeachPuff =f"58;2;255;218;185" -MistyRose =f"58;2;255;228;225" -LavenderBlush =f"58;2;255;240;245" -Linen =f"58;2;250;240;230" -OldLace =f"58;2;253;245;230" -PapayaWhip =f"58;2;255;239;213" -WeaShell =f"58;2;255;245;238" -MintCream =f"58;2;245;255;250" -SlateGray =f"58;2;112;128;144" -LightSlateGray =f"58;2;119;136;153" -LightSteelBlue =f"58;2;176;196;222" -Lavender =f"58;2;230;230;250" -FloralWhite =f"58;2;255;250;240" -AliceBlue =f"58;2;240;248;255" -GhostWhite =f"58;2;248;248;255" -Honeydew =f"58;2;240;255;240" -Ivory =f"58;2;255;255;240" -Azure =f"58;2;240;255;255" -Snow =f"58;2;255;250;250" -Black =f"58;2;0;0;0" -DimGray =f"58;2;105;105;105" -Gray =f"58;2;128;128;128" -DarkGray =f"58;2;169;169;169" -Silver =f"58;2;192;192;192" -LightGray =f"58;2;211;211;211" -Gainsboro =f"58;2;220;220;220" -WhiteSmoke =f"58;2;245;245;245" -White =f"58;2;255;255;255" - class UnderlineNest: # ------------------------------------------------------------------------------------------------------------------ # - Methods - @@ -175,9 +36,9 @@ def custom(*obj, color:RGB|HEX, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' color = StrictType(color,(RGB,HEX)) return NestedColorSequence( - *obj, - control_code=f"58;2;{color.r};{color.g};{color.b}", - reset_code=resetCode, + obj, + f"\033[58;2;{color.r};{color.g};{color.b}m", + Style.NoUnderline, **kwargs ) @@ -186,9 +47,9 @@ def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' r,g,b = NormalizeRgb(r, g, b) return NestedColorSequence( - *obj, - control_code=f"58;2;{r};{g};{b}", - reset_code=resetCode, + obj, + f"\033[58;2;{r};{g};{b}m", + Style.NoUnderline, **kwargs ) @@ -197,280 +58,280 @@ def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: # ------------------------------------------------------------------------------------------------------------------ # No partial methods, as this was increase the speed impact 2-fold @staticmethod - def Maroon( *obj, sep=sep_): return NCS(obj,Maroon,resetCode,sep) + def Maroon( *obj, sep=sep_): return NCS(obj,Underline.Maroon,Style.NoUnderline,sep) @staticmethod - def DarkRed(*obj, sep=sep_): return NCS(obj,DarkRed,resetCode,sep) + def DarkRed(*obj, sep=sep_): return NCS(obj,Underline.DarkRed,Style.NoUnderline,sep) @staticmethod - def Brown(*obj, sep=sep_): return NCS(obj,Brown,resetCode,sep) + def Brown(*obj, sep=sep_): return NCS(obj,Underline.Brown,Style.NoUnderline,sep) @staticmethod - def Firebrick(*obj, sep=sep_): return NCS(obj,Firebrick,resetCode,sep) + def Firebrick(*obj, sep=sep_): return NCS(obj,Underline.Firebrick,Style.NoUnderline,sep) @staticmethod - def Crimson(*obj, sep=sep_): return NCS(obj,Crimson,resetCode,sep) + def Crimson(*obj, sep=sep_): return NCS(obj,Underline.Crimson,Style.NoUnderline,sep) @staticmethod - def Red(*obj, sep=sep_): return NCS(obj,Red,resetCode,sep) + def Red(*obj, sep=sep_): return NCS(obj,Underline.Red,Style.NoUnderline,sep) @staticmethod - def Tomato(*obj, sep=sep_): return NCS(obj,Tomato,resetCode,sep) + def Tomato(*obj, sep=sep_): return NCS(obj,Underline.Tomato,Style.NoUnderline,sep) @staticmethod - def Coral(*obj, sep=sep_): return NCS(obj,Coral,resetCode,sep) + def Coral(*obj, sep=sep_): return NCS(obj,Underline.Coral,Style.NoUnderline,sep) @staticmethod - def IndianRed(*obj, sep=sep_): return NCS(obj,IndianRed,resetCode,sep) + def IndianRed(*obj, sep=sep_): return NCS(obj,Underline.IndianRed,Style.NoUnderline,sep) @staticmethod - def LightCoral(*obj, sep=sep_): return NCS(obj,LightCoral,resetCode,sep) + def LightCoral(*obj, sep=sep_): return NCS(obj,Underline.LightCoral,Style.NoUnderline,sep) @staticmethod - def DarkSalmon(*obj, sep=sep_): return NCS(obj,DarkSalmon,resetCode,sep) + def DarkSalmon(*obj, sep=sep_): return NCS(obj,Underline.DarkSalmon,Style.NoUnderline,sep) @staticmethod - def Salmon(*obj, sep=sep_): return NCS(obj,Salmon,resetCode,sep) + def Salmon(*obj, sep=sep_): return NCS(obj,Underline.Salmon,Style.NoUnderline,sep) @staticmethod - def LightSalmon(*obj, sep=sep_): return NCS(obj,LightSalmon,resetCode,sep) + def LightSalmon(*obj, sep=sep_): return NCS(obj,Underline.LightSalmon,Style.NoUnderline,sep) @staticmethod - def OrangeRed(*obj, sep=sep_): return NCS(obj,OrangeRed,resetCode,sep) + def OrangeRed(*obj, sep=sep_): return NCS(obj,Underline.OrangeRed,Style.NoUnderline,sep) @staticmethod - def DarkOrange(*obj, sep=sep_): return NCS(obj,DarkOrange,resetCode,sep) + def DarkOrange(*obj, sep=sep_): return NCS(obj,Underline.DarkOrange,Style.NoUnderline,sep) @staticmethod - def Orange(*obj, sep=sep_): return NCS(obj,Orange,resetCode,sep) + def Orange(*obj, sep=sep_): return NCS(obj,Underline.Orange,Style.NoUnderline,sep) @staticmethod - def Gold(*obj, sep=sep_): return NCS(obj,Gold,resetCode,sep) + def Gold(*obj, sep=sep_): return NCS(obj,Underline.Gold,Style.NoUnderline,sep) @staticmethod - def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,DarkGoldenRod,resetCode,sep) + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,Underline.DarkGoldenRod,Style.NoUnderline,sep) @staticmethod - def GoldenRod(*obj, sep=sep_): return NCS(obj,GoldenRod,resetCode,sep) + def GoldenRod(*obj, sep=sep_): return NCS(obj,Underline.GoldenRod,Style.NoUnderline,sep) @staticmethod - def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,PaleGoldenRod,resetCode,sep) + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,Underline.PaleGoldenRod,Style.NoUnderline,sep) @staticmethod - def DarkKhaki(*obj, sep=sep_): return NCS(obj,DarkKhaki,resetCode,sep) + def DarkKhaki(*obj, sep=sep_): return NCS(obj,Underline.DarkKhaki,Style.NoUnderline,sep) @staticmethod - def Khaki(*obj, sep=sep_): return NCS(obj,Khaki,resetCode,sep) + def Khaki(*obj, sep=sep_): return NCS(obj,Underline.Khaki,Style.NoUnderline,sep) @staticmethod - def Olive(*obj, sep=sep_): return NCS(obj,Olive,resetCode,sep) + def Olive(*obj, sep=sep_): return NCS(obj,Underline.Olive,Style.NoUnderline,sep) @staticmethod - def Yellow(*obj, sep=sep_): return NCS(obj,Yellow,resetCode,sep) + def Yellow(*obj, sep=sep_): return NCS(obj,Underline.Yellow,Style.NoUnderline,sep) @staticmethod - def YellowGreen(*obj, sep=sep_): return NCS(obj,YellowGreen,resetCode,sep) + def YellowGreen(*obj, sep=sep_): return NCS(obj,Underline.YellowGreen,Style.NoUnderline,sep) @staticmethod - def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,DarkOliveGreen,resetCode,sep) + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,Underline.DarkOliveGreen,Style.NoUnderline,sep) @staticmethod - def OliveDrab(*obj, sep=sep_): return NCS(obj,OliveDrab,resetCode,sep) + def OliveDrab(*obj, sep=sep_): return NCS(obj,Underline.OliveDrab,Style.NoUnderline,sep) @staticmethod - def LawnGreen(*obj, sep=sep_): return NCS(obj,LawnGreen,resetCode,sep) + def LawnGreen(*obj, sep=sep_): return NCS(obj,Underline.LawnGreen,Style.NoUnderline,sep) @staticmethod - def Chartreuse(*obj, sep=sep_): return NCS(obj,Chartreuse,resetCode,sep) + def Chartreuse(*obj, sep=sep_): return NCS(obj,Underline.Chartreuse,Style.NoUnderline,sep) @staticmethod - def GreenYellow(*obj, sep=sep_): return NCS(obj,GreenYellow,resetCode,sep) + def GreenYellow(*obj, sep=sep_): return NCS(obj,Underline.GreenYellow,Style.NoUnderline,sep) @staticmethod - def DarkGreen(*obj, sep=sep_): return NCS(obj,DarkGreen,resetCode,sep) + def DarkGreen(*obj, sep=sep_): return NCS(obj,Underline.DarkGreen,Style.NoUnderline,sep) @staticmethod - def Green(*obj, sep=sep_): return NCS(obj,Green,resetCode,sep) + def Green(*obj, sep=sep_): return NCS(obj,Underline.Green,Style.NoUnderline,sep) @staticmethod - def ForestGreen(*obj, sep=sep_): return NCS(obj,ForestGreen,resetCode,sep) + def ForestGreen(*obj, sep=sep_): return NCS(obj,Underline.ForestGreen,Style.NoUnderline,sep) @staticmethod - def Lime(*obj, sep=sep_): return NCS(obj,Lime,resetCode,sep) + def Lime(*obj, sep=sep_): return NCS(obj,Underline.Lime,Style.NoUnderline,sep) @staticmethod - def LimeGreen(*obj, sep=sep_): return NCS(obj,LimeGreen,resetCode,sep) + def LimeGreen(*obj, sep=sep_): return NCS(obj,Underline.LimeGreen,Style.NoUnderline,sep) @staticmethod - def LightGreen(*obj, sep=sep_): return NCS(obj,LightGreen,resetCode,sep) + def LightGreen(*obj, sep=sep_): return NCS(obj,Underline.LightGreen,Style.NoUnderline,sep) @staticmethod - def PaleGreen(*obj, sep=sep_): return NCS(obj,PaleGreen,resetCode,sep) + def PaleGreen(*obj, sep=sep_): return NCS(obj,Underline.PaleGreen,Style.NoUnderline,sep) @staticmethod - def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,DarkSeaGreen,resetCode,sep) + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,Underline.DarkSeaGreen,Style.NoUnderline,sep) @staticmethod - def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,MediumSpringGreen,resetCode,sep) + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,Underline.MediumSpringGreen,Style.NoUnderline,sep) @staticmethod - def SpringGreen(*obj, sep=sep_): return NCS(obj,SpringGreen,resetCode,sep) + def SpringGreen(*obj, sep=sep_): return NCS(obj,Underline.SpringGreen,Style.NoUnderline,sep) @staticmethod - def SeaGreen(*obj, sep=sep_): return NCS(obj,SeaGreen,resetCode,sep) + def SeaGreen(*obj, sep=sep_): return NCS(obj,Underline.SeaGreen,Style.NoUnderline,sep) @staticmethod - def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,MediumAquaMarine,resetCode,sep) + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,Underline.MediumAquaMarine,Style.NoUnderline,sep) @staticmethod - def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,MediumSeaGreen,resetCode,sep) + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,Underline.MediumSeaGreen,Style.NoUnderline,sep) @staticmethod - def LightSeaGreen(*obj, sep=sep_): return NCS(obj,LightSeaGreen,resetCode,sep) + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,Underline.LightSeaGreen,Style.NoUnderline,sep) @staticmethod - def DarkSlateGray(*obj, sep=sep_): return NCS(obj,DarkSlateGray,resetCode,sep) + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,Underline.DarkSlateGray,Style.NoUnderline,sep) @staticmethod - def Teal(*obj, sep=sep_): return NCS(obj,Teal,resetCode,sep) + def Teal(*obj, sep=sep_): return NCS(obj,Underline.Teal,Style.NoUnderline,sep) @staticmethod - def DarkCyan(*obj, sep=sep_): return NCS(obj,DarkCyan,resetCode,sep) + def DarkCyan(*obj, sep=sep_): return NCS(obj,Underline.DarkCyan,Style.NoUnderline,sep) @staticmethod - def Aqua(*obj, sep=sep_): return NCS(obj,Aqua,resetCode,sep) + def Aqua(*obj, sep=sep_): return NCS(obj,Underline.Aqua,Style.NoUnderline,sep) @staticmethod - def Cyan(*obj, sep=sep_): return NCS(obj,Cyan,resetCode,sep) + def Cyan(*obj, sep=sep_): return NCS(obj,Underline.Cyan,Style.NoUnderline,sep) @staticmethod - def LightCyan(*obj, sep=sep_): return NCS(obj,LightCyan,resetCode,sep) + def LightCyan(*obj, sep=sep_): return NCS(obj,Underline.LightCyan,Style.NoUnderline,sep) @staticmethod - def DarkTurquoise(*obj, sep=sep_): return NCS(obj,DarkTurquoise,resetCode,sep) + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,Underline.DarkTurquoise,Style.NoUnderline,sep) @staticmethod - def Turquoise(*obj, sep=sep_): return NCS(obj,Turquoise,resetCode,sep) + def Turquoise(*obj, sep=sep_): return NCS(obj,Underline.Turquoise,Style.NoUnderline,sep) @staticmethod - def MediumTurquoise(*obj, sep=sep_): return NCS(obj,MediumTurquoise,resetCode,sep) + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,Underline.MediumTurquoise,Style.NoUnderline,sep) @staticmethod - def PaleTurquoise(*obj, sep=sep_): return NCS(obj,PaleTurquoise,resetCode,sep) + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,Underline.PaleTurquoise,Style.NoUnderline,sep) @staticmethod - def AquaMarine(*obj, sep=sep_): return NCS(obj,AquaMarine,resetCode,sep) + def AquaMarine(*obj, sep=sep_): return NCS(obj,Underline.AquaMarine,Style.NoUnderline,sep) @staticmethod - def PowderBlue(*obj, sep=sep_): return NCS(obj,PowderBlue,resetCode,sep) + def PowderBlue(*obj, sep=sep_): return NCS(obj,Underline.PowderBlue,Style.NoUnderline,sep) @staticmethod - def CadetBlue(*obj, sep=sep_): return NCS(obj,CadetBlue,resetCode,sep) + def CadetBlue(*obj, sep=sep_): return NCS(obj,Underline.CadetBlue,Style.NoUnderline,sep) @staticmethod - def SteelBlue(*obj, sep=sep_): return NCS(obj,SteelBlue,resetCode,sep) + def SteelBlue(*obj, sep=sep_): return NCS(obj,Underline.SteelBlue,Style.NoUnderline,sep) @staticmethod - def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,CornFlowerBlue,resetCode,sep) + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,Underline.CornFlowerBlue,Style.NoUnderline,sep) @staticmethod - def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,DeepSkyBlue,resetCode,sep) + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,Underline.DeepSkyBlue,Style.NoUnderline,sep) @staticmethod - def DodgerBlue(*obj, sep=sep_): return NCS(obj,DodgerBlue,resetCode,sep) + def DodgerBlue(*obj, sep=sep_): return NCS(obj,Underline.DodgerBlue,Style.NoUnderline,sep) @staticmethod - def LightBlue(*obj, sep=sep_): return NCS(obj,LightBlue,resetCode,sep) + def LightBlue(*obj, sep=sep_): return NCS(obj,Underline.LightBlue,Style.NoUnderline,sep) @staticmethod - def SkyBlue(*obj, sep=sep_): return NCS(obj,SkyBlue,resetCode,sep) + def SkyBlue(*obj, sep=sep_): return NCS(obj,Underline.SkyBlue,Style.NoUnderline,sep) @staticmethod - def LightSkyBlue(*obj, sep=sep_): return NCS(obj,LightSkyBlue,resetCode,sep) + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,Underline.LightSkyBlue,Style.NoUnderline,sep) @staticmethod - def MidnightBlue(*obj, sep=sep_): return NCS(obj,MidnightBlue,resetCode,sep) + def MidnightBlue(*obj, sep=sep_): return NCS(obj,Underline.MidnightBlue,Style.NoUnderline,sep) @staticmethod - def Navy(*obj, sep=sep_): return NCS(obj,Navy,resetCode,sep) + def Navy(*obj, sep=sep_): return NCS(obj,Underline.Navy,Style.NoUnderline,sep) @staticmethod - def DarkBlue(*obj, sep=sep_): return NCS(obj,DarkBlue,resetCode,sep) + def DarkBlue(*obj, sep=sep_): return NCS(obj,Underline.DarkBlue,Style.NoUnderline,sep) @staticmethod - def MediumBlue(*obj, sep=sep_): return NCS(obj,MediumBlue,resetCode,sep) + def MediumBlue(*obj, sep=sep_): return NCS(obj,Underline.MediumBlue,Style.NoUnderline,sep) @staticmethod - def Blue(*obj, sep=sep_): return NCS(obj,Blue,resetCode,sep) + def Blue(*obj, sep=sep_): return NCS(obj,Underline.Blue,Style.NoUnderline,sep) @staticmethod - def RoyalBlue(*obj, sep=sep_): return NCS(obj,RoyalBlue,resetCode,sep) + def RoyalBlue(*obj, sep=sep_): return NCS(obj,Underline.RoyalBlue,Style.NoUnderline,sep) @staticmethod - def BlueViolet(*obj, sep=sep_): return NCS(obj,BlueViolet,resetCode,sep) + def BlueViolet(*obj, sep=sep_): return NCS(obj,Underline.BlueViolet,Style.NoUnderline,sep) @staticmethod - def Indigo(*obj, sep=sep_): return NCS(obj,Indigo,resetCode,sep) + def Indigo(*obj, sep=sep_): return NCS(obj,Underline.Indigo,Style.NoUnderline,sep) @staticmethod - def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,DarkSlateBlue,resetCode,sep) + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,Underline.DarkSlateBlue,Style.NoUnderline,sep) @staticmethod - def SlateBlue(*obj, sep=sep_): return NCS(obj,SlateBlue,resetCode,sep) + def SlateBlue(*obj, sep=sep_): return NCS(obj,Underline.SlateBlue,Style.NoUnderline,sep) @staticmethod - def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,MediumSlateBlue,resetCode,sep) + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,Underline.MediumSlateBlue,Style.NoUnderline,sep) @staticmethod - def MediumPurple(*obj, sep=sep_): return NCS(obj,MediumPurple,resetCode,sep) + def MediumPurple(*obj, sep=sep_): return NCS(obj,Underline.MediumPurple,Style.NoUnderline,sep) @staticmethod - def DarkMagenta(*obj, sep=sep_): return NCS(obj,DarkMagenta,resetCode,sep) + def DarkMagenta(*obj, sep=sep_): return NCS(obj,Underline.DarkMagenta,Style.NoUnderline,sep) @staticmethod - def DarkViolet(*obj, sep=sep_): return NCS(obj,DarkViolet,resetCode,sep) + def DarkViolet(*obj, sep=sep_): return NCS(obj,Underline.DarkViolet,Style.NoUnderline,sep) @staticmethod - def DarkOrchid(*obj, sep=sep_): return NCS(obj,DarkOrchid,resetCode,sep) + def DarkOrchid(*obj, sep=sep_): return NCS(obj,Underline.DarkOrchid,Style.NoUnderline,sep) @staticmethod - def MediumOrchid(*obj, sep=sep_): return NCS(obj,MediumOrchid,resetCode,sep) + def MediumOrchid(*obj, sep=sep_): return NCS(obj,Underline.MediumOrchid,Style.NoUnderline,sep) @staticmethod - def Purple(*obj, sep=sep_): return NCS(obj,Purple,resetCode,sep) + def Purple(*obj, sep=sep_): return NCS(obj,Underline.Purple,Style.NoUnderline,sep) @staticmethod - def Thistle(*obj, sep=sep_): return NCS(obj,Thistle,resetCode,sep) + def Thistle(*obj, sep=sep_): return NCS(obj,Underline.Thistle,Style.NoUnderline,sep) @staticmethod - def Plum(*obj, sep=sep_): return NCS(obj,Plum,resetCode,sep) + def Plum(*obj, sep=sep_): return NCS(obj,Underline.Plum,Style.NoUnderline,sep) @staticmethod - def Violet(*obj, sep=sep_): return NCS(obj,Violet,resetCode,sep) + def Violet(*obj, sep=sep_): return NCS(obj,Underline.Violet,Style.NoUnderline,sep) @staticmethod - def Magenta(*obj, sep=sep_): return NCS(obj,Magenta,resetCode,sep) + def Magenta(*obj, sep=sep_): return NCS(obj,Underline.Magenta,Style.NoUnderline,sep) @staticmethod - def Orchid(*obj, sep=sep_): return NCS(obj,Orchid,resetCode,sep) + def Orchid(*obj, sep=sep_): return NCS(obj,Underline.Orchid,Style.NoUnderline,sep) @staticmethod - def MediumVioletRed(*obj, sep=sep_): return NCS(obj,MediumVioletRed,resetCode,sep) + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,Underline.MediumVioletRed,Style.NoUnderline,sep) @staticmethod - def PaleVioletRed(*obj, sep=sep_): return NCS(obj,PaleVioletRed,resetCode,sep) + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,Underline.PaleVioletRed,Style.NoUnderline,sep) @staticmethod - def DeepPink(*obj, sep=sep_): return NCS(obj,DeepPink,resetCode,sep) + def DeepPink(*obj, sep=sep_): return NCS(obj,Underline.DeepPink,Style.NoUnderline,sep) @staticmethod - def HotPink(*obj, sep=sep_): return NCS(obj,HotPink,resetCode,sep) + def HotPink(*obj, sep=sep_): return NCS(obj,Underline.HotPink,Style.NoUnderline,sep) @staticmethod - def LightPink(*obj, sep=sep_): return NCS(obj,LightPink,resetCode,sep) + def LightPink(*obj, sep=sep_): return NCS(obj,Underline.LightPink,Style.NoUnderline,sep) @staticmethod - def Pink(*obj, sep=sep_): return NCS(obj,Pink,resetCode,sep) + def Pink(*obj, sep=sep_): return NCS(obj,Underline.Pink,Style.NoUnderline,sep) @staticmethod - def AntiqueWhite(*obj, sep=sep_): return NCS(obj,AntiqueWhite,resetCode,sep) + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,Underline.AntiqueWhite,Style.NoUnderline,sep) @staticmethod - def Beige(*obj, sep=sep_): return NCS(obj,Beige,resetCode,sep) + def Beige(*obj, sep=sep_): return NCS(obj,Underline.Beige,Style.NoUnderline,sep) @staticmethod - def Bisque(*obj, sep=sep_): return NCS(obj,Bisque,resetCode,sep) + def Bisque(*obj, sep=sep_): return NCS(obj,Underline.Bisque,Style.NoUnderline,sep) @staticmethod - def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,BlanchedAlmond,resetCode,sep) + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,Underline.BlanchedAlmond,Style.NoUnderline,sep) @staticmethod - def Wheat(*obj, sep=sep_): return NCS(obj,Wheat,resetCode,sep) + def Wheat(*obj, sep=sep_): return NCS(obj,Underline.Wheat,Style.NoUnderline,sep) @staticmethod - def CornSilk(*obj, sep=sep_): return NCS(obj,CornSilk,resetCode,sep) + def CornSilk(*obj, sep=sep_): return NCS(obj,Underline.CornSilk,Style.NoUnderline,sep) @staticmethod - def LemonChiffon(*obj, sep=sep_): return NCS(obj,LemonChiffon,resetCode,sep) + def LemonChiffon(*obj, sep=sep_): return NCS(obj,Underline.LemonChiffon,Style.NoUnderline,sep) @staticmethod - def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,LightGoldenRodYellow,resetCode,sep) + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,Underline.LightGoldenRodYellow,Style.NoUnderline,sep) @staticmethod - def LightYellow(*obj, sep=sep_): return NCS(obj,LightYellow,resetCode,sep) + def LightYellow(*obj, sep=sep_): return NCS(obj,Underline.LightYellow,Style.NoUnderline,sep) @staticmethod - def SaddleBrown(*obj, sep=sep_): return NCS(obj,SaddleBrown,resetCode,sep) + def SaddleBrown(*obj, sep=sep_): return NCS(obj,Underline.SaddleBrown,Style.NoUnderline,sep) @staticmethod - def Sienna(*obj, sep=sep_): return NCS(obj,Sienna,resetCode,sep) + def Sienna(*obj, sep=sep_): return NCS(obj,Underline.Sienna,Style.NoUnderline,sep) @staticmethod - def Chocolate(*obj, sep=sep_): return NCS(obj,Chocolate,resetCode,sep) + def Chocolate(*obj, sep=sep_): return NCS(obj,Underline.Chocolate,Style.NoUnderline,sep) @staticmethod - def Peru(*obj, sep=sep_): return NCS(obj,Peru,resetCode,sep) + def Peru(*obj, sep=sep_): return NCS(obj,Underline.Peru,Style.NoUnderline,sep) @staticmethod - def SandyBrown(*obj, sep=sep_): return NCS(obj,SandyBrown,resetCode,sep) + def SandyBrown(*obj, sep=sep_): return NCS(obj,Underline.SandyBrown,Style.NoUnderline,sep) @staticmethod - def BurlyWood(*obj, sep=sep_): return NCS(obj,BurlyWood,resetCode,sep) + def BurlyWood(*obj, sep=sep_): return NCS(obj,Underline.BurlyWood,Style.NoUnderline,sep) @staticmethod - def Tan(*obj, sep=sep_): return NCS(obj,Tan,resetCode,sep) + def Tan(*obj, sep=sep_): return NCS(obj,Underline.Tan,Style.NoUnderline,sep) @staticmethod - def RosyBrown(*obj, sep=sep_): return NCS(obj,RosyBrown,resetCode,sep) + def RosyBrown(*obj, sep=sep_): return NCS(obj,Underline.RosyBrown,Style.NoUnderline,sep) @staticmethod - def Moccasin(*obj, sep=sep_): return NCS(obj,Moccasin,resetCode,sep) + def Moccasin(*obj, sep=sep_): return NCS(obj,Underline.Moccasin,Style.NoUnderline,sep) @staticmethod - def NavajoWhite(*obj, sep=sep_): return NCS(obj,NavajoWhite,resetCode,sep) + def NavajoWhite(*obj, sep=sep_): return NCS(obj,Underline.NavajoWhite,Style.NoUnderline,sep) @staticmethod - def PeachPuff(*obj, sep=sep_): return NCS(obj,PeachPuff,resetCode,sep) + def PeachPuff(*obj, sep=sep_): return NCS(obj,Underline.PeachPuff,Style.NoUnderline,sep) @staticmethod - def MistyRose(*obj, sep=sep_): return NCS(obj,MistyRose,resetCode,sep) + def MistyRose(*obj, sep=sep_): return NCS(obj,Underline.MistyRose,Style.NoUnderline,sep) @staticmethod - def LavenderBlush(*obj, sep=sep_): return NCS(obj,LavenderBlush,resetCode,sep) + def LavenderBlush(*obj, sep=sep_): return NCS(obj,Underline.LavenderBlush,Style.NoUnderline,sep) @staticmethod - def Linen(*obj, sep=sep_): return NCS(obj,Linen,resetCode,sep) + def Linen(*obj, sep=sep_): return NCS(obj,Underline.Linen,Style.NoUnderline,sep) @staticmethod - def OldLace(*obj, sep=sep_): return NCS(obj,OldLace,resetCode,sep) + def OldLace(*obj, sep=sep_): return NCS(obj,Underline.OldLace,Style.NoUnderline,sep) @staticmethod - def PapayaWhip(*obj, sep=sep_): return NCS(obj,PapayaWhip,resetCode,sep) + def PapayaWhip(*obj, sep=sep_): return NCS(obj,Underline.PapayaWhip,Style.NoUnderline,sep) @staticmethod - def WeaShell(*obj, sep=sep_): return NCS(obj,WeaShell,resetCode,sep) + def WeaShell(*obj, sep=sep_): return NCS(obj,Underline.WeaShell,Style.NoUnderline,sep) @staticmethod - def MintCream(*obj, sep=sep_): return NCS(obj,MintCream,resetCode,sep) + def MintCream(*obj, sep=sep_): return NCS(obj,Underline.MintCream,Style.NoUnderline,sep) @staticmethod - def SlateGray(*obj, sep=sep_): return NCS(obj,SlateGray,resetCode,sep) + def SlateGray(*obj, sep=sep_): return NCS(obj,Underline.SlateGray,Style.NoUnderline,sep) @staticmethod - def LightSlateGray(*obj, sep=sep_): return NCS(obj,LightSlateGray,resetCode,sep) + def LightSlateGray(*obj, sep=sep_): return NCS(obj,Underline.LightSlateGray,Style.NoUnderline,sep) @staticmethod - def LightSteelBlue(*obj, sep=sep_): return NCS(obj,LightSteelBlue,resetCode,sep) + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,Underline.LightSteelBlue,Style.NoUnderline,sep) @staticmethod - def Lavender(*obj, sep=sep_): return NCS(obj,Lavender,resetCode,sep) + def Lavender(*obj, sep=sep_): return NCS(obj,Underline.Lavender,Style.NoUnderline,sep) @staticmethod - def FloralWhite(*obj, sep=sep_): return NCS(obj,FloralWhite,resetCode,sep) + def FloralWhite(*obj, sep=sep_): return NCS(obj,Underline.FloralWhite,Style.NoUnderline,sep) @staticmethod - def AliceBlue(*obj, sep=sep_): return NCS(obj,AliceBlue,resetCode,sep) + def AliceBlue(*obj, sep=sep_): return NCS(obj,Underline.AliceBlue,Style.NoUnderline,sep) @staticmethod - def GhostWhite(*obj, sep=sep_): return NCS(obj,GhostWhite,resetCode,sep) + def GhostWhite(*obj, sep=sep_): return NCS(obj,Underline.GhostWhite,Style.NoUnderline,sep) @staticmethod - def Honeydew(*obj, sep=sep_): return NCS(obj,Honeydew,resetCode,sep) + def Honeydew(*obj, sep=sep_): return NCS(obj,Underline.Honeydew,Style.NoUnderline,sep) @staticmethod - def Ivory(*obj, sep=sep_): return NCS(obj,Ivory,resetCode,sep) + def Ivory(*obj, sep=sep_): return NCS(obj,Underline.Ivory,Style.NoUnderline,sep) @staticmethod - def Azure(*obj, sep=sep_): return NCS(obj,Azure,resetCode,sep) + def Azure(*obj, sep=sep_): return NCS(obj,Underline.Azure,Style.NoUnderline,sep) @staticmethod - def Snow(*obj, sep=sep_): return NCS(obj,Snow,resetCode,sep) + def Snow(*obj, sep=sep_): return NCS(obj,Underline.Snow,Style.NoUnderline,sep) @staticmethod - def Black(*obj, sep=sep_): return NCS(obj,Black,resetCode,sep) + def Black(*obj, sep=sep_): return NCS(obj,Underline.Black,Style.NoUnderline,sep) @staticmethod - def DimGray(*obj, sep=sep_): return NCS(obj,DimGray,resetCode,sep) + def DimGray(*obj, sep=sep_): return NCS(obj,Underline.DimGray,Style.NoUnderline,sep) @staticmethod - def Gray(*obj, sep=sep_): return NCS(obj,Gray,resetCode,sep) + def Gray(*obj, sep=sep_): return NCS(obj,Underline.Gray,Style.NoUnderline,sep) @staticmethod - def DarkGray(*obj, sep=sep_): return NCS(obj,DarkGray,resetCode,sep) + def DarkGray(*obj, sep=sep_): return NCS(obj,Underline.DarkGray,Style.NoUnderline,sep) @staticmethod - def Silver(*obj, sep=sep_): return NCS(obj,Silver,resetCode,sep) + def Silver(*obj, sep=sep_): return NCS(obj,Underline.Silver,Style.NoUnderline,sep) @staticmethod - def LightGray(*obj, sep=sep_): return NCS(obj,LightGray,resetCode,sep) + def LightGray(*obj, sep=sep_): return NCS(obj,Underline.LightGray,Style.NoUnderline,sep) @staticmethod - def Gainsboro(*obj, sep=sep_): return NCS(obj,Gainsboro,resetCode,sep) + def Gainsboro(*obj, sep=sep_): return NCS(obj,Underline.Gainsboro,Style.NoUnderline,sep) @staticmethod - def WhiteSmoke(*obj, sep=sep_): return NCS(obj,WhiteSmoke,resetCode,sep) + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,Underline.WhiteSmoke,Style.NoUnderline,sep) @staticmethod - def White(*obj, sep=sep_): return NCS(obj,White,resetCode,sep) \ No newline at end of file + def White(*obj, sep=sep_): return NCS(obj,Underline.White,Style.NoUnderline,sep) \ No newline at end of file From c4081cf4115b6854a5af627344f6374ad0c79ae8 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 13:15:18 +0200 Subject: [PATCH 32/40] Fix: Better custom and rgb functions for ForeNest,BackNest and UnderlineNest --- .../Objects/Console/Styling/Nested/BackNest.py | 18 ++++++++---------- .../Objects/Console/Styling/Nested/ForeNest.py | 14 ++++++-------- .../Console/Styling/Nested/UnderlineNest.py | 18 ++++++++---------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py index 313bf56..2636fb9 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py @@ -31,25 +31,23 @@ class BackNest: # - Methods - # ------------------------------------------------------------------------------------------------------------------ @staticmethod - def custom(*obj, color:RGB|HEX, **kwargs) -> str: + def custom(*obj, color:RGB|HEX, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - color = StrictType(color,(RGB,HEX)) return NestedColorSequence( obj, - f"\033[48;2;{color.r};{color.g};{color.b}m", - Style.NoBackground, - **kwargs + f"\033[48;2;{';'.join(*StrictType(color,(RGB,HEX)).export())}m", + Style.NoForeground, + sep=sep ) @staticmethod - def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: + def rgb(*obj, r:int,g:int,b:int, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - r,g,b = NormalizeRgb(r, g, b) return NestedColorSequence( obj, - f"\033[48;2;{r};{g};{b}m", - Style.NoBackground, - **kwargs + f"\033[48;2;{';'.join(*NormalizeRgb(r, g, b))}m", + Style.NoForeground, + sep=sep ) # ------------------------------------------------------------------------------------------------------------------ diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py index 3eaca0a..a08378d 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py @@ -31,25 +31,23 @@ class ForeNest: # - Methods - # ------------------------------------------------------------------------------------------------------------------ @staticmethod - def custom(*obj, color:RGB|HEX, **kwargs) -> str: + def custom(*obj, color:RGB|HEX, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - color = StrictType(color,(RGB,HEX)) return NestedColorSequence( obj, - f"\033[38;2;{color.r};{color.g};{color.b}m", + f"\033[38;2;{';'.join(*StrictType(color,(RGB,HEX)).export())}m", Style.NoForeground, - **kwargs + sep=sep ) @staticmethod - def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: + def rgb(*obj, r:int,g:int,b:int, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - r,g,b = NormalizeRgb(r, g, b) return NestedColorSequence( obj, - f"\033[38;2;{r};{g};{b}m", + f"\033[38;2;{';'.join(*NormalizeRgb(r, g, b))}m", Style.NoForeground, - **kwargs + sep=sep ) # ------------------------------------------------------------------------------------------------------------------ diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py index dbb2fb8..36f01c4 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py @@ -32,25 +32,23 @@ class UnderlineNest: # - Methods - # ------------------------------------------------------------------------------------------------------------------ @staticmethod - def custom(*obj, color:RGB|HEX, **kwargs) -> str: + def custom(*obj, color:RGB|HEX, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - color = StrictType(color,(RGB,HEX)) return NestedColorSequence( obj, - f"\033[58;2;{color.r};{color.g};{color.b}m", - Style.NoUnderline, - **kwargs + f"\033[58;2;{';'.join(*StrictType(color,(RGB,HEX)).export())}m", + Style.NoForeground, + sep=sep ) @staticmethod - def rgb(*obj, r:int,g:int,b:int, **kwargs) -> str: + def rgb(*obj, r:int,g:int,b:int, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' - r,g,b = NormalizeRgb(r, g, b) return NestedColorSequence( obj, - f"\033[58;2;{r};{g};{b}m", - Style.NoUnderline, - **kwargs + f"\033[58;2;{';'.join(*NormalizeRgb(r, g, b))}m", + Style.NoForeground, + sep=sep ) # ------------------------------------------------------------------------------------------------------------------ From ff10e38d3e899541cd51af9fecae0798ad8e03f7 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 13:23:26 +0200 Subject: [PATCH 33/40] Change: TextNestedBig speed test addition --- Tests/SpeedTest.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py index cd22232..62556b4 100644 --- a/Tests/SpeedTest.py +++ b/Tests/SpeedTest.py @@ -32,9 +32,24 @@ def TextNested(): c = BackNest.Maroon("I'M BLUE") return a,b,c +def TextNestedBig(): + a = StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + StyleNest.Bold( + "Bold")))))))))) + return a + if __name__ == '__main__': - # print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") - # print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") + print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") + print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") + print(f"TextNestedBig:{ForeNest.Red(timeit.repeat(lambda: TextNestedBig(), number=1_000_000, repeat=5))}") From 4d971bffc41503cf7cccc4c99ea2deae252d2f76 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 14:21:35 +0200 Subject: [PATCH 34/40] Change: Better _ColorConversionInput decorator instead of long if statements --- Tests/SpeedTest.py | 6 +- src/AthenaColor/Functions/DunderFunctions.py | 66 +--- src/AthenaColor/Objects/Color/ColorSystem.py | 352 ++++++++----------- 3 files changed, 163 insertions(+), 261 deletions(-) diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py index 62556b4..87d0bd0 100644 --- a/Tests/SpeedTest.py +++ b/Tests/SpeedTest.py @@ -49,7 +49,7 @@ def TextNestedBig(): if __name__ == '__main__': print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") - print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") - print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") - print(f"TextNestedBig:{ForeNest.Red(timeit.repeat(lambda: TextNestedBig(), number=1_000_000, repeat=5))}") + # print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") + # print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") + # print(f"TextNestedBig:{ForeNest.Red(timeit.repeat(lambda: TextNestedBig(), number=1_000_000, repeat=5))}") diff --git a/src/AthenaColor/Functions/DunderFunctions.py b/src/AthenaColor/Functions/DunderFunctions.py index e185d4f..8ae8329 100644 --- a/src/AthenaColor/Functions/DunderFunctions.py +++ b/src/AthenaColor/Functions/DunderFunctions.py @@ -3,6 +3,7 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations +import operator # Custom Library @@ -20,46 +21,25 @@ # - Math Dunders - # ---------------------------------------------------------------------------------------------------------------------- def add(left:tuple, right:tuple)->tuple: - return tuple( - lr[0] + lr[1] - for lr in zip(left, right) - ) + return tuple(map(operator.add, left, right)) def sub(left:tuple, right:tuple)->tuple: - return tuple( - lr[0] - lr[1] - for lr in zip(left, right) - ) + return tuple(map(operator.sub, left, right)) def mul(left:tuple, right:tuple)->tuple: - return tuple( - lr[0] * lr[1] - for lr in zip(left, right) - ) + return tuple(map(operator.mul, left, right)) def floordiv(left:tuple, right:tuple)->tuple: - return tuple( - lr[0] // lr[1] - for lr in zip(left, right) - ) + return tuple(map(operator.floordiv, left, right)) def truediv(left:tuple, right:tuple)->tuple: - return tuple( - lr[0] / lr[1] - for lr in zip(left, right) - ) + return tuple(map(operator.truediv, left, right)) def mod(left:tuple, right:tuple)->tuple: - return tuple( - lr[0] % lr[1] - for lr in zip(left, right) - ) + return tuple(map(operator.mod, left, right)) def power(left:tuple, right:tuple)->tuple: - return tuple( - lr[0] ** lr[1] - for lr in zip(left, right) - ) + return tuple(map(operator.pow, left, right)) def divmod_function(left:tuple, right:tuple)->tuple: return floordiv(left,right), mod(left,right) @@ -68,37 +48,19 @@ def divmod_function(left:tuple, right:tuple)->tuple: # - Comparator Dunders - # ---------------------------------------------------------------------------------------------------------------------- def gt(left:tuple,right:tuple)->bool: - return all( - lr[0] > lr[1] - for lr in zip(left, right) - ) + return all(map(operator.gt, left, right)) def lt(left:tuple,right:tuple)->bool: - return all( - lr[0] < lr[1] - for lr in zip(left, right) - ) + return all(map(operator.lt, left, right)) def eq(left:tuple,right:tuple)->bool: - return all( - lr[0] == lr[1] - for lr in zip(left, right) - ) + return all(map(operator.eq, left, right)) def ne(left:tuple,right:tuple)->bool: - return all( - lr[0] != lr[1] - for lr in zip(left, right) - ) + return all(map(operator.ne, left, right)) def le(left:tuple,right:tuple)->bool: - return all( - lr[0] <= lr[1] - for lr in zip(left, right) - ) + return all(map(operator.le, left, right)) def ge(left:tuple,right:tuple)->bool: - return all( - lr[0] >= lr[1] - for lr in zip(left, right) - ) \ No newline at end of file + return all(map(operator.ge, left, right)) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 554728a..de1f3c2 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -4,7 +4,7 @@ # General Packages from __future__ import annotations from abc import ABC, abstractmethod -from typing import Callable, Tuple +from typing import Tuple # Custom Library # Custom Packages @@ -25,24 +25,13 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Support Methods - # ---------------------------------------------------------------------------------------------------------------------- -def dunder_func(func:Callable,left:ColorSystem,right:ColorSystem|int|float|tuple): - if type(left) is type(right): - return func(left.export(), right.export()) - elif isinstance(right, ColorSystem): - return func(left.export(), map_color(left, right)) - elif isinstance(right, (int, float)): - return func(left.export(), (right,) * len(left.export())) - elif isinstance(right, tuple) and len(right) == len(left.export()): - return func(left.export(), right) - else: - return NotImplemented - -def map_color(left,right) -> tuple: - try: - a = color_conversions_mapped[type(left)][type(right)] - return a(right) - except KeyError: - return NotImplemented +def _ColorConversionInput(fnc): + def wrapper(self,other): + try: + return fnc(self, color_conversions_mapped[type(self)][type(other)](other),) + except KeyError: + return NotImplemented + return wrapper # ---------------------------------------------------------------------------------------------------------------------- # - Actual Color System - @@ -90,6 +79,11 @@ def __copy__(self): def __contains__(self, item): return item in self.export() + @ _ColorConversionInput + def __divmod__(self, other: tuple) -> tuple: + div_ , mod_ = CSD.divmod_function(self.export(), other) + return self.__class__(*div_),self.__class__(*mod_) + # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @@ -98,136 +92,78 @@ def __contains__(self, item): # If the two sides of the operation are NOT of the same type, # it will convert the right-hand object to the same type as the left-hand type. - # noinspection PyTypeChecker - def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - """ - """ - result = dunder_func(func=CSD.add, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result) - - # noinspection PyTypeChecker - def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - result = dunder_func(func=CSD.sub, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result) - - # noinspection PyTypeChecker - def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - result = dunder_func(func=CSD.mul, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result) - - # noinspection PyTypeChecker - def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - result = dunder_func(func=CSD.floordiv, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result) - - # noinspection PyTypeChecker - def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - result = dunder_func(func=CSD.truediv, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result) - - # noinspection PyTypeChecker - def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - result = dunder_func(func=CSD.mod, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result) - - # noinspection PyTypeChecker - def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - result = dunder_func(func=CSD.power, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result) - - def __divmod__(self, other: ColorSystem|int|float|tuple): - result = dunder_func(func=CSD.divmod_function, left=self, right=other) - if result is NotImplemented: - return result - return self.__class__(*result[0]), self.__class__(*result[1]) - - def __iadd__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - values = dunder_func(func=CSD.add, left=self, right=other) - if values is NotImplemented: - return values - self._value_setter(values) - return self - def __isub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - values = dunder_func(func=CSD.sub, left=self, right=other) - if values is NotImplemented: - return values - self._value_setter(values) - return self - def __imul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - values = dunder_func(func=CSD.mul, left=self, right=other) - if values is NotImplemented: - return values - self._value_setter(values) - return self - def __ifloordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - values = dunder_func(func=CSD.floordiv, left=self, right=other) - if values is NotImplemented: - return values - self._value_setter(values) - return self - def __itruediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - values = dunder_func(func=CSD.truediv, left=self, right=other) - if values is NotImplemented: - return values - self._value_setter(values) - return self - def __imod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - values = dunder_func(func=CSD.mod, left=self, right=other) - if values is NotImplemented: - return values - self._value_setter(values) - return self - def __ipow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - values = dunder_func(func=CSD.power, left=self, right=other) - if values is NotImplemented: - return values - self._value_setter(values) - return self + @ _ColorConversionInput + def __add__(self, other: tuple) -> ColorSystem: + return self.__class__(*CSD.add(self.export(), other)) + @ _ColorConversionInput + def __sub__(self, other: tuple) -> ColorSystem: + return self.__class__(*CSD.sub(self.export(), other)) + @ _ColorConversionInput + def __mul__(self, other: tuple) -> ColorSystem: + return self.__class__(*CSD.mul(self.export(), other)) + @ _ColorConversionInput + def __floordiv__(self, other: tuple) -> ColorSystem: + return self.__class__(*CSD.floordiv(self.export(), other)) + @ _ColorConversionInput + def __truediv__(self, other: tuple) -> ColorSystem: + return self.__class__(*CSD.truediv(self.export(), other)) + @ _ColorConversionInput + def __mod__(self, other: tuple) -> ColorSystem: + return self.__class__(*CSD.mod(self.export(), other)) + @ _ColorConversionInput + def __pow__(self, other: tuple) -> ColorSystem: + return self.__class__(*CSD.power(self.export(), other)) + + @ _ColorConversionInput + def __iadd__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.add(self.export(), other)) + @ _ColorConversionInput + def __isub__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.sub(self.export(), other)) + @ _ColorConversionInput + def __imul__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.mul(self.export(), other)) + @ _ColorConversionInput + def __ifloordiv__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.floordiv(self.export(), other)) + @ _ColorConversionInput + def __itruediv__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.truediv(self.export(), other)) + @ _ColorConversionInput + def __itruediv__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.truediv(self.export(), other)) + @ _ColorConversionInput + def __imod__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.mod(self.export(), other)) + @ _ColorConversionInput + def __ipow__(self, other: tuple) -> ColorSystem: + return self._value_setter(CSD.power(self.export(), other)) # ------------------------------------------------------------------------------------------------------------------ # - Comparison Dunders - # ------------------------------------------------------------------------------------------------------------------ # ! Comparison Dunder which executes an operator between the left- and right-hand side of the operation. # If the two sides of the operation are NOT of the same type, - # it will convert the right-hand object to the same type as the left-hand type. + # it will convert the right-hand object to the same tuple format as the left-hand type. - # noinspection PyTypeChecker + @ _ColorConversionInput def __gt__(self, other: ColorSystem|int|float|tuple) -> bool: - return dunder_func(func=CSD.gt,left=self,right=other) - - # noinspection PyTypeChecker + return CSD.gt(self.export(), other) + @ _ColorConversionInput def __lt__(self, other: ColorSystem|int|float|tuple) -> bool: - return dunder_func(func=CSD.lt,left=self,right=other) - - # noinspection PyTypeChecker + return CSD.lt(self.export(), other) + @ _ColorConversionInput def __eq__(self, other: ColorSystem|int|float|tuple) -> bool: - return dunder_func(func=CSD.eq,left=self,right=other) - - # noinspection PyTypeChecker + return CSD.eq(self.export(), other) + @ _ColorConversionInput def __ne__(self, other: ColorSystem|int|float|tuple) -> bool: - return dunder_func(func=CSD.ne,left=self,right=other) - - # noinspection PyTypeChecker + return CSD.ne(self.export(), other) + @ _ColorConversionInput def __le__(self, other: ColorSystem|int|float|tuple) -> bool: - return dunder_func(func=CSD.le,left=self,right=other) - - # noinspection PyTypeChecker + return CSD.le(self.export(), other) + @ _ColorConversionInput def __ge__(self, other: ColorSystem|int|float|tuple) -> bool: - return dunder_func(func=CSD.ge,left=self,right=other) + return CSD.ge(self.export(), other) # ------------------------------------------------------------------------------------------------------------------ # - RGB - @@ -315,45 +251,35 @@ def __repr__(self) -> str: def __round__(self, n=None): return self.__class__(rgb_to_hex(*(round(value,n) for value in self.export()))) - def __divmod__(self, other: ColorSystem|int|float|tuple): - result = dunder_func(func=CSD.divmod_function, left=self, right=other) - if result is NotImplemented: - return result - return (*(self.__class__(rgb_to_hex(*colors)) for colors in result),) - - def __abs__(self) -> ColorSystem: - return self.__class__(rgb_to_hex(*(abs(value) for value in self))) + @ _ColorConversionInput + def __divmod__(self, other: tuple) -> tuple: + div_ , mod_ = CSD.divmod_function(self.export(), other) + return self.__class__(rgb_to_hex(*div_)),self.__class__(rgb_to_hex(*mod_)) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ - # noinspection PyTypeChecker - def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgb_to_hex(*dunder_func(func=CSD.add, left=self, right=other))) - - # noinspection PyTypeChecker - def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgb_to_hex(*dunder_func(func=CSD.sub, left=self, right=other))) - - # noinspection PyTypeChecker - def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgb_to_hex(*dunder_func(func=CSD.mul, left=self, right=other))) - - # noinspection PyTypeChecker - def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgb_to_hex(*dunder_func(func=CSD.floordiv, left=self, right=other))) - - # noinspection PyTypeChecker - def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgb_to_hex(*dunder_func(func=CSD.truediv, left=self, right=other))) - - # noinspection PyTypeChecker - def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgb_to_hex(*dunder_func(func=CSD.mod, left=self, right=other))) - - # noinspection PyTypeChecker - def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgb_to_hex(*dunder_func(func=CSD.power, left=self, right=other))) + @ _ColorConversionInput + def __add__(self, other: tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.add(self.export(), other))) + @ _ColorConversionInput + def __sub__(self, other: tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.sub(self.export(), other))) + @ _ColorConversionInput + def __mul__(self, other: tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.mul(self.export(), other))) + @ _ColorConversionInput + def __floordiv__(self, other: tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.floordiv(self.export(), other))) + @ _ColorConversionInput + def __truediv__(self, other: tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.truediv(self.export(), other))) + @ _ColorConversionInput + def __mod__(self, other: tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.mod(self.export(), other))) + @ _ColorConversionInput + def __pow__(self, other: tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.power(self.export(), other))) # ------------------------------------------------------------------------------------------------------------------ # - RGBA - @@ -451,45 +377,35 @@ def __repr__(self) -> str: def __round__(self, n=None): return self.__class__(rgba_to_hexa(*(round(value,n) for value in self.export()))) - def __divmod__(self, other: ColorSystem|int|float|tuple): - result = dunder_func(func=CSD.divmod_function, left=self, right=other) - if result is NotImplemented: - return result - return (*(self.__class__(rgba_to_hexa(*colors)) for colors in result),) - - def __abs__(self) -> ColorSystem: - return self.__class__(rgba_to_hexa(*(abs(value) for value in self))) + @ _ColorConversionInput + def __divmod__(self, other: tuple) -> tuple: + div_ , mod_ = CSD.divmod_function(self.export(), other) + return self.__class__(rgba_to_hexa(*div_)),self.__class__(rgba_to_hexa(*mod_)) # ------------------------------------------------------------------------------------------------------------------ # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ - # noinspection PyTypeChecker - def __add__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.add, left=self, right=other))) - - # noinspection PyTypeChecker - def __sub__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.sub, left=self, right=other))) - - # noinspection PyTypeChecker - def __mul__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.mul, left=self, right=other))) - - # noinspection PyTypeChecker - def __floordiv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.floordiv, left=self, right=other))) - - # noinspection PyTypeChecker - def __truediv__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.truediv, left=self, right=other))) - - # noinspection PyTypeChecker - def __mod__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.mod, left=self, right=other))) - - # noinspection PyTypeChecker - def __pow__(self, other: ColorSystem|int|float|tuple) -> ColorSystem: - return self.__class__(rgba_to_hexa(*dunder_func(func=CSD.power, left=self, right=other))) + @ _ColorConversionInput + def __add__(self, other: tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.add(self.export(), other))) + @ _ColorConversionInput + def __sub__(self, other: tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.sub(self.export(), other))) + @ _ColorConversionInput + def __mul__(self, other: tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.mul(self.export(), other))) + @ _ColorConversionInput + def __floordiv__(self, other: tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.floordiv(self.export(), other))) + @ _ColorConversionInput + def __truediv__(self, other: tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.truediv(self.export(), other))) + @ _ColorConversionInput + def __mod__(self, other: tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.mod(self.export(), other))) + @ _ColorConversionInput + def __pow__(self, other: tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.power(self.export(), other))) # ------------------------------------------------------------------------------------------------------------------ # - HSV - @@ -658,6 +574,9 @@ def __repr__(self) -> str: # needs to be placed here, as only after all the defining of all the colors, this map can be made _r_export = lambda r: r.export() _r_export_slice = lambda r: r.export() +_tuple3 = lambda r: (r,r,r) +_tuple4 = lambda r: (r,r,r,r) +_same = lambda r: r trnspDef = init.transparentDefault[1] color_conversions_mapped ={ RGB : { @@ -668,6 +587,9 @@ def __repr__(self) -> str: CMYK: lambda r: cmyk_to_rgb(*r.export()), RGBA: _r_export_slice, HEXA: _r_export_slice, + int: _tuple3, + float: _tuple3, + tuple: _same }, HEX : { RGB: _r_export, @@ -677,6 +599,9 @@ def __repr__(self) -> str: CMYK: lambda r: cmyk_to_rgb(*r.export()), RGBA: _r_export_slice, HEXA: _r_export_slice, + int: _tuple3, + float: _tuple3, + tuple: _same }, HSL : { RGB: lambda r: rgb_to_hsl(*r.export()), @@ -686,6 +611,9 @@ def __repr__(self) -> str: CMYK: lambda r: cmyk_to_hsl(*r.export()), RGBA: lambda r: rgb_to_hsl(*_r_export_slice(r)), HEXA: lambda r: rgb_to_hsl(*_r_export_slice(r)), + int: _tuple3, + float: _tuple3, + tuple: _same }, HSV : { RGB: lambda r: rgb_to_hsv(*r.export()), @@ -695,6 +623,9 @@ def __repr__(self) -> str: CMYK: lambda r: cmyk_to_hsv(*r.export()), RGBA: lambda r: rgb_to_hsv(*_r_export_slice(r)), HEXA: lambda r: rgb_to_hsv(*_r_export_slice(r)), + int: _tuple3, + float: _tuple3, + tuple: _same }, CMYK : { RGB: lambda r: rgb_to_cmyk(*r.export()), @@ -704,6 +635,9 @@ def __repr__(self) -> str: CMYK: _r_export, RGBA: lambda r: rgb_to_cmyk(*_r_export_slice(r)), HEXA: lambda r: rgb_to_cmyk(*_r_export_slice(r)), + int: _tuple4, + float: _tuple4, + tuple: _same }, RGBA : { RGB: lambda r: (*r.export(), trnspDef), @@ -713,6 +647,9 @@ def __repr__(self) -> str: CMYK: lambda r: (*cmyk_to_rgb(*r.export()), trnspDef), RGBA: _r_export, HEXA: _r_export, + int: _tuple4, + float: _tuple4, + tuple: _same }, HEXA : { RGB: lambda r: (*r.export(), trnspDef), @@ -722,5 +659,8 @@ def __repr__(self) -> str: CMYK: lambda r: (*cmyk_to_rgb(*r.export()), trnspDef), RGBA: _r_export, HEXA: _r_export, + int: _tuple4, + float: _tuple4, + tuple: _same }, } \ No newline at end of file From b7d5c532173378e1b6059ffd17086c4b261369ca Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 14:35:08 +0200 Subject: [PATCH 35/40] Fix: Removal of StrictType --- Tests/ColorObjects/test_HEX.py | 2 +- Tests/Functions/test_General.py | 8 +- src/AthenaColor/Functions/General.py | 9 +- src/AthenaColor/Objects/Color/ColorSystem.py | 140 ++++++++---------- .../Objects/Color/ColorTupleConversion.py | 49 +----- .../Console/Styling/Inline/RgbControlled.py | 3 +- .../Console/Styling/Nested/BackNest.py | 3 +- .../Console/Styling/Nested/ForeNest.py | 3 +- .../Console/Styling/Nested/UnderlineNest.py | 3 +- 9 files changed, 74 insertions(+), 146 deletions(-) diff --git a/Tests/ColorObjects/test_HEX.py b/Tests/ColorObjects/test_HEX.py index e2515ab..d08885b 100644 --- a/Tests/ColorObjects/test_HEX.py +++ b/Tests/ColorObjects/test_HEX.py @@ -25,7 +25,7 @@ def CreateColor(hex_str = "#204080") -> HEX: def test_input(self): with self.assertRaises(TypeError): HEX(1) - with self.assertRaises(TypeError): + with self.assertRaises(ValueError): HEX(b"#123456") with self.assertRaises(ValueError): HEX("#123456789") diff --git a/Tests/Functions/test_General.py b/Tests/Functions/test_General.py index d2e1d12..bd77f66 100644 --- a/Tests/Functions/test_General.py +++ b/Tests/Functions/test_General.py @@ -54,10 +54,4 @@ def test_RoundHalfUp_Fail(self): with self.assertRaises(TypeError): RoundHalfUp((1,)) with self.assertRaises(TypeError): - RoundHalfUp([1,]) - - def test_StrictType(self): - with self.assertRaises(TypeError): - StrictType("a", (int,float)) - with self.assertRaises(TypeError): - StrictType(1, str) + RoundHalfUp([1,]) \ No newline at end of file diff --git a/src/AthenaColor/Functions/General.py b/src/AthenaColor/Functions/General.py index 5426a47..4af33ad 100644 --- a/src/AthenaColor/Functions/General.py +++ b/src/AthenaColor/Functions/General.py @@ -14,7 +14,7 @@ # - All - # ---------------------------------------------------------------------------------------------------------------------- __all__ = [ - "Normalize", "RoundHalfUp","RoundToDecimals", "StrictType" + "Normalize", "RoundHalfUp","RoundToDecimals" ] # ---------------------------------------------------------------------------------------------------------------------- @@ -29,9 +29,4 @@ def RoundToDecimals(value:int|float, decimals:int=None): return round(value, decimals) def RoundHalfUp(value:int|float) -> int: # because Twidi didn't like RoundCorrectly :P - return int(value + 0.5) # thanks for tedthetwonk for refinement - -def StrictType(object_, type_) -> Any: - if not isinstance(object_, type_): - raise TypeError(f"{object_} was not of the type: {type_}") - return object_ \ No newline at end of file + return int(value + 0.5) # thanks for tedthetwonk for refinement \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index de1f3c2..b89dc1e 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -13,7 +13,6 @@ from AthenaColor.InitClass import init from AthenaColor.Functions.Constraints import Constrain from AthenaColor.Functions.General import RoundHalfUp,RoundToDecimals -from AthenaColor.Functions.General import StrictType # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -67,9 +66,6 @@ def __round__(self, n=None) -> ColorSystem: def __iter__(self): return iter(self.export()) - def __len__(self): - return len(self.export()) - def __hash__(self): return hash(self.export()) @@ -193,30 +189,21 @@ def r(self) -> int: return self._r @r.setter def r(self, value: int|float): - if init.roundUp: - self._r = RoundHalfUp(Constrain(StrictType(value, (int,float)), 255)) - else: - self._r = round(Constrain(StrictType(value, (int,float)), 255)) + self._r = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) @property def g(self) -> int: return self._g @g.setter def g(self, value: int|float): - if init.roundUp: - self._g = RoundHalfUp(Constrain(StrictType(value, (int,float)), 255)) - else: - self._g = round(Constrain(StrictType(value, (int,float)), 255)) + self._g = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) @property def b(self) -> int: return self._b @b.setter def b(self, value: int|float): - if init.roundUp: - self._b = RoundHalfUp(Constrain(StrictType(value, (int,float)), 255)) - else: - self._b = round(Constrain(StrictType(value, (int,float)), 255)) + self._b = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -235,7 +222,7 @@ class HEX(RGB): Inherits from RGB as this is just another notation for RGB values. """ def __init__(self, hex_value:str="#000000"): - super().__init__(*hex_to_rgb(StrictType(hex_value, str))) + super().__init__(*hex_to_rgb(hex_value)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -309,40 +296,29 @@ def r(self) -> int: return self._r @r.setter def r(self, value: int|float): - if init.roundUp: - self._r = RoundHalfUp(Constrain(StrictType(value, (int,float)), 255)) - else: - self._r = round(Constrain(StrictType(value, (int,float)), 255)) + self._r = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) @property def g(self) -> int: return self._g @g.setter def g(self, value: int|float): - if init.roundUp: - self._g = RoundHalfUp(Constrain(StrictType(value, (int,float)), 255)) - else: - self._g = round(Constrain(StrictType(value, (int,float)), 255)) + self._g = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) @property def b(self) -> int: return self._b @b.setter def b(self, value: int|float): - if init.roundUp: - self._b = RoundHalfUp(Constrain(StrictType(value, (int,float)), 255)) - else: - self._b = round(Constrain(StrictType(value, (int,float)), 255)) + self._b = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + @property def a(self) -> int: return self._a @a.setter def a(self, value: int|float): - if init.roundUp: - self._a = RoundHalfUp(Constrain(StrictType(value, (int,float)), 255)) - else: - self._a = round(Constrain(StrictType(value, (int,float)), 255)) + self._a = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods # ------------------------------------------------------------------------------------------------------------------ @@ -436,21 +412,21 @@ def h(self) -> int|float: return self._h @h.setter def h(self, value: int|float): - self._h = RoundToDecimals(Constrain(StrictType(value, (int,float)), 360)) + self._h = RoundToDecimals(Constrain(value, 360)) @property def s(self) -> int|float: return self._s @s.setter def s(self, value: int|float): - self._s = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._s = RoundToDecimals(Constrain(value, 1)) @property def v(self) -> int|float: return self._v @v.setter def v(self, value: int|float): - self._v = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._v = RoundToDecimals(Constrain(value, 1)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -488,21 +464,21 @@ def h(self) -> int|float: return self._h @h.setter def h(self, value: int|float): - self._h = RoundToDecimals(Constrain(StrictType(value, (int,float)), 360)) + self._h = RoundToDecimals(Constrain(value, 360)) @property def s(self) -> int|float: return self._s @s.setter def s(self, value: int|float): - self._s = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._s = RoundToDecimals(Constrain(value, 1)) @property def l(self) -> int|float: return self._l @l.setter def l(self, value: int|float): - self._l = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._l = RoundToDecimals(Constrain(value, 1)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -539,28 +515,28 @@ def c(self) -> int|float: return self._c @c.setter def c(self, value: int|float): - self._c = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._c = RoundToDecimals(Constrain(value, 1)) @property def m(self) -> int|float: return self._m @m.setter def m(self, value: int|float): - self._m = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._m = RoundToDecimals(Constrain(value, 1)) @property def y(self) -> int|float: return self._y @y.setter def y(self, value: int|float): - self._y = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._y = RoundToDecimals(Constrain(value, 1)) @property def k(self) -> int|float: return self._k @k.setter def k(self, value: int|float): - self._k = RoundToDecimals(Constrain(StrictType(value, (int,float)), 1)) + self._k = RoundToDecimals(Constrain(value, 1)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -573,7 +549,7 @@ def __repr__(self) -> str: # Possible because we now have a __hash__ on any given ColorSystem class # needs to be placed here, as only after all the defining of all the colors, this map can be made _r_export = lambda r: r.export() -_r_export_slice = lambda r: r.export() +_r_export_RGBAtoRGB = lambda r: (r.r, r.g, r.b) _tuple3 = lambda r: (r,r,r) _tuple4 = lambda r: (r,r,r,r) _same = lambda r: r @@ -582,11 +558,11 @@ def __repr__(self) -> str: RGB : { RGB: _r_export, HEX: _r_export, - HSL: lambda r: hsl_to_rgb(*r.export()), - HSV: lambda r: hsv_to_rgb(*r.export()), - CMYK: lambda r: cmyk_to_rgb(*r.export()), - RGBA: _r_export_slice, - HEXA: _r_export_slice, + HSL: lambda r: hsl_to_rgb(r.h, r.s, r.l), + HSV: lambda r: hsv_to_rgb(r.h, r.s, r.v), + CMYK: lambda r: cmyk_to_rgb(r.c,r.m,r.y,r.k), + RGBA: _r_export_RGBAtoRGB, + HEXA: _r_export_RGBAtoRGB, int: _tuple3, float: _tuple3, tuple: _same @@ -594,57 +570,57 @@ def __repr__(self) -> str: HEX : { RGB: _r_export, HEX: _r_export, - HSL: lambda r: hsl_to_rgb(*r.export()), - HSV: lambda r: hsv_to_rgb(*r.export()), - CMYK: lambda r: cmyk_to_rgb(*r.export()), - RGBA: _r_export_slice, - HEXA: _r_export_slice, + HSL: lambda r: hsl_to_rgb(r.h, r.s, r.l), + HSV: lambda r: hsv_to_rgb(r.h, r.s, r.v), + CMYK: lambda r: cmyk_to_rgb(r.c,r.m,r.y,r.k), + RGBA: _r_export_RGBAtoRGB, + HEXA: _r_export_RGBAtoRGB, int: _tuple3, float: _tuple3, tuple: _same }, HSL : { - RGB: lambda r: rgb_to_hsl(*r.export()), - HEX: lambda r: rgb_to_hsl(*r.export()), + RGB: lambda r: rgb_to_hsl(r.r, r.g, r.b), + HEX: lambda r: rgb_to_hsl(r.r, r.g, r.b), HSL: _r_export, - HSV: lambda r: hsv_to_hsl(*r.export()), - CMYK: lambda r: cmyk_to_hsl(*r.export()), - RGBA: lambda r: rgb_to_hsl(*_r_export_slice(r)), - HEXA: lambda r: rgb_to_hsl(*_r_export_slice(r)), + HSV: lambda r: hsv_to_hsl(r.h, r.s, r.v), + CMYK: lambda r: cmyk_to_hsl(r.c,r.m,r.y,r.k), + RGBA: lambda r: rgb_to_hsl(r.r, r.g, r.b), + HEXA: lambda r: rgb_to_hsl(r.r, r.g, r.b), int: _tuple3, float: _tuple3, tuple: _same }, HSV : { - RGB: lambda r: rgb_to_hsv(*r.export()), - HEX: lambda r: rgb_to_hsv(*r.export()), - HSL: lambda r: hsl_to_hsv(*r.export()), + RGB: lambda r: rgb_to_hsv(r.r, r.g, r.b), + HEX: lambda r: rgb_to_hsv(r.r, r.g, r.b), + HSL: lambda r: hsl_to_hsv(r.h, r.s, r.l), HSV: _r_export, - CMYK: lambda r: cmyk_to_hsv(*r.export()), - RGBA: lambda r: rgb_to_hsv(*_r_export_slice(r)), - HEXA: lambda r: rgb_to_hsv(*_r_export_slice(r)), + CMYK: lambda r: cmyk_to_hsv(r.c,r.m,r.y,r.k), + RGBA: lambda r: rgb_to_hsv(r.r, r.g, r.b), + HEXA: lambda r: rgb_to_hsv(r.r, r.g, r.b), int: _tuple3, float: _tuple3, tuple: _same }, CMYK : { - RGB: lambda r: rgb_to_cmyk(*r.export()), - HEX: lambda r: rgb_to_cmyk(*r.export()), - HSL: lambda r: hsl_to_cmyk(*r.export()), - HSV: lambda r: hsv_to_cmyk(*r.export()), + RGB: lambda r: rgb_to_cmyk(r.r, r.g, r.b), + HEX: lambda r: rgb_to_cmyk(r.r, r.g, r.b), + HSL: lambda r: hsl_to_cmyk(r.h, r.s, r.l), + HSV: lambda r: hsv_to_cmyk(r.h, r.s, r.v), CMYK: _r_export, - RGBA: lambda r: rgb_to_cmyk(*_r_export_slice(r)), - HEXA: lambda r: rgb_to_cmyk(*_r_export_slice(r)), + RGBA: lambda r: rgb_to_cmyk(r.r, r.g, r.b), + HEXA: lambda r: rgb_to_cmyk(r.r, r.g, r.b), int: _tuple4, float: _tuple4, tuple: _same }, RGBA : { - RGB: lambda r: (*r.export(), trnspDef), - HEX: lambda r: (*r.export(), trnspDef), - HSL: lambda r: (*hsl_to_rgb(*r.export()), trnspDef), - HSV: lambda r: (*hsv_to_rgb(*r.export()), trnspDef), - CMYK: lambda r: (*cmyk_to_rgb(*r.export()), trnspDef), + RGB: lambda r: (r.r, r.g, r.b, trnspDef), + HEX: lambda r: (r.r, r.g, r.b, trnspDef), + HSL: lambda r: (*hsl_to_rgb(r.h, r.s, r.l), trnspDef), + HSV: lambda r: (*hsv_to_rgb(r.h, r.s, r.v), trnspDef), + CMYK: lambda r: (*cmyk_to_rgb(r.c,r.m,r.y,r.k), trnspDef), RGBA: _r_export, HEXA: _r_export, int: _tuple4, @@ -652,11 +628,11 @@ def __repr__(self) -> str: tuple: _same }, HEXA : { - RGB: lambda r: (*r.export(), trnspDef), - HEX: lambda r: (*r.export(), trnspDef), - HSL: lambda r: (*hsl_to_rgb(*r.export()), trnspDef), - HSV: lambda r: (*hsv_to_rgb(*r.export()), trnspDef), - CMYK: lambda r: (*cmyk_to_rgb(*r.export()), trnspDef), + RGB: lambda r: (r.r, r.g, r.b, trnspDef), + HEX: lambda r: (r.r, r.g, r.b, trnspDef), + HSL: lambda r: (*hsl_to_rgb(r.h, r.s, r.l), trnspDef), + HSV: lambda r: (*hsv_to_rgb(r.h, r.s, r.v), trnspDef), + CMYK: lambda r: (*cmyk_to_rgb(r.c,r.m,r.y,r.k), trnspDef), RGBA: _r_export, HEXA: _r_export, int: _tuple4, diff --git a/src/AthenaColor/Objects/Color/ColorTupleConversion.py b/src/AthenaColor/Objects/Color/ColorTupleConversion.py index 680d7a5..10faf08 100644 --- a/src/AthenaColor/Objects/Color/ColorTupleConversion.py +++ b/src/AthenaColor/Objects/Color/ColorTupleConversion.py @@ -10,7 +10,7 @@ # Custom Packages from AthenaColor.Functions.General import ( - Normalize,RoundHalfUp,RoundToDecimals, StrictType + Normalize,RoundHalfUp,RoundToDecimals ) from AthenaColor.Functions.Constraints import ( ConstrainHSV, ConstrainHSL, ConstrainRGB, ConstrainCMYK,ConstrainRGBA @@ -41,8 +41,6 @@ def hex_to_rgb(hexadecimal:str) -> Tuple[int, ...]: Function to convert a hexadecimal string to a rgb tuple. Does not create an RGB object. """ - # Type check the hex input - StrictType(hexadecimal, str) # Form hex value in usable state (cast away the '#' value) if hexadecimal[0] == "#" and len(hexadecimal) == 7: hex_v = hexadecimal[1:] @@ -62,11 +60,7 @@ def hsv_to_rgb(h:int|float,s:int|float,v:int|float) -> Tuple[int,int,int]: Function to convert a hsv tuple to a rgb tuple. Does not create an RGB object. """ - h,s,v = ConstrainHSV( - StrictType(h,numbers), - StrictType(s,numbers), - StrictType(v,numbers) - ) + h,s,v = ConstrainHSV(h,s,v) C = v*s X = C*(1-math.fabs(math.fmod(h/60.0,2)-1)) @@ -92,12 +86,7 @@ def cmyk_to_rgb(c:int|float,m:int|float,y:int|float,k:int|float) -> Tuple[int,in Function to convert a cmyk tuple to a rgb tuple. Does not create an RGB object. """ - c,m,y,k = ConstrainCMYK( - StrictType(c,numbers), - StrictType(m,numbers), - StrictType(y,numbers), - StrictType(k,numbers), - ) + c,m,y,k = ConstrainCMYK(c,m,y,k) return ( RoundHalfUp(255 * (1 - c) * (1 - k)), #r RoundHalfUp(255 * (1 - m) * (1 - k)), #g @@ -109,11 +98,7 @@ def hsl_to_rgb(h:int|float,s:int|float,l:int|float) -> Tuple[int,int,int]: Function to convert a hsl tuple to a rgb tuple. Does not create an RGB object. """ - h,s,l =ConstrainHSL( - StrictType(h, numbers), - StrictType(s, numbers), - StrictType(l, numbers) - ) + h,s,l =ConstrainHSL(h,s,l) C = (1-math.fabs((2*l)-1))*s X = C*(1-math.fabs(math.fmod(h/60,2)-1)) @@ -175,11 +160,7 @@ def rgb_to_hsv(r:int,g:int,b:int) -> Tuple[float,float,float]: Does not create an HSV object. """ # Normalize - r_,g_,b_ = NormalizeRgb(*ConstrainRGB( - StrictType(r, numbers), - StrictType(g, numbers), - StrictType(b, numbers) - )) + r_,g_,b_ = NormalizeRgb(*ConstrainRGB(r,g,b)) # Find max and min Max = max(r_, g_, b_) @@ -234,11 +215,7 @@ def rgb_to_cmyk(r:int,g:int,b:int) -> Tuple[float,float,float,float]: Does not create an CMYK object. """ # Normalize - r_, g_, b_ = NormalizeRgb(*ConstrainRGB( - StrictType(r, numbers), - StrictType(g, numbers), - StrictType(b, numbers) - )) + r_, g_, b_ = NormalizeRgb(*ConstrainRGB(r,g,b)) k = 1 - max(r_, g_, b_) if k == 1: @@ -281,11 +258,7 @@ def rgb_to_hsl(r:int,g:int,b:int) -> Tuple[float,float,float]: Does not create an HSL object. """ # Normalize - r_, g_, b_ = NormalizeRgb(*ConstrainRGB( - StrictType(r, numbers), - StrictType(g, numbers), - StrictType(b, numbers) - )) + r_, g_, b_ = NormalizeRgb(*ConstrainRGB(r,g,b)) # Find max and min Max = max(r_, g_, b_) Min = min(r_, g_, b_) @@ -342,7 +315,6 @@ def hexa_to_rgba(hexadecimal:str) -> Tuple[int,...]: Does not create an RGBA object. """ # Type check the hex input - StrictType(hexadecimal, str) # Form hex value in usable state (cast away the '#' value) if hexadecimal[0] == "#": hex_v = hexadecimal[1:] @@ -361,9 +333,4 @@ def rgba_to_hexa(r:int,g:int,b:int,a:int) -> str: Function to convert a rgba tuple to a hexa string. Does not create an HEXA object. """ - return '#%02x%02x%02x%02x' % ConstrainRGBA( - StrictType(r, numbers), - StrictType(g, numbers), - StrictType(b, numbers), - StrictType(a, numbers), - ) \ No newline at end of file + return '#%02x%02x%02x%02x' % ConstrainRGBA(r,g,b,a) \ No newline at end of file diff --git a/src/AthenaColor/Objects/Console/Styling/Inline/RgbControlled.py b/src/AthenaColor/Objects/Console/Styling/Inline/RgbControlled.py index 1cb0fa7..b123c85 100644 --- a/src/AthenaColor/Objects/Console/Styling/Inline/RgbControlled.py +++ b/src/AthenaColor/Objects/Console/Styling/Inline/RgbControlled.py @@ -11,7 +11,6 @@ from AthenaColor.Functions.ANSIsquences import ColorSequence from AthenaColor.Data.HtmlColors import HtmlColorObjects from AthenaColor.Objects.Color.ColorSystem import RGB, RGBA, HEX, HEXA, HSV, HSL, CMYK -from AthenaColor.Functions.General import StrictType # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -25,7 +24,7 @@ # ---------------------------------------------------------------------------------------------------------------------- class RgbControlled: def __init__(self, param_code:str): - self._param_code = StrictType(param_code, str) + self._param_code = param_code self.Maroon = ColorSequence(f"{self._param_code}{str(HtmlColorObjects.Maroon)}") self.DarkRed = ColorSequence(f"{self._param_code}{str(HtmlColorObjects.DarkRed)}") self.Brown = ColorSequence(f"{self._param_code}{str(HtmlColorObjects.Brown)}") diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py index 2636fb9..861bf99 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py @@ -9,7 +9,6 @@ # Custom Packages from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence -from AthenaColor.Functions.General import StrictType from AthenaColor.Objects.Console.Styling.Inline.Bodies import Back from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style @@ -35,7 +34,7 @@ def custom(*obj, color:RGB|HEX, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' return NestedColorSequence( obj, - f"\033[48;2;{';'.join(*StrictType(color,(RGB,HEX)).export())}m", + f"\033[48;2;{';'.join(*color.export())}m", Style.NoForeground, sep=sep ) diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py index a08378d..2e26983 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py @@ -9,7 +9,6 @@ # Custom Packages from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence -from AthenaColor.Functions.General import StrictType from AthenaColor.Objects.Console.Styling.Inline.Bodies import Fore from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style @@ -35,7 +34,7 @@ def custom(*obj, color:RGB|HEX, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' return NestedColorSequence( obj, - f"\033[38;2;{';'.join(*StrictType(color,(RGB,HEX)).export())}m", + f"\033[38;2;{';'.join(*color.export())}m", Style.NoForeground, sep=sep ) diff --git a/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py index 36f01c4..da022a9 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py @@ -9,7 +9,6 @@ # Custom Packages from AthenaColor.Objects.Color.ColorSystem import RGB,HEX, NormalizeRgb from AthenaColor.Functions.ANSIsquences import NestedColorSequence -from AthenaColor.Functions.General import StrictType from AthenaColor.Objects.Console.Styling.Inline.Bodies import Underline from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style @@ -36,7 +35,7 @@ def custom(*obj, color:RGB|HEX, sep=sep_) -> str: # Don't rely on init.stringSeparation as the ANSI code rely on it being a ';' return NestedColorSequence( obj, - f"\033[58;2;{';'.join(*StrictType(color,(RGB,HEX)).export())}m", + f"\033[58;2;{';'.join(*color.export())}m", Style.NoForeground, sep=sep ) From af30336bc68a254790577b650c6561e933ae60dd Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 14:37:28 +0200 Subject: [PATCH 36/40] Change: Better TypeHinting --- src/AthenaColor/Objects/Color/ColorSystem.py | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index b89dc1e..637c395 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -25,9 +25,9 @@ # - Support Methods - # ---------------------------------------------------------------------------------------------------------------------- def _ColorConversionInput(fnc): - def wrapper(self,other): + def wrapper(self,other:ColorSystem|int|tuple): try: - return fnc(self, color_conversions_mapped[type(self)][type(other)](other),) + return fnc(self, color_conversions_mapped[type(self)][type(other)](other)) except KeyError: return NotImplemented return wrapper @@ -89,50 +89,50 @@ def __divmod__(self, other: tuple) -> tuple: # it will convert the right-hand object to the same type as the left-hand type. @ _ColorConversionInput - def __add__(self, other: tuple) -> ColorSystem: + def __add__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(*CSD.add(self.export(), other)) @ _ColorConversionInput - def __sub__(self, other: tuple) -> ColorSystem: + def __sub__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(*CSD.sub(self.export(), other)) @ _ColorConversionInput - def __mul__(self, other: tuple) -> ColorSystem: + def __mul__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(*CSD.mul(self.export(), other)) @ _ColorConversionInput - def __floordiv__(self, other: tuple) -> ColorSystem: + def __floordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(*CSD.floordiv(self.export(), other)) @ _ColorConversionInput - def __truediv__(self, other: tuple) -> ColorSystem: + def __truediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(*CSD.truediv(self.export(), other)) @ _ColorConversionInput - def __mod__(self, other: tuple) -> ColorSystem: + def __mod__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(*CSD.mod(self.export(), other)) @ _ColorConversionInput - def __pow__(self, other: tuple) -> ColorSystem: + def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(*CSD.power(self.export(), other)) @ _ColorConversionInput - def __iadd__(self, other: tuple) -> ColorSystem: + def __iadd__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.add(self.export(), other)) @ _ColorConversionInput - def __isub__(self, other: tuple) -> ColorSystem: + def __isub__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.sub(self.export(), other)) @ _ColorConversionInput - def __imul__(self, other: tuple) -> ColorSystem: + def __imul__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.mul(self.export(), other)) @ _ColorConversionInput - def __ifloordiv__(self, other: tuple) -> ColorSystem: + def __ifloordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.floordiv(self.export(), other)) @ _ColorConversionInput - def __itruediv__(self, other: tuple) -> ColorSystem: + def __itruediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.truediv(self.export(), other)) @ _ColorConversionInput - def __itruediv__(self, other: tuple) -> ColorSystem: + def __itruediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.truediv(self.export(), other)) @ _ColorConversionInput - def __imod__(self, other: tuple) -> ColorSystem: + def __imod__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.mod(self.export(), other)) @ _ColorConversionInput - def __ipow__(self, other: tuple) -> ColorSystem: + def __ipow__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self._value_setter(CSD.power(self.export(), other)) # ------------------------------------------------------------------------------------------------------------------ @@ -247,25 +247,25 @@ def __divmod__(self, other: tuple) -> tuple: # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @ _ColorConversionInput - def __add__(self, other: tuple) -> ColorSystem: + def __add__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgb_to_hex(*CSD.add(self.export(), other))) @ _ColorConversionInput - def __sub__(self, other: tuple) -> ColorSystem: + def __sub__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgb_to_hex(*CSD.sub(self.export(), other))) @ _ColorConversionInput - def __mul__(self, other: tuple) -> ColorSystem: + def __mul__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgb_to_hex(*CSD.mul(self.export(), other))) @ _ColorConversionInput - def __floordiv__(self, other: tuple) -> ColorSystem: + def __floordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgb_to_hex(*CSD.floordiv(self.export(), other))) @ _ColorConversionInput - def __truediv__(self, other: tuple) -> ColorSystem: + def __truediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgb_to_hex(*CSD.truediv(self.export(), other))) @ _ColorConversionInput - def __mod__(self, other: tuple) -> ColorSystem: + def __mod__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgb_to_hex(*CSD.mod(self.export(), other))) @ _ColorConversionInput - def __pow__(self, other: tuple) -> ColorSystem: + def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgb_to_hex(*CSD.power(self.export(), other))) # ------------------------------------------------------------------------------------------------------------------ @@ -362,25 +362,25 @@ def __divmod__(self, other: tuple) -> tuple: # - Math Dunders - # ------------------------------------------------------------------------------------------------------------------ @ _ColorConversionInput - def __add__(self, other: tuple) -> ColorSystem: + def __add__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgba_to_hexa(*CSD.add(self.export(), other))) @ _ColorConversionInput - def __sub__(self, other: tuple) -> ColorSystem: + def __sub__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgba_to_hexa(*CSD.sub(self.export(), other))) @ _ColorConversionInput - def __mul__(self, other: tuple) -> ColorSystem: + def __mul__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgba_to_hexa(*CSD.mul(self.export(), other))) @ _ColorConversionInput - def __floordiv__(self, other: tuple) -> ColorSystem: + def __floordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgba_to_hexa(*CSD.floordiv(self.export(), other))) @ _ColorConversionInput - def __truediv__(self, other: tuple) -> ColorSystem: + def __truediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgba_to_hexa(*CSD.truediv(self.export(), other))) @ _ColorConversionInput - def __mod__(self, other: tuple) -> ColorSystem: + def __mod__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgba_to_hexa(*CSD.mod(self.export(), other))) @ _ColorConversionInput - def __pow__(self, other: tuple) -> ColorSystem: + def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem: return self.__class__(rgba_to_hexa(*CSD.power(self.export(), other))) # ------------------------------------------------------------------------------------------------------------------ From 9c1a50b504c998e7b79bb76f463057de45b09267 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 14:41:17 +0200 Subject: [PATCH 37/40] Removed init.RoundUp --- Tests/SpeedTest.py | 10 +++++++--- src/AthenaColor/InitClass.py | 10 ---------- src/AthenaColor/Objects/Color/ColorSystem.py | 14 +++++++------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py index 87d0bd0..8181a02 100644 --- a/Tests/SpeedTest.py +++ b/Tests/SpeedTest.py @@ -44,12 +44,16 @@ def TextNestedBig(): StyleNest.Bold( StyleNest.Bold( "Bold")))))))))) - return a + return + +def ObjectCreation(): + RGB(255, 255, 255) if __name__ == '__main__': - print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") - print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") + # print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") + # print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") # print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") # print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") # print(f"TextNestedBig:{ForeNest.Red(timeit.repeat(lambda: TextNestedBig(), number=1_000_000, repeat=5))}") + print(f"ObjectCreation:{ForeNest.Red(timeit.repeat(lambda: ObjectCreation(), number=1_000_000, repeat=5))}") diff --git a/src/AthenaColor/InitClass.py b/src/AthenaColor/InitClass.py index 56855e6..bd9eda7 100644 --- a/src/AthenaColor/InitClass.py +++ b/src/AthenaColor/InitClass.py @@ -33,16 +33,6 @@ def __init__(self): if sys.platform == 'win32': os.system("color") - @property - def roundUp(self): - return self._roundUp - @roundUp.setter - def roundUp(self,value:bool): - if isinstance(value,bool): - self._roundUp = value - else: - raise ValueError - @property def esc(self): return self._esc diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index 637c395..a494916 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -189,21 +189,21 @@ def r(self) -> int: return self._r @r.setter def r(self, value: int|float): - self._r = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + self._r = round(Constrain(value, 255)) @property def g(self) -> int: return self._g @g.setter def g(self, value: int|float): - self._g = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + self._g = round(Constrain(value, 255)) @property def b(self) -> int: return self._b @b.setter def b(self, value: int|float): - self._b = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + self._b = round(Constrain(value, 255)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -296,21 +296,21 @@ def r(self) -> int: return self._r @r.setter def r(self, value: int|float): - self._r = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + self._r = round(Constrain(value, 255)) @property def g(self) -> int: return self._g @g.setter def g(self, value: int|float): - self._g = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + self._g = round(Constrain(value, 255)) @property def b(self) -> int: return self._b @b.setter def b(self, value: int|float): - self._b = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + self._b = round(Constrain(value, 255)) @property @@ -318,7 +318,7 @@ def a(self) -> int: return self._a @a.setter def a(self, value: int|float): - self._a = RoundHalfUp(Constrain(value, 255)) if init.roundUp else round(Constrain(value, 255)) + self._a = round(Constrain(value, 255)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods # ------------------------------------------------------------------------------------------------------------------ From 8f71276289b475275a7f7d6d16a14330841788bd Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 15:01:04 +0200 Subject: [PATCH 38/40] Change to_... now uses color_conversions_mapped --- Tests/Functions/test_Constraints.py | 5 - Tests/Functions/test_General.py | 8 +- src/AthenaColor/Functions/Constraints.py | 2 - src/AthenaColor/Functions/General.py | 5 +- .../Objects/Color/ColorObjectConversion.py | 109 ++++-------------- src/AthenaColor/Objects/Color/ColorSystem.py | 22 ++-- 6 files changed, 36 insertions(+), 115 deletions(-) diff --git a/Tests/Functions/test_Constraints.py b/Tests/Functions/test_Constraints.py index c4eae88..10877ea 100644 --- a/Tests/Functions/test_Constraints.py +++ b/Tests/Functions/test_Constraints.py @@ -22,11 +22,6 @@ def test_Constrain(self): self.assertEqual(Constrain(value=-1000,maximum=100,minimum=-100),-100) def test_Constrain_Fail(self): - with self.assertRaises(ValueError): - Constrain(value=85, maximum=90, minimum=100) - with self.assertRaises(ValueError): - Constrain(value=85, maximum=90, minimum=100) - with self.assertRaises(TypeError): # noinspection PyTypeChecker Constrain(value="a", maximum=100) diff --git a/Tests/Functions/test_General.py b/Tests/Functions/test_General.py index bd77f66..f1e5846 100644 --- a/Tests/Functions/test_General.py +++ b/Tests/Functions/test_General.py @@ -26,11 +26,9 @@ def test_Normalize_Factor(self): self.assertEqual(Normalize(i, factor=f), i/f) def test_RoundToDecimals(self): - for d in range(1,6): - init.decimalPlaces = d - for i, f in zip(range(1,24),range(24,56)): - with self.subTest(i=i, f=f, d=d): - self.assertEqual(RoundToDecimals(i/f), round(i/f , d)) + for i, f in zip(range(1,24),range(24,56)): + with self.subTest(i=i, f=f): + self.assertEqual(RoundToDecimals(i/f), round(i/f , init.decimalPlaces)) # noinspection PyTypeChecker def test_RoundToDecimals_Fail(self): diff --git a/src/AthenaColor/Functions/Constraints.py b/src/AthenaColor/Functions/Constraints.py index 4f3001c..da7e401 100644 --- a/src/AthenaColor/Functions/Constraints.py +++ b/src/AthenaColor/Functions/Constraints.py @@ -20,8 +20,6 @@ # - Code - # ---------------------------------------------------------------------------------------------------------------------- def Constrain(value:int|float, maximum:int|float, minimum:int|float=0) -> int|float: - if maximum < minimum: - raise ValueError(f"maximum={maximum} cannot be smaller than minimum={minimum}") return max(min(value, maximum),minimum) # ---------------------------------------------------------------------------------------------------------------------- diff --git a/src/AthenaColor/Functions/General.py b/src/AthenaColor/Functions/General.py index 4af33ad..4520dd8 100644 --- a/src/AthenaColor/Functions/General.py +++ b/src/AthenaColor/Functions/General.py @@ -3,7 +3,6 @@ # ---------------------------------------------------------------------------------------------------------------------- # General Packages from __future__ import annotations -from typing import Any # Custom Library @@ -23,9 +22,7 @@ def Normalize(value:int|float, factor:int|float=100)->float: return value/factor -def RoundToDecimals(value:int|float, decimals:int=None): - if decimals is None: - decimals = init.decimalPlaces +def RoundToDecimals(value:int|float, decimals:int=init.decimalPlaces): return round(value, decimals) def RoundHalfUp(value:int|float) -> int: # because Twidi didn't like RoundCorrectly :P diff --git a/src/AthenaColor/Objects/Color/ColorObjectConversion.py b/src/AthenaColor/Objects/Color/ColorObjectConversion.py index 4316b58..2ce1997 100644 --- a/src/AthenaColor/Objects/Color/ColorObjectConversion.py +++ b/src/AthenaColor/Objects/Color/ColorObjectConversion.py @@ -7,9 +7,8 @@ # Custom Library # Custom Packages -from AthenaColor.InitClass import init import AthenaColor.Objects.Color.ColorTupleConversion as CTC -from AthenaColor.Objects.Color.ColorSystem import ColorSystem,RGB,HEX,CMYK,HSL,HSV,RGBA,HEXA +from AthenaColor.Objects.Color.ColorSystem import ColorSystem,RGB,HEX,CMYK,HSL,HSV,RGBA,HEXA, color_conversions_mapped # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -26,19 +25,9 @@ def to_RGB(color:ColorSystem|RGB|HEX|CMYK|HSL|HSV|RGBA|HEXA) -> RGB: """ Function which converts any Color Object to an RGB object """ - if isinstance(color, HEX): - return RGB(*CTC.hex_to_rgb(str(color))) - elif isinstance(color, RGB): - return RGB(*color.export()) - elif isinstance(color,(RGBA,HEXA)): - return RGB(*color.export()[:-1]) - elif isinstance(color, HSV): - return RGB(*CTC.hsv_to_rgb(*color.export())) - elif isinstance(color, HSL): - return RGB(*CTC.hsl_to_rgb(*color.export())) - elif isinstance(color, CMYK): - return RGB(*CTC.cmyk_to_rgb(*color.export())) - else: + try: + return RGB(*color_conversions_mapped[RGB][type(color)](color)) + except KeyError: return NotImplemented # ---------------------------------------------------------------------------------------------------------------------- @@ -49,17 +38,9 @@ def to_HEX(color:ColorSystem|RGB|HEX|CMYK|HSL|HSV|RGBA|HEXA) -> HEX: """ Function which converts any Color Object to an HEX object. """ - if isinstance(color, (RGB,HEX)): - return HEX(CTC.rgb_to_hex(*color.export())) - elif isinstance(color,(RGBA,HEXA)): - return HEX(CTC.rgb_to_hex(*color.export()[:-1])) - elif isinstance(color, HSV): - return HEX(CTC.hsv_to_hex(*color.export())) - elif isinstance(color, HSL): - return HEX(CTC.hsl_to_hex(*color.export())) - elif isinstance(color, CMYK): - return HEX(CTC.cmyk_to_hex(*color.export())) - else: + try: + return HEX(CTC.rgb_to_hex(*color_conversions_mapped[HEX][type(color)](color))) + except KeyError: return NotImplemented # ---------------------------------------------------------------------------------------------------------------------- @@ -70,17 +51,9 @@ def to_HSV(color:ColorSystem|RGB|HEX|CMYK|HSL|HSV|RGBA|HEXA) -> HSV: """ Function which converts any Color Object to an HSV object. """ - if isinstance(color, (RGB,HEX)): - return HSV(*CTC.rgb_to_hsv(*color.export())) - elif isinstance(color,(RGBA,HEXA)): - return HSV(*CTC.rgb_to_hsv(*color.export()[:-1])) - elif isinstance(color, HSV): - return HSV(*color.export()) - elif isinstance(color, HSL): - return HSV(*CTC.hsl_to_hsv(*color.export())) - elif isinstance(color, CMYK): - return HSV(*CTC.cmyk_to_hsv(*color.export())) - else: + try: + return HSV(*color_conversions_mapped[HSV][type(color)](color)) + except KeyError: return NotImplemented # ---------------------------------------------------------------------------------------------------------------------- @@ -90,17 +63,9 @@ def to_HSL(color:ColorSystem|RGB|HEX|CMYK|HSL|HSV|RGBA|HEXA) -> HSL: """ Function which converts any Color Object to an HSL object. """ - if isinstance(color, (RGB,HEX)): - return HSL(*CTC.rgb_to_hsl(*color.export())) - elif isinstance(color,(RGBA,HEXA)): - return HSL(*CTC.rgb_to_hsl(*color.export()[:-1])) - elif isinstance(color, HSV): - return HSL(*CTC.hsv_to_hsl(*color.export())) - elif isinstance(color, HSL): - return HSL(*color.export()) - elif isinstance(color, CMYK): - return HSL(*CTC.cmyk_to_hsl(*color.export())) - else: + try: + return HSL(*color_conversions_mapped[HSL][type(color)](color)) + except KeyError: return NotImplemented # ---------------------------------------------------------------------------------------------------------------------- @@ -110,17 +75,9 @@ def to_CMYK(color:ColorSystem|RGB|HEX|CMYK|HSL|HSV|RGBA|HEXA) -> CMYK: """ Function which converts any Color Object to an CMYK object. """ - if isinstance(color, (RGB,HEX)): - return CMYK(*CTC.rgb_to_cmyk(*color.export())) - elif isinstance(color,(RGBA,HEXA)): - return CMYK(*CTC.rgb_to_cmyk(*color.export()[:-1])) - elif isinstance(color, HSV): - return CMYK(*CTC.hsv_to_cmyk(*color.export())) - elif isinstance(color, HSL): - return CMYK(*CTC.hsl_to_cmyk(*color.export())) - elif isinstance(color, CMYK): - return CMYK(*color.export()) - else: + try: + return CMYK(*color_conversions_mapped[CMYK][type(color)](color)) + except KeyError: return NotImplemented # ---------------------------------------------------------------------------------------------------------------------- @@ -130,38 +87,16 @@ def to_RGBA(color:ColorSystem|RGB|HEX|CMYK|HSL|HSV|RGBA|HEXA) -> RGBA: """ Function which converts any Color Object to an RGBA object. """ - if isinstance(color, RGBA): - return RGBA(*color.export()) - elif isinstance(color, HEXA): - return RGBA(*CTC.hexa_to_rgba(str(color))) - # below conversions will set the A part of RGBA to 1 - elif isinstance(color, (RGB,HEX)): - return RGBA(*color.export(), a=init.transparentDefault[1]) - elif isinstance(color, HSV): - return RGBA(*CTC.hsv_to_rgb(*color.export()), a=init.transparentDefault[1]) - elif isinstance(color, HSL): - return RGBA(*CTC.hsl_to_rgb(*color.export()), a=init.transparentDefault[1]) - elif isinstance(color, CMYK): - return RGBA(*CTC.cmyk_to_rgb(*color.export()), a=init.transparentDefault[1]) - else: + try: + return RGBA(*color_conversions_mapped[RGBA][type(color)](color)) + except KeyError: return NotImplemented def to_HEXA(color:ColorSystem|RGB|HEX|CMYK|HSL|HSV|RGBA|HEXA) -> HEXA: """ Function which converts any Color Object to an HEXA object. """ - if isinstance(color, RGBA): - return HEXA(CTC.rgba_to_hexa(*color.export())) - elif isinstance(color, HEXA): - return HEXA(str(color)) - # below conversions will set the A part of HEXA to ff - elif isinstance(color, (RGB,HEX)): - return HEXA(CTC.rgb_to_hex(*color.export()) + init.transparentDefault[0]) - elif isinstance(color, HSV): - return HEXA(CTC.hsv_to_hex(*color.export()) + init.transparentDefault[0]) - elif isinstance(color, HSL): - return HEXA(CTC.hsl_to_hex(*color.export()) + init.transparentDefault[0]) - elif isinstance(color, CMYK): - return HEXA(CTC.cmyk_to_hex(*color.export()) + init.transparentDefault[0]) - else: + try: + return HEXA(CTC.rgba_to_hexa(*color_conversions_mapped[HEXA][type(color)](color))) + except KeyError: return NotImplemented \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index a494916..b88946e 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -12,7 +12,6 @@ from AthenaColor.Objects.Color.ColorTupleConversion import * from AthenaColor.InitClass import init from AthenaColor.Functions.Constraints import Constrain -from AthenaColor.Functions.General import RoundHalfUp,RoundToDecimals # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -312,7 +311,6 @@ def b(self) -> int: def b(self, value: int|float): self._b = round(Constrain(value, 255)) - @property def a(self) -> int: return self._a @@ -412,21 +410,21 @@ def h(self) -> int|float: return self._h @h.setter def h(self, value: int|float): - self._h = RoundToDecimals(Constrain(value, 360)) + self._h = round(Constrain(value, 360), init.decimalPlaces) @property def s(self) -> int|float: return self._s @s.setter def s(self, value: int|float): - self._s = RoundToDecimals(Constrain(value, 1)) + self._s = round(Constrain(value, 1), init.decimalPlaces) @property def v(self) -> int|float: return self._v @v.setter def v(self, value: int|float): - self._v = RoundToDecimals(Constrain(value, 1)) + self._v = round(Constrain(value, 1), init.decimalPlaces) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -464,21 +462,21 @@ def h(self) -> int|float: return self._h @h.setter def h(self, value: int|float): - self._h = RoundToDecimals(Constrain(value, 360)) + self._h = round(Constrain(value, 360), init.decimalPlaces) @property def s(self) -> int|float: return self._s @s.setter def s(self, value: int|float): - self._s = RoundToDecimals(Constrain(value, 1)) + self._s = round(Constrain(value, 1), init.decimalPlaces) @property def l(self) -> int|float: return self._l @l.setter def l(self, value: int|float): - self._l = RoundToDecimals(Constrain(value, 1)) + self._l = round(Constrain(value, 1), init.decimalPlaces) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -515,28 +513,28 @@ def c(self) -> int|float: return self._c @c.setter def c(self, value: int|float): - self._c = RoundToDecimals(Constrain(value, 1)) + self._c = round(Constrain(value, 1), init.decimalPlaces) @property def m(self) -> int|float: return self._m @m.setter def m(self, value: int|float): - self._m = RoundToDecimals(Constrain(value, 1)) + self._m = round(Constrain(value, 1), init.decimalPlaces) @property def y(self) -> int|float: return self._y @y.setter def y(self, value: int|float): - self._y = RoundToDecimals(Constrain(value, 1)) + self._y = round(Constrain(value, 1), init.decimalPlaces) @property def k(self) -> int|float: return self._k @k.setter def k(self, value: int|float): - self._k = RoundToDecimals(Constrain(value, 1)) + self._k = round(Constrain(value, 1), init.decimalPlaces) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods From 544c5037364a0774ec2a160487475fef12ffe6b5 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 15:15:54 +0200 Subject: [PATCH 39/40] Change: Removed rounds from Color Systems which did not need it --- Tests/ColorObjects/test_Dunders.py | 18 ++--- Tests/ColorObjects/test_HSL.py | 84 ++++++++++---------- Tests/ColorObjects/test_HSV.py | 84 ++++++++++---------- Tests/SpeedTest.py | 6 +- src/AthenaColor/Objects/Color/ColorSystem.py | 20 ++--- 5 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Tests/ColorObjects/test_Dunders.py b/Tests/ColorObjects/test_Dunders.py index b8b6b46..4394a2e 100644 --- a/Tests/ColorObjects/test_Dunders.py +++ b/Tests/ColorObjects/test_Dunders.py @@ -96,9 +96,9 @@ def test_HSV(self): (bool, (), {}, (0,0,0), {}, False), (bool, (), {}, (0,0,1), {}, True), (divmod, (8,), {}, (180,.5,.5), {}, (HSV(h=22,s=0.0,v=0.0), HSV(h=4,s=0.5,v=0.5))), - (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), - (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSV(h=9,s=0.0,v=1), HSV(h=0,s=0.5,v=0.004))), - (divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.025,v=0.02))), + (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.024999999999999974,v=0.01999999999999999))), + (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSV(h=9,s=0.0,v=1), HSV(h=0,s=0.5,v=0.0040000000000000036))), + (divmod, (HSV(8,.025,.02),), {}, (180,.5,.5), {}, (HSV(h=22,s=1,v=1), HSV(h=4,s=0.024999999999999974,v=0.01999999999999999))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -113,9 +113,9 @@ def test_HSL(self): (bool, (), {}, (0,0,0), {}, False), (bool, (), {}, (0,0,1), {}, True), (divmod, (8,), {}, (180,.5,.5), {}, (HSL(h=22,s=0.0,l=0.0), HSL(h=4,s=0.5,l=0.5))), - (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), - (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSL(h=9,s=0.0,l=1), HSL(h=0,s=0.5,l=0.02))), - (divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.025,l=0.02))), + (divmod, ((8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.024999999999999974,l=0.01999999999999999))), + (divmod, (RGB(8,4,2),), {}, (180,.5,.5), {}, (HSL(h=9,s=0.0,l=1), HSL(h=0,s=0.5,l=0.01999999999999999))), + (divmod, (HSL(8,.025,.02),), {}, (180,.5,.5), {}, (HSL(h=22,s=1,l=1), HSL(h=4,s=0.024999999999999974,l=0.01999999999999999))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) @@ -128,11 +128,11 @@ def test_CMYK(self): (round, (), {}, (.5,.5,.5,.5), {}, CMYK(0,0,0,0)), (round, (5,), {}, (.123456,.123456,.123456,.123456), {}, CMYK(.12346,.12346,.12346,.12346)), (divmod, ((8,4,2,5),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))), - (divmod, ((.8,.4,.2,.5),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1.0,y=1,k=1.0), CMYK(c=0.5,m=0.1,y=0.1,k=0.0))), + (divmod, ((.8,.4,.2,.5),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1.0,y=1,k=1.0), CMYK(c=0.5,m=0.09999999999999998,y=0.09999999999999998,k=0.0))), (bool, (), {}, (0,0,0,0), {}, False), (bool, (), {}, (0,0,0,1), {}, True), (divmod, (8,), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=0.0,y=0.0,k=0.0), CMYK(c=0.5,m=0.5,y=0.5,k=0.5))), - (divmod, ((8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), - (divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.025,y=0.02,k=0.01))), + (divmod, ((8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.024999999999999974,y=0.01999999999999999,k=0.00999999999999999))), + (divmod, (CMYK(8,.025,.02, 0.01),), {}, (.5,.5,.5,.5), {}, (CMYK(c=0.0,m=1,y=1,k=1), CMYK(c=0.5,m=0.024999999999999974,y=0.01999999999999999,k=0.00999999999999999))), ) self.Subtest_ObjectOperationBulk(objectType, casesOperation) \ No newline at end of file diff --git a/Tests/ColorObjects/test_HSL.py b/Tests/ColorObjects/test_HSL.py index 785c7c4..7c352c8 100644 --- a/Tests/ColorObjects/test_HSL.py +++ b/Tests/ColorObjects/test_HSL.py @@ -44,31 +44,31 @@ def test_dunder_tuples(self): # math self.assertEqual( - color + (.25,.25,.25), + round(color + (.25,.25,.25),init.decimalPlaces), HSL(60.25,0.75,1.0) ) self.assertEqual( - color - (.25,.5,0.75), + round(color - (.25,.5,0.75),init.decimalPlaces), HSL(59.75,0.0,0.0) ) self.assertEqual( - color * (.1,.5,0.75), + round(color * (.1,.5,0.75),init.decimalPlaces), HSL(6.0,0.25,0.562) ) self.assertEqual( - color / (.1,.5,0.75), + round(color / (.1,.5,0.75),init.decimalPlaces), HSL(360,1.0,1.0) ) self.assertEqual( - color // (.1,.5,0.75), + round(color // (.1,.5,0.75),init.decimalPlaces), HSL(360,1.0,1.0) ) self.assertEqual( - color ** (.1,.5,0.75), + round(color ** (.1,.5,0.75),init.decimalPlaces), HSL(1.506,0.707,0.806) ) self.assertEqual( - color % (.1,.5,0.75), + round(color % (.1,.5,0.75),init.decimalPlaces), HSL(0.1, 0.0, 0.0) ) @@ -85,31 +85,31 @@ def test_dunder_RGB(self): # math self.assertEqual( - color + RGB(32, 64, 128), + round(color + RGB(32, 64, 128),init.decimalPlaces), HSL(280.0,1,1) ) self.assertEqual( - color - RGB(32, 64, 128), + round(color - RGB(32, 64, 128),init.decimalPlaces), HSL(0,0,0.436) ) self.assertEqual( - color * RGB(4, 3, 2), + round(color * RGB(4, 3, 2),init.decimalPlaces), HSL(360,0.167,0.009) ) self.assertEqual( - color / RGB(4, 3, 2), + round(color / RGB(4, 3, 2),init.decimalPlaces), HSL(2.0,1,1) ) self.assertEqual( - color // RGB(9, 7, 5), + round(color // RGB(9, 7, 5),init.decimalPlaces), HSL(2.0,1.0,1) ) self.assertEqual( - color ** RGB(2, 2, 1), + round(color ** RGB(2, 2, 1),init.decimalPlaces), HSL(360, 0.794, 0.998) ) self.assertEqual( - color % RGB(9, 7, 5), + round(color % RGB(9, 7, 5),init.decimalPlaces), HSL(0.0, 0.214, 0.021) ) @@ -125,31 +125,31 @@ def test_dunder_HEX(self): # math self.assertEqual( - color + HEX("#204080"), + round(color + HEX("#204080"),init.decimalPlaces), HSL(280.0, 1, 1) ) self.assertEqual( - color - HEX("#204080"), + round(color - HEX("#204080"),init.decimalPlaces), HSL(0, 0, 0.436) ) self.assertEqual( - color * HEX("#040302"), + round(color * HEX("#040302"),init.decimalPlaces), HSL(360, 0.167, 0.009) ) self.assertEqual( - color / HEX("#040302"), + round(color / HEX("#040302"),init.decimalPlaces), HSL(2.0, 1, 1) ) self.assertEqual( - color // HEX("#090705"), + round(color // HEX("#090705"),init.decimalPlaces), HSL(2.0, 1.0, 1) ) self.assertEqual( - color ** HEX("#020201"), + round(color ** HEX("#020201"),init.decimalPlaces), HSL(360, 0.794, 0.998) ) self.assertEqual( - color % HEX("#090705"), + round(color % HEX("#090705"),init.decimalPlaces), HSL(0.0, 0.214, 0.021) ) @@ -165,31 +165,31 @@ def test_dunder_HSL(self): # math self.assertEqual( - color + HSL(.25,.25,.25), + round(color + HSL(.25,.25,.25),init.decimalPlaces), HSL(60.25,0.75,1.0) ) self.assertEqual( - color - HSL(.25,.5,0.75), + round(color - HSL(.25,.5,0.75),init.decimalPlaces), HSL(59.75,0.0,0.0) ) self.assertEqual( - color * HSL(.1,.5,0.75), + round(color * HSL(.1,.5,0.75),init.decimalPlaces), HSL(6.0,0.25,0.562) ) self.assertEqual( - color / HSL(.1,.5,0.75), + round(color / HSL(.1,.5,0.75),init.decimalPlaces), HSL(360,1.0,1.0) ) self.assertEqual( - color // HSL(.1,.5,0.75), + round(color // HSL(.1,.5,0.75),init.decimalPlaces), HSL(360,1.0,1.0) ) self.assertEqual( - color ** HSL(.1,.5,0.75), + round(color ** HSL(.1,.5,0.75),init.decimalPlaces), HSL(1.506,0.707,0.806) ) self.assertEqual( - color % HSL(.1,.5,0.75), + round(color % HSL(.1,.5,0.75),init.decimalPlaces), HSL(0.1, 0.0, 0.0) ) @@ -205,31 +205,31 @@ def test_dunder_HSV(self): # math self.assertEqual( - color + HSV(.25, .25, .25), + round(color + HSV(.25, .25, .25),init.decimalPlaces), HSL(60.0,0.643,0.97) ) self.assertEqual( - color - HSV(.25, .5, 0.75), + round(color - HSV(.25, .5, 0.75),init.decimalPlaces), HSL(60.0,0.074,0.187) ) self.assertEqual( - color * HSV(.1, .5, 0.75), + round(color * HSV(.1, .5, 0.75),init.decimalPlaces), HSL(0.0,0.213,0.422) ) self.assertEqual( - color / HSV(30, .5, 0.75), + round(color / HSV(30, .5, 0.75),init.decimalPlaces), HSL(2,1,1) ) self.assertEqual( - color // HSV(30, .5, 0.75), + round(color // HSV(30, .5, 0.75),init.decimalPlaces), HSL(2.0,1.0,1.0) ) self.assertEqual( - color ** HSV(.1, .5, 0.75), + round(color ** HSV(.1, .5, 0.75),init.decimalPlaces), HSL(1.0, 0.744, 0.85) ) self.assertEqual( - color % HSV(30, .5, 0.75), + round(color % HSV(30, .5, 0.75),init.decimalPlaces), HSL(0,0.074,0.187) ) @@ -245,30 +245,30 @@ def test_dunder_CMYK(self): # math self.assertEqual( - color + CMYK(.9,.9,.75,.1), + round(color + CMYK(.9,.9,.75,.1),init.decimalPlaces), HSL(300.0,0.925,0.907) ) self.assertEqual( - color - CMYK(.9,.9,.75,.1), + round(color - CMYK(.9,.9,.75,.1),init.decimalPlaces), HSL(0,0.075,0.593) ) self.assertEqual( - color * CMYK(.9,.9,.75,.9), + round(color * CMYK(.9,.9,.75,.9),init.decimalPlaces), HSL(360,0.167,0.013) ) self.assertEqual( - color / CMYK(.9,.9,.75,.9), + round(color / CMYK(.9,.9,.75,.9),init.decimalPlaces), HSL(0.25,1,1) ) self.assertEqual( - color // CMYK(.9,.9,.75,.9), + round(color // CMYK(.9,.9,.75,.9),init.decimalPlaces), HSL(0.0,1.0,1) ) self.assertEqual( - color ** CMYK(.01,.1,.1,.2), + round(color ** CMYK(.01,.1,.1,.2),init.decimalPlaces), HSL(1.0,0.904,0.804) ) self.assertEqual( - color % CMYK(0.75,0.25,0.25,0.15), + round(color % CMYK(0.75,0.25,0.25,0.15),init.decimalPlaces), HSL(60.0,0.5,0.325) ) \ No newline at end of file diff --git a/Tests/ColorObjects/test_HSV.py b/Tests/ColorObjects/test_HSV.py index 1b7abd5..9cb9782 100644 --- a/Tests/ColorObjects/test_HSV.py +++ b/Tests/ColorObjects/test_HSV.py @@ -44,31 +44,31 @@ def test_dunder_tuples(self): # math self.assertEqual( - color + (.25,.25,.25), + round(color + (.25,.25,.25),init.decimalPlaces), HSV(.5,.75,1.0) ) self.assertEqual( - color - (.25,.5,0.75), + round(color - (.25,.5,0.75),init.decimalPlaces), HSV(0.0,0.0,0.0) ) self.assertEqual( - color * (.1,.5,0.75), + round(color * (.1,.5,0.75),init.decimalPlaces), HSV(0.025,0.25,0.562) ) self.assertEqual( - color / (.1,.5,0.75), + round(color / (.1,.5,0.75),init.decimalPlaces), HSV(2.5,1.0,1.0) ) self.assertEqual( - color // (.1,.5,0.75), + round(color // (.1,.5,0.75),init.decimalPlaces), HSV(2.0,1.0,1.0) ) self.assertEqual( - color ** (.1,.5,0.75), + round(color ** (.1,.5,0.75),init.decimalPlaces), HSV(0.871,0.707,0.806) ) self.assertEqual( - color % (.1,.5,0.75), + round(color % (.1,.5,0.75),init.decimalPlaces), HSV(0.05,0.0,0.0) ) @@ -85,31 +85,31 @@ def test_dunder_RGB(self): # math self.assertEqual( - color + RGB(32, 64, 128), + round(color + RGB(32, 64, 128),init.decimalPlaces), HSV(220.25,1,1) ) self.assertEqual( - color - RGB(32, 64, 128), + round(color - RGB(32, 64, 128),init.decimalPlaces), HSV(0,0,0.248) ) self.assertEqual( - color * RGB(4, 3, 2), + round(color * RGB(4, 3, 2),init.decimalPlaces), HSV(7.5,0.25,0.012) ) self.assertEqual( - color / RGB(4, 3, 2), + round(color / RGB(4, 3, 2),init.decimalPlaces), HSV(0.008,1.0,1) ) self.assertEqual( - color // RGB(9, 7, 5), + round(color // RGB(9, 7, 5),init.decimalPlaces), HSV(0.0,1.0,1) ) self.assertEqual( - color ** RGB(2, 2, 1), + round(color ** RGB(2, 2, 1),init.decimalPlaces), HSV(0.0,0.707,0.998) ) self.assertEqual( - color % RGB(9, 7, 5), + round(color % RGB(9, 7, 5),init.decimalPlaces), HSV(0.25,0.056,0.015) ) @@ -125,31 +125,31 @@ def test_dunder_HEX(self): # math self.assertEqual( - color + HEX("#abcdef"), + round(color + HEX("#abcdef"),init.decimalPlaces), HSV(210.25,0.785,1) ) self.assertEqual( - color - HEX("#00bb55"), + round(color - HEX("#00bb55"),init.decimalPlaces), HSV(0,0,0.017) ) self.assertEqual( - color * HEX("#020302"), + round(color * HEX("#020302"),init.decimalPlaces), HSV(30.0,0.167,0.009) ) self.assertEqual( - color / HEX("#020302"), + round(color / HEX("#020302"),init.decimalPlaces), HSV(0.002,1,1) ) self.assertEqual( - color // HEX("#050709"), + round(color // HEX("#050709"),init.decimalPlaces), HSV(0.0,1.0,1) ) self.assertEqual( - color ** HEX("#020101"), + round(color ** HEX("#020101"),init.decimalPlaces), HSV(1.0,0.707,0.998) ) self.assertEqual( - color % HEX("#121664"), + round(color % HEX("#121664"),init.decimalPlaces), HSV(0.25,0.5,0.358) ) @@ -165,31 +165,31 @@ def test_dunder_HSL(self): # math self.assertEqual( - color + HSL(0.125,0.5,0.1), + round(color + HSL(0.125,0.5,0.1),init.decimalPlaces), HSV(0.25,1,0.899) ) self.assertEqual( - color - HSL(0.125,0.5,0.1), + round(color - HSL(0.125,0.5,0.1),init.decimalPlaces), HSV(0.25,0,0.601) ) self.assertEqual( - color * HSL(0,0,0.01), + round(color * HSL(0,0,0.01),init.decimalPlaces), HSV(0.0,0.0,0.009) ) self.assertEqual( - color / HSL(180,1,.01), + round(color / HSL(180,1,.01),init.decimalPlaces), HSV(0.001,0.5,1) ) self.assertEqual( - color // HSL(180,1,.01), + round(color // HSL(180,1,.01),init.decimalPlaces), HSV(0.0,0.0,1) ) self.assertEqual( - color ** HSL(0,0,0.006), + round(color ** HSL(0,0,0.006),init.decimalPlaces), HSV(1.0, 1.0, 0.998) ) self.assertEqual( - color % HSL(180,0.2,0.1), + round(color % HSL(180,0.2,0.1),init.decimalPlaces), HSV(0.25,0.145,0.018) ) @@ -205,31 +205,31 @@ def test_dunder_HSV(self): # math self.assertEqual( - color + HSV(.25, .25, .25), + round(color + HSV(.25, .25, .25),init.decimalPlaces), HSV(.5, .75, 1.0) ) self.assertEqual( - color - HSV(.25, .5, 0.75), + round(color - HSV(.25, .5, 0.75),init.decimalPlaces), HSV(0.0, 0.0, 0.0) ) self.assertEqual( - color * HSV(.1, .5, 0.75), + round(color * HSV(.1, .5, 0.75),init.decimalPlaces), HSV(0.025, 0.25, 0.562) ) self.assertEqual( - color / HSV(.1, .5, 0.75), + round(color / HSV(.1, .5, 0.75),init.decimalPlaces), HSV(2.5, 1.0, 1.0) ) self.assertEqual( - color // HSV(.1, .5, 0.75), + round(color // HSV(.1, .5, 0.75),init.decimalPlaces), HSV(2.0, 1.0, 1.0) ) self.assertEqual( - color ** HSV(.1, .5, 0.75), + round(color ** HSV(.1, .5, 0.75),init.decimalPlaces), HSV(0.871, 0.707, 0.806) ) self.assertEqual( - color % HSV(.1, .5, 0.75), + round(color % HSV(.1, .5, 0.75),init.decimalPlaces), HSV(0.05, 0.0, 0.0) ) @@ -245,30 +245,30 @@ def test_dunder_CMYK(self): # math self.assertEqual( - color + CMYK(.9,.9,.75,.1), + round(color + CMYK(.9,.9,.75,.1),init.decimalPlaces), HSV(240.25,1,0.974) ) self.assertEqual( - color - CMYK(.9,.9,.75,.1), + round(color - CMYK(.9,.9,.75,.1),init.decimalPlaces), HSV(0,0,0.526) ) self.assertEqual( - color * CMYK(.9,.9,.75,.9), + round(color * CMYK(.9,.9,.75,.9),init.decimalPlaces), HSV(60.0,0.25,0.018) ) self.assertEqual( - color / CMYK(.9,.9,.75,.9), + round(color / CMYK(.9,.9,.75,.9),init.decimalPlaces), HSV(0.001,1.0,1) ) self.assertEqual( - color // CMYK(.9,.9,.75,.9), + round(color // CMYK(.9,.9,.75,.9),init.decimalPlaces), HSV(0.0,1.0,1) ) self.assertEqual( - color ** CMYK(1,0,0,0), + round(color ** CMYK(1,0,0,0),init.decimalPlaces), HSV(0.0,0.5,0.75) ) self.assertEqual( - color % CMYK(0.75,0.25,0.25,0.15), + round(color % CMYK(0.75,0.25,0.25,0.15),init.decimalPlaces), HSV(0.25,0.5,0.111) ) \ No newline at end of file diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py index 8181a02..541ad8d 100644 --- a/Tests/SpeedTest.py +++ b/Tests/SpeedTest.py @@ -50,10 +50,10 @@ def ObjectCreation(): RGB(255, 255, 255) if __name__ == '__main__': - # print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") - # print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") + print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") + print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") # print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") # print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") # print(f"TextNestedBig:{ForeNest.Red(timeit.repeat(lambda: TextNestedBig(), number=1_000_000, repeat=5))}") - print(f"ObjectCreation:{ForeNest.Red(timeit.repeat(lambda: ObjectCreation(), number=1_000_000, repeat=5))}") + # print(f"ObjectCreation:{ForeNest.Red(timeit.repeat(lambda: ObjectCreation(), number=1_000_000, repeat=5))}") diff --git a/src/AthenaColor/Objects/Color/ColorSystem.py b/src/AthenaColor/Objects/Color/ColorSystem.py index b88946e..d9ad303 100644 --- a/src/AthenaColor/Objects/Color/ColorSystem.py +++ b/src/AthenaColor/Objects/Color/ColorSystem.py @@ -410,21 +410,21 @@ def h(self) -> int|float: return self._h @h.setter def h(self, value: int|float): - self._h = round(Constrain(value, 360), init.decimalPlaces) + self._h = Constrain(value, 360) @property def s(self) -> int|float: return self._s @s.setter def s(self, value: int|float): - self._s = round(Constrain(value, 1), init.decimalPlaces) + self._s = Constrain(value, 1) @property def v(self) -> int|float: return self._v @v.setter def v(self, value: int|float): - self._v = round(Constrain(value, 1), init.decimalPlaces) + self._v = Constrain(value, 1) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -462,21 +462,21 @@ def h(self) -> int|float: return self._h @h.setter def h(self, value: int|float): - self._h = round(Constrain(value, 360), init.decimalPlaces) + self._h = Constrain(value, 360) @property def s(self) -> int|float: return self._s @s.setter def s(self, value: int|float): - self._s = round(Constrain(value, 1), init.decimalPlaces) + self._s = Constrain(value, 1) @property def l(self) -> int|float: return self._l @l.setter def l(self, value: int|float): - self._l = round(Constrain(value, 1), init.decimalPlaces) + self._l = Constrain(value, 1) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -513,28 +513,28 @@ def c(self) -> int|float: return self._c @c.setter def c(self, value: int|float): - self._c = round(Constrain(value, 1), init.decimalPlaces) + self._c = Constrain(value, 1) @property def m(self) -> int|float: return self._m @m.setter def m(self, value: int|float): - self._m = round(Constrain(value, 1), init.decimalPlaces) + self._m = Constrain(value, 1) @property def y(self) -> int|float: return self._y @y.setter def y(self, value: int|float): - self._y = round(Constrain(value, 1), init.decimalPlaces) + self._y = Constrain(value, 1) @property def k(self) -> int|float: return self._k @k.setter def k(self, value: int|float): - self._k = round(Constrain(value, 1), init.decimalPlaces) + self._k = Constrain(value, 1) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods From 720ef79f8f77b60d0b91ed494e9380dee79473e0 Mon Sep 17 00:00:00 2001 From: DirectiveAthena Date: Sat, 7 May 2022 15:54:23 +0200 Subject: [PATCH 40/40] Change: Final Cleanup --- Tests/Functions/test_General.py | 10 ---------- Tests/SpeedTest.py | 8 ++++---- setup.py | 2 +- src/AthenaColor/Functions/ANSIsquences.py | 2 -- src/AthenaColor/Functions/General.py | 5 +---- src/AthenaColor/Objects/Color/ColorTupleConversion.py | 4 ++-- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Tests/Functions/test_General.py b/Tests/Functions/test_General.py index f1e5846..2e1c32d 100644 --- a/Tests/Functions/test_General.py +++ b/Tests/Functions/test_General.py @@ -15,16 +15,6 @@ # - Code - # ---------------------------------------------------------------------------------------------------------------------- class Functions_General(unittest.TestCase): - def test_Normalize(self): - for i in range(1,100): - with self.subTest(i=i): - self.assertEqual(Normalize(i), i/100) - - def test_Normalize_Factor(self): - for i, f in zip(range(1,100),range(100,200)): - with self.subTest(i=i): - self.assertEqual(Normalize(i, factor=f), i/f) - def test_RoundToDecimals(self): for i, f in zip(range(1,24),range(24,56)): with self.subTest(i=i, f=f): diff --git a/Tests/SpeedTest.py b/Tests/SpeedTest.py index 541ad8d..0ce9037 100644 --- a/Tests/SpeedTest.py +++ b/Tests/SpeedTest.py @@ -52,8 +52,8 @@ def ObjectCreation(): if __name__ == '__main__': print(f"Conversion:{ForeNest.Red(timeit.repeat(lambda: Conversion(), number=1_000_000, repeat=5))}") print(f"ConversionInline:{ForeNest.Red(timeit.repeat(lambda: ConversionInline(), number=1_000_000, repeat=5))}") - # print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") - # print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") - # print(f"TextNestedBig:{ForeNest.Red(timeit.repeat(lambda: TextNestedBig(), number=1_000_000, repeat=5))}") - # print(f"ObjectCreation:{ForeNest.Red(timeit.repeat(lambda: ObjectCreation(), number=1_000_000, repeat=5))}") + print(f"TextInline:{ForeNest.Red(timeit.repeat(lambda: TextInline(), number=1_000_000, repeat=5))}") + print(f"TextNested:{ForeNest.Red(timeit.repeat(lambda: TextNested(), number=1_000_000, repeat=5))}") + print(f"TextNestedBig:{ForeNest.Red(timeit.repeat(lambda: TextNestedBig(), number=1_000_000, repeat=5))}") + print(f"ObjectCreation:{ForeNest.Red(timeit.repeat(lambda: ObjectCreation(), number=1_000_000, repeat=5))}") diff --git a/setup.py b/setup.py index 8a9fc4b..205d2c2 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setuptools.setup( name="AthenaColor", - version="4.0.1", + version="4.1.0", author="Andreas Sas", author_email="", description="Package to support full usage of RGB colors in the Console.", diff --git a/src/AthenaColor/Functions/ANSIsquences.py b/src/AthenaColor/Functions/ANSIsquences.py index a585bef..645504a 100644 --- a/src/AthenaColor/Functions/ANSIsquences.py +++ b/src/AthenaColor/Functions/ANSIsquences.py @@ -19,8 +19,6 @@ # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- - - def ColorSequence(control_code:int|str)->str: """ Used for quick assembly of correct Ansi Escape functions diff --git a/src/AthenaColor/Functions/General.py b/src/AthenaColor/Functions/General.py index 4520dd8..b54f09a 100644 --- a/src/AthenaColor/Functions/General.py +++ b/src/AthenaColor/Functions/General.py @@ -13,15 +13,12 @@ # - All - # ---------------------------------------------------------------------------------------------------------------------- __all__ = [ - "Normalize", "RoundHalfUp","RoundToDecimals" + "RoundHalfUp","RoundToDecimals" ] # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- -def Normalize(value:int|float, factor:int|float=100)->float: - return value/factor - def RoundToDecimals(value:int|float, decimals:int=init.decimalPlaces): return round(value, decimals) diff --git a/src/AthenaColor/Objects/Color/ColorTupleConversion.py b/src/AthenaColor/Objects/Color/ColorTupleConversion.py index 10faf08..3252038 100644 --- a/src/AthenaColor/Objects/Color/ColorTupleConversion.py +++ b/src/AthenaColor/Objects/Color/ColorTupleConversion.py @@ -10,7 +10,7 @@ # Custom Packages from AthenaColor.Functions.General import ( - Normalize,RoundHalfUp,RoundToDecimals + RoundHalfUp,RoundToDecimals ) from AthenaColor.Functions.Constraints import ( ConstrainHSV, ConstrainHSL, ConstrainRGB, ConstrainCMYK,ConstrainRGBA @@ -29,7 +29,7 @@ # - Support Code - # ---------------------------------------------------------------------------------------------------------------------- def NormalizeRgb(r:int,g:int,b:int) -> Tuple[float, ...]: - return Normalize(r,255),Normalize(g,255),Normalize(b,255) + return r/255,g/255,b/255 numbers = (int,float)