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_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 new file mode 100644 index 0000000..4394a2e --- /dev/null +++ b/Tests/ColorObjects/test_Dunders.py @@ -0,0 +1,138 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - Package Imports - +# ---------------------------------------------------------------------------------------------------------------------- +# General Packages +from __future__ import annotations +import copy +import operator + +# 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 + (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))), + (sum, (), {}, (127,127,127), {}, 381), + (max, (), {}, (52,128,255), {}, 255), + (min, (), {}, (52,128,255), {}, 52), + (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) + + 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 + (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 + (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 + (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)), + (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.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) + + 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)), + (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.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) + + 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)), + (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.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.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_HEX.py b/Tests/ColorObjects/test_HEX.py index c1ec73b..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") @@ -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/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/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/Tests/Functions/test_ANSIsequences.py b/Tests/Functions/test_ANSIsequences.py index 85df8ec..3cdd5af 100644 --- a/Tests/Functions/test_ANSIsequences.py +++ b/Tests/Functions/test_ANSIsequences.py @@ -18,11 +18,11 @@ 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, + color_code="\033[38;2;128;0;0m", + reset_code="\033[0m", sep="\n" ) @@ -36,102 +36,33 @@ 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( # 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, + color_code="\033[38;2;128;0;0m", + reset_code="\033[0m", 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( # 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, + color_code="\033[38;2;128;0;0m", + reset_code="\033[0m", 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/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 d2e1d12..2e1c32d 100644 --- a/Tests/Functions/test_General.py +++ b/Tests/Functions/test_General.py @@ -15,22 +15,10 @@ # - 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 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): @@ -54,10 +42,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/Tests/SpeedTest.py b/Tests/SpeedTest.py new file mode 100644 index 0000000..0ce9037 --- /dev/null +++ b/Tests/SpeedTest.py @@ -0,0 +1,59 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - 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) + +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.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 + +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"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/Data/HtmlColors.py b/src/AthenaColor/Data/HtmlColors.py index 597700c..b040055 100644 --- a/src/AthenaColor/Data/HtmlColors.py +++ b/src/AthenaColor/Data/HtmlColors.py @@ -12,284 +12,143 @@ # ---------------------------------------------------------------------------------------------------------------------- # - 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 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/Functions/ANSIsquences.py b/src/AthenaColor/Functions/ANSIsquences.py index 564499f..645504a 100644 --- a/src/AthenaColor/Functions/ANSIsquences.py +++ b/src/AthenaColor/Functions/ANSIsquences.py @@ -8,14 +8,12 @@ # Custom Packages from AthenaColor.InitClass import init -from AthenaColor.Data.General import ConsoleCodes -from AthenaColor.Functions.General import StrictType # ---------------------------------------------------------------------------------------------------------------------- # - All - # ---------------------------------------------------------------------------------------------------------------------- __all__ = [ - "ColorSequence", "NestedColorSequence" + "ColorSequence", "NestedColorSequence","NestedColorSequence_NoReset" ] # ---------------------------------------------------------------------------------------------------------------------- @@ -26,16 +24,30 @@ 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: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. 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) - 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_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, 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. + This is made to prevent style makeup bleed + """ + + # SHHH, don't touch this, this is speed 101 + text = "" + for o in obj[:-1]: + 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/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/DunderFunctions.py b/src/AthenaColor/Functions/DunderFunctions.py index 622b8ff..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,82 +21,46 @@ # - 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) # ---------------------------------------------------------------------------------------------------------------------- # - 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/Functions/General.py b/src/AthenaColor/Functions/General.py index 5426a47..b54f09a 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 @@ -14,24 +13,14 @@ # - All - # ---------------------------------------------------------------------------------------------------------------------- __all__ = [ - "Normalize", "RoundHalfUp","RoundToDecimals", "StrictType" + "RoundHalfUp","RoundToDecimals" ] # ---------------------------------------------------------------------------------------------------------------------- # - Code - # ---------------------------------------------------------------------------------------------------------------------- -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 - 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/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/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 16e2161..d9ad303 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 @@ -12,8 +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 -from AthenaColor.Functions.General import StrictType # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -25,81 +23,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: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.transparent_default_float - elif isinstance(right,HSL): - return hsl_to_rgb(*right.export()), init.transparent_default_float - elif isinstance(right,HSV): - return hsv_to_rgb(*right.export()), init.transparent_default_float - elif isinstance(right,CMYK): - return cmyk_to_rgb(*right.export()), init.transparent_default_float - elif isinstance(right, (RGBA,HEXA)): - return right.export() - - # If nothing has matched, this will return -> - return NotImplemented +def _ColorConversionInput(fnc): + def wrapper(self,other:ColorSystem|int|tuple): + try: + return fnc(self, color_conversions_mapped[type(self)][type(other)](other)) + except KeyError: + return NotImplemented + return wrapper # ---------------------------------------------------------------------------------------------------------------------- # - Actual Color System - @@ -111,178 +41,124 @@ 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.export()) + 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):... + + def average(self) -> float: + values = self.export() + return sum(values)/len(values) + + def __bool__(self) -> bool: + return any(color!=0 for color in self) + + def __round__(self, n=None) -> ColorSystem: + return self.__class__(*(round(value,n) for value in self)) + + def __iter__(self): + return iter(self.export()) + + def __hash__(self): + return hash(self.export()) + + def __copy__(self): + return eval(repr(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 - # ------------------------------------------------------------------------------------------------------------------ - # 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: - return result - return type(self)(*result) - - # 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 - return type(self)(*result) - - # 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 - return type(self)(*result) - - # 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 - return type(self)(*result) - - # 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 - return type(self)(*result) - - # 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 - return type(self)(*result) - - # 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 - return type(self)(*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:... + # ! 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. + + @ _ColorConversionInput + def __add__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(*CSD.add(self.export(), other)) + @ _ColorConversionInput + def __sub__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(*CSD.sub(self.export(), other)) + @ _ColorConversionInput + def __mul__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(*CSD.mul(self.export(), other)) + @ _ColorConversionInput + def __floordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(*CSD.floordiv(self.export(), other)) + @ _ColorConversionInput + def __truediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(*CSD.truediv(self.export(), other)) + @ _ColorConversionInput + def __mod__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(*CSD.mod(self.export(), other)) + @ _ColorConversionInput + def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(*CSD.power(self.export(), other)) + + @ _ColorConversionInput + def __iadd__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.add(self.export(), other)) + @ _ColorConversionInput + def __isub__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.sub(self.export(), other)) + @ _ColorConversionInput + def __imul__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.mul(self.export(), other)) + @ _ColorConversionInput + def __ifloordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.floordiv(self.export(), other)) + @ _ColorConversionInput + def __itruediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.truediv(self.export(), other)) + @ _ColorConversionInput + def __itruediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.truediv(self.export(), other)) + @ _ColorConversionInput + def __imod__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.mod(self.export(), other)) + @ _ColorConversionInput + def __ipow__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self._value_setter(CSD.power(self.export(), other)) # ------------------------------------------------------------------------------------------------------------------ # - Comparison Dunders - # ------------------------------------------------------------------------------------------------------------------ - # 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) + # ! 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 tuple format as the left-hand type. - # noinspection PyTypeChecker + @ _ColorConversionInput + def __gt__(self, other: ColorSystem|int|float|tuple) -> bool: + return CSD.gt(self.export(), other) + @ _ColorConversionInput 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 + return CSD.lt(self.export(), other) + @ _ColorConversionInput 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 + return CSD.eq(self.export(), other) + @ _ColorConversionInput 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 + return CSD.ne(self.export(), other) + @ _ColorConversionInput 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 + return CSD.le(self.export(), other) + @ _ColorConversionInput 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) + return CSD.ge(self.export(), other) # ------------------------------------------------------------------------------------------------------------------ # - RGB - @@ -301,6 +177,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 # ------------------------------------------------------------------------------------------------------------------ @@ -309,30 +188,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 = 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 = 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 = round(Constrain(value, 255)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -341,49 +211,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 - # ---------------------------------------------------------------------------------------------------------------------- @@ -394,7 +221,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 @@ -404,38 +231,41 @@ 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 self.__class__(rgb_to_hex(*(round(value,n) for value in self.export()))) + + @ _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 type(self)(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))) - - # 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))) - - # 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))) - - # 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))) - - # 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))) - - # 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))) + @ _ColorConversionInput + def __add__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.add(self.export(), other))) + @ _ColorConversionInput + def __sub__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.sub(self.export(), other))) + @ _ColorConversionInput + def __mul__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.mul(self.export(), other))) + @ _ColorConversionInput + def __floordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.floordiv(self.export(), other))) + @ _ColorConversionInput + def __truediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.truediv(self.export(), other))) + @ _ColorConversionInput + def __mod__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.mod(self.export(), other))) + @ _ColorConversionInput + def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgb_to_hex(*CSD.power(self.export(), other))) # ------------------------------------------------------------------------------------------------------------------ # - RGBA - @@ -454,6 +284,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, self.a = values + # ------------------------------------------------------------------------------------------------------------------ # RGB Properties # ------------------------------------------------------------------------------------------------------------------ @@ -462,40 +295,28 @@ 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 = 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 = 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 = 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 = round(Constrain(value, 255)) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods # ------------------------------------------------------------------------------------------------------------------ @@ -503,49 +324,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 - @@ -567,39 +345,41 @@ 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 self.__class__(rgba_to_hexa(*(round(value,n) for value in self.export()))) + + @ _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 type(self)(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))) - - # 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))) - - # 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))) - - # 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))) - - # 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))) - - # 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))) + @ _ColorConversionInput + def __add__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.add(self.export(), other))) + @ _ColorConversionInput + def __sub__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.sub(self.export(), other))) + @ _ColorConversionInput + def __mul__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.mul(self.export(), other))) + @ _ColorConversionInput + def __floordiv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.floordiv(self.export(), other))) + @ _ColorConversionInput + def __truediv__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.truediv(self.export(), other))) + @ _ColorConversionInput + def __mod__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.mod(self.export(), other))) + @ _ColorConversionInput + def __pow__(self, other: ColorSystem|int|tuple) -> ColorSystem: + return self.__class__(rgba_to_hexa(*CSD.power(self.export(), other))) # ------------------------------------------------------------------------------------------------------------------ # - HSV - @@ -619,6 +399,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.h,self.s,self.v = values + # ------------------------------------------------------------------------------------------------------------------ # RGB Properties # ------------------------------------------------------------------------------------------------------------------ @@ -627,21 +410,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 = 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 = 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 = Constrain(value, 1) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -650,51 +433,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 - # ------------------------------------------------------------------------------------------------------------------ @@ -713,6 +451,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.h,self.s,self.l = values + # ------------------------------------------------------------------------------------------------------------------ # RGB Properties # ------------------------------------------------------------------------------------------------------------------ @@ -721,21 +462,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 = 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 = 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 = Constrain(value, 1) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -744,50 +485,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 - # ---------------------------------------------------------------------------------------------------------------------- @@ -805,6 +502,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.c,self.m,self.y,self.k = values + # ------------------------------------------------------------------------------------------------------------------ # CMYK Properties # ------------------------------------------------------------------------------------------------------------------ @@ -813,28 +513,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 = 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 = 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 = 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 = Constrain(value, 1) # ------------------------------------------------------------------------------------------------------------------ # MAGIC Methods @@ -843,45 +543,98 @@ 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})" - 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 +# 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_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 +trnspDef = init.transparentDefault[1] +color_conversions_mapped ={ + RGB : { + RGB: _r_export, + HEX: _r_export, + 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 + }, + HEX : { + RGB: _r_export, + HEX: _r_export, + 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.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.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.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.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.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.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.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, + float: _tuple4, + tuple: _same + }, + HEXA : { + 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, + float: _tuple4, + tuple: _same + }, +} \ No newline at end of file diff --git a/src/AthenaColor/Objects/Color/ColorTupleConversion.py b/src/AthenaColor/Objects/Color/ColorTupleConversion.py index 67783cd..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, StrictType + RoundHalfUp,RoundToDecimals ) from AthenaColor.Functions.Constraints import ( ConstrainHSV, ConstrainHSL, ConstrainRGB, ConstrainCMYK,ConstrainRGBA @@ -22,14 +22,14 @@ __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" ] # ---------------------------------------------------------------------------------------------------------------------- # - 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) @@ -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 new file mode 100644 index 0000000..861bf99 --- /dev/null +++ b/src/AthenaColor/Objects/Console/Styling/Nested/BackNest.py @@ -0,0 +1,333 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - 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.Objects.Console.Styling.Inline.Bodies import Back +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style + +# ---------------------------------------------------------------------------------------------------------------------- +# - All - +# ---------------------------------------------------------------------------------------------------------------------- +__all__=[ + "BackNest" +] + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase +sep_=" " + +class BackNest: + # ------------------------------------------------------------------------------------------------------------------ + # - Methods - + # ------------------------------------------------------------------------------------------------------------------ + @staticmethod + 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(*color.export())}m", + Style.NoForeground, + sep=sep + ) + + @staticmethod + 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 ';' + return NestedColorSequence( + obj, + f"\033[48;2;{';'.join(*NormalizeRgb(r, g, b))}m", + Style.NoForeground, + sep=sep + ) + + # ------------------------------------------------------------------------------------------------------------------ + # - HTML colors - + # ------------------------------------------------------------------------------------------------------------------ + # No partial methods, as this was increase the speed impact 2-fold + @staticmethod + def Maroon(*obj, sep=sep_): return NCS(obj,Back.Maroon,Style.NoBackground,sep) + @staticmethod + def DarkRed(*obj, sep=sep_): return NCS(obj,Back.DarkRed,Style.NoBackground,sep) + @staticmethod + def Brown(*obj, sep=sep_): return NCS(obj,Back.Brown,Style.NoBackground,sep) + @staticmethod + def Firebrick(*obj, sep=sep_): return NCS(obj,Back.Firebrick,Style.NoBackground,sep) + @staticmethod + def Crimson(*obj, sep=sep_): return NCS(obj,Back.Crimson,Style.NoBackground,sep) + @staticmethod + def Red(*obj, sep=sep_): return NCS(obj,Back.Red,Style.NoBackground,sep) + @staticmethod + def Tomato(*obj, sep=sep_): return NCS(obj,Back.Tomato,Style.NoBackground,sep) + @staticmethod + def Coral(*obj, sep=sep_): return NCS(obj,Back.Coral,Style.NoBackground,sep) + @staticmethod + def IndianRed(*obj, sep=sep_): return NCS(obj,Back.IndianRed,Style.NoBackground,sep) + @staticmethod + def LightCoral(*obj, sep=sep_): return NCS(obj,Back.LightCoral,Style.NoBackground,sep) + @staticmethod + def DarkSalmon(*obj, sep=sep_): return NCS(obj,Back.DarkSalmon,Style.NoBackground,sep) + @staticmethod + def Salmon(*obj, sep=sep_): return NCS(obj,Back.Salmon,Style.NoBackground,sep) + @staticmethod + def LightSalmon(*obj, sep=sep_): return NCS(obj,Back.LightSalmon,Style.NoBackground,sep) + @staticmethod + def OrangeRed(*obj, sep=sep_): return NCS(obj,Back.OrangeRed,Style.NoBackground,sep) + @staticmethod + def DarkOrange(*obj, sep=sep_): return NCS(obj,Back.DarkOrange,Style.NoBackground,sep) + @staticmethod + def Orange(*obj, sep=sep_): return NCS(obj,Back.Orange,Style.NoBackground,sep) + @staticmethod + def Gold(*obj, sep=sep_): return NCS(obj,Back.Gold,Style.NoBackground,sep) + @staticmethod + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,Back.DarkGoldenRod,Style.NoBackground,sep) + @staticmethod + def GoldenRod(*obj, sep=sep_): return NCS(obj,Back.GoldenRod,Style.NoBackground,sep) + @staticmethod + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,Back.PaleGoldenRod,Style.NoBackground,sep) + @staticmethod + def DarkKhaki(*obj, sep=sep_): return NCS(obj,Back.DarkKhaki,Style.NoBackground,sep) + @staticmethod + def Khaki(*obj, sep=sep_): return NCS(obj,Back.Khaki,Style.NoBackground,sep) + @staticmethod + def Olive(*obj, sep=sep_): return NCS(obj,Back.Olive,Style.NoBackground,sep) + @staticmethod + def Yellow(*obj, sep=sep_): return NCS(obj,Back.Yellow,Style.NoBackground,sep) + @staticmethod + def YellowGreen(*obj, sep=sep_): return NCS(obj,Back.YellowGreen,Style.NoBackground,sep) + @staticmethod + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,Back.DarkOliveGreen,Style.NoBackground,sep) + @staticmethod + def OliveDrab(*obj, sep=sep_): return NCS(obj,Back.OliveDrab,Style.NoBackground,sep) + @staticmethod + def LawnGreen(*obj, sep=sep_): return NCS(obj,Back.LawnGreen,Style.NoBackground,sep) + @staticmethod + def Chartreuse(*obj, sep=sep_): return NCS(obj,Back.Chartreuse,Style.NoBackground,sep) + @staticmethod + def GreenYellow(*obj, sep=sep_): return NCS(obj,Back.GreenYellow,Style.NoBackground,sep) + @staticmethod + def DarkGreen(*obj, sep=sep_): return NCS(obj,Back.DarkGreen,Style.NoBackground,sep) + @staticmethod + def Green(*obj, sep=sep_): return NCS(obj,Back.Green,Style.NoBackground,sep) + @staticmethod + def ForestGreen(*obj, sep=sep_): return NCS(obj,Back.ForestGreen,Style.NoBackground,sep) + @staticmethod + def Lime(*obj, sep=sep_): return NCS(obj,Back.Lime,Style.NoBackground,sep) + @staticmethod + def LimeGreen(*obj, sep=sep_): return NCS(obj,Back.LimeGreen,Style.NoBackground,sep) + @staticmethod + def LightGreen(*obj, sep=sep_): return NCS(obj,Back.LightGreen,Style.NoBackground,sep) + @staticmethod + def PaleGreen(*obj, sep=sep_): return NCS(obj,Back.PaleGreen,Style.NoBackground,sep) + @staticmethod + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,Back.DarkSeaGreen,Style.NoBackground,sep) + @staticmethod + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,Back.MediumSpringGreen,Style.NoBackground,sep) + @staticmethod + def SpringGreen(*obj, sep=sep_): return NCS(obj,Back.SpringGreen,Style.NoBackground,sep) + @staticmethod + def SeaGreen(*obj, sep=sep_): return NCS(obj,Back.SeaGreen,Style.NoBackground,sep) + @staticmethod + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,Back.MediumAquaMarine,Style.NoBackground,sep) + @staticmethod + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,Back.MediumSeaGreen,Style.NoBackground,sep) + @staticmethod + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,Back.LightSeaGreen,Style.NoBackground,sep) + @staticmethod + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,Back.DarkSlateGray,Style.NoBackground,sep) + @staticmethod + def Teal(*obj, sep=sep_): return NCS(obj,Back.Teal,Style.NoBackground,sep) + @staticmethod + def DarkCyan(*obj, sep=sep_): return NCS(obj,Back.DarkCyan,Style.NoBackground,sep) + @staticmethod + def Aqua(*obj, sep=sep_): return NCS(obj,Back.Aqua,Style.NoBackground,sep) + @staticmethod + def Cyan(*obj, sep=sep_): return NCS(obj,Back.Cyan,Style.NoBackground,sep) + @staticmethod + def LightCyan(*obj, sep=sep_): return NCS(obj,Back.LightCyan,Style.NoBackground,sep) + @staticmethod + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,Back.DarkTurquoise,Style.NoBackground,sep) + @staticmethod + def Turquoise(*obj, sep=sep_): return NCS(obj,Back.Turquoise,Style.NoBackground,sep) + @staticmethod + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,Back.MediumTurquoise,Style.NoBackground,sep) + @staticmethod + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,Back.PaleTurquoise,Style.NoBackground,sep) + @staticmethod + def AquaMarine(*obj, sep=sep_): return NCS(obj,Back.AquaMarine,Style.NoBackground,sep) + @staticmethod + def PowderBlue(*obj, sep=sep_): return NCS(obj,Back.PowderBlue,Style.NoBackground,sep) + @staticmethod + def CadetBlue(*obj, sep=sep_): return NCS(obj,Back.CadetBlue,Style.NoBackground,sep) + @staticmethod + def SteelBlue(*obj, sep=sep_): return NCS(obj,Back.SteelBlue,Style.NoBackground,sep) + @staticmethod + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,Back.CornFlowerBlue,Style.NoBackground,sep) + @staticmethod + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,Back.DeepSkyBlue,Style.NoBackground,sep) + @staticmethod + def DodgerBlue(*obj, sep=sep_): return NCS(obj,Back.DodgerBlue,Style.NoBackground,sep) + @staticmethod + def LightBlue(*obj, sep=sep_): return NCS(obj,Back.LightBlue,Style.NoBackground,sep) + @staticmethod + def SkyBlue(*obj, sep=sep_): return NCS(obj,Back.SkyBlue,Style.NoBackground,sep) + @staticmethod + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,Back.LightSkyBlue,Style.NoBackground,sep) + @staticmethod + def MidnightBlue(*obj, sep=sep_): return NCS(obj,Back.MidnightBlue,Style.NoBackground,sep) + @staticmethod + def Navy(*obj, sep=sep_): return NCS(obj,Back.Navy,Style.NoBackground,sep) + @staticmethod + def DarkBlue(*obj, sep=sep_): return NCS(obj,Back.DarkBlue,Style.NoBackground,sep) + @staticmethod + def MediumBlue(*obj, sep=sep_): return NCS(obj,Back.MediumBlue,Style.NoBackground,sep) + @staticmethod + def Blue(*obj, sep=sep_): return NCS(obj,Back.Blue,Style.NoBackground,sep) + @staticmethod + def RoyalBlue(*obj, sep=sep_): return NCS(obj,Back.RoyalBlue,Style.NoBackground,sep) + @staticmethod + def BlueViolet(*obj, sep=sep_): return NCS(obj,Back.BlueViolet,Style.NoBackground,sep) + @staticmethod + def Indigo(*obj, sep=sep_): return NCS(obj,Back.Indigo,Style.NoBackground,sep) + @staticmethod + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,Back.DarkSlateBlue,Style.NoBackground,sep) + @staticmethod + def SlateBlue(*obj, sep=sep_): return NCS(obj,Back.SlateBlue,Style.NoBackground,sep) + @staticmethod + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,Back.MediumSlateBlue,Style.NoBackground,sep) + @staticmethod + def MediumPurple(*obj, sep=sep_): return NCS(obj,Back.MediumPurple,Style.NoBackground,sep) + @staticmethod + def DarkMagenta(*obj, sep=sep_): return NCS(obj,Back.DarkMagenta,Style.NoBackground,sep) + @staticmethod + def DarkViolet(*obj, sep=sep_): return NCS(obj,Back.DarkViolet,Style.NoBackground,sep) + @staticmethod + def DarkOrchid(*obj, sep=sep_): return NCS(obj,Back.DarkOrchid,Style.NoBackground,sep) + @staticmethod + def MediumOrchid(*obj, sep=sep_): return NCS(obj,Back.MediumOrchid,Style.NoBackground,sep) + @staticmethod + def Purple(*obj, sep=sep_): return NCS(obj,Back.Purple,Style.NoBackground,sep) + @staticmethod + def Thistle(*obj, sep=sep_): return NCS(obj,Back.Thistle,Style.NoBackground,sep) + @staticmethod + def Plum(*obj, sep=sep_): return NCS(obj,Back.Plum,Style.NoBackground,sep) + @staticmethod + def Violet(*obj, sep=sep_): return NCS(obj,Back.Violet,Style.NoBackground,sep) + @staticmethod + def Magenta(*obj, sep=sep_): return NCS(obj,Back.Magenta,Style.NoBackground,sep) + @staticmethod + def Orchid(*obj, sep=sep_): return NCS(obj,Back.Orchid,Style.NoBackground,sep) + @staticmethod + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,Back.MediumVioletRed,Style.NoBackground,sep) + @staticmethod + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,Back.PaleVioletRed,Style.NoBackground,sep) + @staticmethod + def DeepPink(*obj, sep=sep_): return NCS(obj,Back.DeepPink,Style.NoBackground,sep) + @staticmethod + def HotPink(*obj, sep=sep_): return NCS(obj,Back.HotPink,Style.NoBackground,sep) + @staticmethod + def LightPink(*obj, sep=sep_): return NCS(obj,Back.LightPink,Style.NoBackground,sep) + @staticmethod + def Pink(*obj, sep=sep_): return NCS(obj,Back.Pink,Style.NoBackground,sep) + @staticmethod + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,Back.AntiqueWhite,Style.NoBackground,sep) + @staticmethod + def Beige(*obj, sep=sep_): return NCS(obj,Back.Beige,Style.NoBackground,sep) + @staticmethod + def Bisque(*obj, sep=sep_): return NCS(obj,Back.Bisque,Style.NoBackground,sep) + @staticmethod + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,Back.BlanchedAlmond,Style.NoBackground,sep) + @staticmethod + def Wheat(*obj, sep=sep_): return NCS(obj,Back.Wheat,Style.NoBackground,sep) + @staticmethod + def CornSilk(*obj, sep=sep_): return NCS(obj,Back.CornSilk,Style.NoBackground,sep) + @staticmethod + def LemonChiffon(*obj, sep=sep_): return NCS(obj,Back.LemonChiffon,Style.NoBackground,sep) + @staticmethod + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,Back.LightGoldenRodYellow,Style.NoBackground,sep) + @staticmethod + def LightYellow(*obj, sep=sep_): return NCS(obj,Back.LightYellow,Style.NoBackground,sep) + @staticmethod + def SaddleBrown(*obj, sep=sep_): return NCS(obj,Back.SaddleBrown,Style.NoBackground,sep) + @staticmethod + def Sienna(*obj, sep=sep_): return NCS(obj,Back.Sienna,Style.NoBackground,sep) + @staticmethod + def Chocolate(*obj, sep=sep_): return NCS(obj,Back.Chocolate,Style.NoBackground,sep) + @staticmethod + def Peru(*obj, sep=sep_): return NCS(obj,Back.Peru,Style.NoBackground,sep) + @staticmethod + def SandyBrown(*obj, sep=sep_): return NCS(obj,Back.SandyBrown,Style.NoBackground,sep) + @staticmethod + def BurlyWood(*obj, sep=sep_): return NCS(obj,Back.BurlyWood,Style.NoBackground,sep) + @staticmethod + def Tan(*obj, sep=sep_): return NCS(obj,Back.Tan,Style.NoBackground,sep) + @staticmethod + def RosyBrown(*obj, sep=sep_): return NCS(obj,Back.RosyBrown,Style.NoBackground,sep) + @staticmethod + def Moccasin(*obj, sep=sep_): return NCS(obj,Back.Moccasin,Style.NoBackground,sep) + @staticmethod + def NavajoWhite(*obj, sep=sep_): return NCS(obj,Back.NavajoWhite,Style.NoBackground,sep) + @staticmethod + def PeachPuff(*obj, sep=sep_): return NCS(obj,Back.PeachPuff,Style.NoBackground,sep) + @staticmethod + def MistyRose(*obj, sep=sep_): return NCS(obj,Back.MistyRose,Style.NoBackground,sep) + @staticmethod + def LavenderBlush(*obj, sep=sep_): return NCS(obj,Back.LavenderBlush,Style.NoBackground,sep) + @staticmethod + def Linen(*obj, sep=sep_): return NCS(obj,Back.Linen,Style.NoBackground,sep) + @staticmethod + def OldLace(*obj, sep=sep_): return NCS(obj,Back.OldLace,Style.NoBackground,sep) + @staticmethod + def PapayaWhip(*obj, sep=sep_): return NCS(obj,Back.PapayaWhip,Style.NoBackground,sep) + @staticmethod + def WeaShell(*obj, sep=sep_): return NCS(obj,Back.WeaShell,Style.NoBackground,sep) + @staticmethod + def MintCream(*obj, sep=sep_): return NCS(obj,Back.MintCream,Style.NoBackground,sep) + @staticmethod + def SlateGray(*obj, sep=sep_): return NCS(obj,Back.SlateGray,Style.NoBackground,sep) + @staticmethod + def LightSlateGray(*obj, sep=sep_): return NCS(obj,Back.LightSlateGray,Style.NoBackground,sep) + @staticmethod + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,Back.LightSteelBlue,Style.NoBackground,sep) + @staticmethod + def Lavender(*obj, sep=sep_): return NCS(obj,Back.Lavender,Style.NoBackground,sep) + @staticmethod + def FloralWhite(*obj, sep=sep_): return NCS(obj,Back.FloralWhite,Style.NoBackground,sep) + @staticmethod + def AliceBlue(*obj, sep=sep_): return NCS(obj,Back.AliceBlue,Style.NoBackground,sep) + @staticmethod + def GhostWhite(*obj, sep=sep_): return NCS(obj,Back.GhostWhite,Style.NoBackground,sep) + @staticmethod + def Honeydew(*obj, sep=sep_): return NCS(obj,Back.Honeydew,Style.NoBackground,sep) + @staticmethod + def Ivory(*obj, sep=sep_): return NCS(obj,Back.Ivory,Style.NoBackground,sep) + @staticmethod + def Azure(*obj, sep=sep_): return NCS(obj,Back.Azure,Style.NoBackground,sep) + @staticmethod + def Snow(*obj, sep=sep_): return NCS(obj,Back.Snow,Style.NoBackground,sep) + @staticmethod + def Black(*obj, sep=sep_): return NCS(obj,Back.Black,Style.NoBackground,sep) + @staticmethod + def DimGray(*obj, sep=sep_): return NCS(obj,Back.DimGray,Style.NoBackground,sep) + @staticmethod + def Gray(*obj, sep=sep_): return NCS(obj,Back.Gray,Style.NoBackground,sep) + @staticmethod + def DarkGray(*obj, sep=sep_): return NCS(obj,Back.DarkGray,Style.NoBackground,sep) + @staticmethod + def Silver(*obj, sep=sep_): return NCS(obj,Back.Silver,Style.NoBackground,sep) + @staticmethod + def LightGray(*obj, sep=sep_): return NCS(obj,Back.LightGray,Style.NoBackground,sep) + @staticmethod + def Gainsboro(*obj, sep=sep_): return NCS(obj,Back.Gainsboro,Style.NoBackground,sep) + @staticmethod + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,Back.WhiteSmoke,Style.NoBackground,sep) + @staticmethod + 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 new file mode 100644 index 0000000..2e26983 --- /dev/null +++ b/src/AthenaColor/Objects/Console/Styling/Nested/ForeNest.py @@ -0,0 +1,333 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - 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.Objects.Console.Styling.Inline.Bodies import Fore +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style + +# ---------------------------------------------------------------------------------------------------------------------- +# - All - +# ---------------------------------------------------------------------------------------------------------------------- +__all__=[ + "ForeNest" +] + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase +sep_=" " + +class ForeNest: + # ------------------------------------------------------------------------------------------------------------------ + # - Methods - + # ------------------------------------------------------------------------------------------------------------------ + @staticmethod + 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(*color.export())}m", + Style.NoForeground, + sep=sep + ) + + @staticmethod + 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 ';' + return NestedColorSequence( + obj, + f"\033[38;2;{';'.join(*NormalizeRgb(r, g, b))}m", + Style.NoForeground, + sep=sep + ) + + # ------------------------------------------------------------------------------------------------------------------ + # - HTML colors - + # ------------------------------------------------------------------------------------------------------------------ + # No partial methods, as this was increase the speed impact 2-fold + @staticmethod + def Maroon(*obj, sep=sep_): return NCS(obj,Fore.Maroon,Style.NoForeground,sep) + @staticmethod + def DarkRed(*obj, sep=sep_): return NCS(obj,Fore.DarkRed,Style.NoForeground,sep) + @staticmethod + def Brown(*obj, sep=sep_): return NCS(obj,Fore.Brown,Style.NoForeground,sep) + @staticmethod + def Firebrick(*obj, sep=sep_): return NCS(obj,Fore.Firebrick,Style.NoForeground,sep) + @staticmethod + def Crimson(*obj, sep=sep_): return NCS(obj,Fore.Crimson,Style.NoForeground,sep) + @staticmethod + def Red(*obj, sep=sep_): return NCS(obj,Fore.Red,Style.NoForeground,sep) + @staticmethod + def Tomato(*obj, sep=sep_): return NCS(obj,Fore.Tomato,Style.NoForeground,sep) + @staticmethod + def Coral(*obj, sep=sep_): return NCS(obj,Fore.Coral,Style.NoForeground,sep) + @staticmethod + def IndianRed(*obj, sep=sep_): return NCS(obj,Fore.IndianRed,Style.NoForeground,sep) + @staticmethod + def LightCoral(*obj, sep=sep_): return NCS(obj,Fore.LightCoral,Style.NoForeground,sep) + @staticmethod + def DarkSalmon(*obj, sep=sep_): return NCS(obj,Fore.DarkSalmon,Style.NoForeground,sep) + @staticmethod + def Salmon(*obj, sep=sep_): return NCS(obj,Fore.Salmon,Style.NoForeground,sep) + @staticmethod + def LightSalmon(*obj, sep=sep_): return NCS(obj,Fore.LightSalmon,Style.NoForeground,sep) + @staticmethod + def OrangeRed(*obj, sep=sep_): return NCS(obj,Fore.OrangeRed,Style.NoForeground,sep) + @staticmethod + def DarkOrange(*obj, sep=sep_): return NCS(obj,Fore.DarkOrange,Style.NoForeground,sep) + @staticmethod + def Orange(*obj, sep=sep_): return NCS(obj,Fore.Orange,Style.NoForeground,sep) + @staticmethod + def Gold(*obj, sep=sep_): return NCS(obj,Fore.Gold,Style.NoForeground,sep) + @staticmethod + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,Fore.DarkGoldenRod,Style.NoForeground,sep) + @staticmethod + def GoldenRod(*obj, sep=sep_): return NCS(obj,Fore.GoldenRod,Style.NoForeground,sep) + @staticmethod + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,Fore.PaleGoldenRod,Style.NoForeground,sep) + @staticmethod + def DarkKhaki(*obj, sep=sep_): return NCS(obj,Fore.DarkKhaki,Style.NoForeground,sep) + @staticmethod + def Khaki(*obj, sep=sep_): return NCS(obj,Fore.Khaki,Style.NoForeground,sep) + @staticmethod + def Olive(*obj, sep=sep_): return NCS(obj,Fore.Olive,Style.NoForeground,sep) + @staticmethod + def Yellow(*obj, sep=sep_): return NCS(obj,Fore.Yellow,Style.NoForeground,sep) + @staticmethod + def YellowGreen(*obj, sep=sep_): return NCS(obj,Fore.YellowGreen,Style.NoForeground,sep) + @staticmethod + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,Fore.DarkOliveGreen,Style.NoForeground,sep) + @staticmethod + def OliveDrab(*obj, sep=sep_): return NCS(obj,Fore.OliveDrab,Style.NoForeground,sep) + @staticmethod + def LawnGreen(*obj, sep=sep_): return NCS(obj,Fore.LawnGreen,Style.NoForeground,sep) + @staticmethod + def Chartreuse(*obj, sep=sep_): return NCS(obj,Fore.Chartreuse,Style.NoForeground,sep) + @staticmethod + def GreenYellow(*obj, sep=sep_): return NCS(obj,Fore.GreenYellow,Style.NoForeground,sep) + @staticmethod + def DarkGreen(*obj, sep=sep_): return NCS(obj,Fore.DarkGreen,Style.NoForeground,sep) + @staticmethod + def Green(*obj, sep=sep_): return NCS(obj,Fore.Green,Style.NoForeground,sep) + @staticmethod + def ForestGreen(*obj, sep=sep_): return NCS(obj,Fore.ForestGreen,Style.NoForeground,sep) + @staticmethod + def Lime(*obj, sep=sep_): return NCS(obj,Fore.Lime,Style.NoForeground,sep) + @staticmethod + def LimeGreen(*obj, sep=sep_): return NCS(obj,Fore.LimeGreen,Style.NoForeground,sep) + @staticmethod + def LightGreen(*obj, sep=sep_): return NCS(obj,Fore.LightGreen,Style.NoForeground,sep) + @staticmethod + def PaleGreen(*obj, sep=sep_): return NCS(obj,Fore.PaleGreen,Style.NoForeground,sep) + @staticmethod + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,Fore.DarkSeaGreen,Style.NoForeground,sep) + @staticmethod + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,Fore.MediumSpringGreen,Style.NoForeground,sep) + @staticmethod + def SpringGreen(*obj, sep=sep_): return NCS(obj,Fore.SpringGreen,Style.NoForeground,sep) + @staticmethod + def SeaGreen(*obj, sep=sep_): return NCS(obj,Fore.SeaGreen,Style.NoForeground,sep) + @staticmethod + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,Fore.MediumAquaMarine,Style.NoForeground,sep) + @staticmethod + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,Fore.MediumSeaGreen,Style.NoForeground,sep) + @staticmethod + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,Fore.LightSeaGreen,Style.NoForeground,sep) + @staticmethod + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,Fore.DarkSlateGray,Style.NoForeground,sep) + @staticmethod + def Teal(*obj, sep=sep_): return NCS(obj,Fore.Teal,Style.NoForeground,sep) + @staticmethod + def DarkCyan(*obj, sep=sep_): return NCS(obj,Fore.DarkCyan,Style.NoForeground,sep) + @staticmethod + def Aqua(*obj, sep=sep_): return NCS(obj,Fore.Aqua,Style.NoForeground,sep) + @staticmethod + def Cyan(*obj, sep=sep_): return NCS(obj,Fore.Cyan,Style.NoForeground,sep) + @staticmethod + def LightCyan(*obj, sep=sep_): return NCS(obj,Fore.LightCyan,Style.NoForeground,sep) + @staticmethod + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,Fore.DarkTurquoise,Style.NoForeground,sep) + @staticmethod + def Turquoise(*obj, sep=sep_): return NCS(obj,Fore.Turquoise,Style.NoForeground,sep) + @staticmethod + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,Fore.MediumTurquoise,Style.NoForeground,sep) + @staticmethod + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,Fore.PaleTurquoise,Style.NoForeground,sep) + @staticmethod + def AquaMarine(*obj, sep=sep_): return NCS(obj,Fore.AquaMarine,Style.NoForeground,sep) + @staticmethod + def PowderBlue(*obj, sep=sep_): return NCS(obj,Fore.PowderBlue,Style.NoForeground,sep) + @staticmethod + def CadetBlue(*obj, sep=sep_): return NCS(obj,Fore.CadetBlue,Style.NoForeground,sep) + @staticmethod + def SteelBlue(*obj, sep=sep_): return NCS(obj,Fore.SteelBlue,Style.NoForeground,sep) + @staticmethod + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,Fore.CornFlowerBlue,Style.NoForeground,sep) + @staticmethod + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,Fore.DeepSkyBlue,Style.NoForeground,sep) + @staticmethod + def DodgerBlue(*obj, sep=sep_): return NCS(obj,Fore.DodgerBlue,Style.NoForeground,sep) + @staticmethod + def LightBlue(*obj, sep=sep_): return NCS(obj,Fore.LightBlue,Style.NoForeground,sep) + @staticmethod + def SkyBlue(*obj, sep=sep_): return NCS(obj,Fore.SkyBlue,Style.NoForeground,sep) + @staticmethod + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,Fore.LightSkyBlue,Style.NoForeground,sep) + @staticmethod + def MidnightBlue(*obj, sep=sep_): return NCS(obj,Fore.MidnightBlue,Style.NoForeground,sep) + @staticmethod + def Navy(*obj, sep=sep_): return NCS(obj,Fore.Navy,Style.NoForeground,sep) + @staticmethod + def DarkBlue(*obj, sep=sep_): return NCS(obj,Fore.DarkBlue,Style.NoForeground,sep) + @staticmethod + def MediumBlue(*obj, sep=sep_): return NCS(obj,Fore.MediumBlue,Style.NoForeground,sep) + @staticmethod + def Blue(*obj, sep=sep_): return NCS(obj,Fore.Blue,Style.NoForeground,sep) + @staticmethod + def RoyalBlue(*obj, sep=sep_): return NCS(obj,Fore.RoyalBlue,Style.NoForeground,sep) + @staticmethod + def BlueViolet(*obj, sep=sep_): return NCS(obj,Fore.BlueViolet,Style.NoForeground,sep) + @staticmethod + def Indigo(*obj, sep=sep_): return NCS(obj,Fore.Indigo,Style.NoForeground,sep) + @staticmethod + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,Fore.DarkSlateBlue,Style.NoForeground,sep) + @staticmethod + def SlateBlue(*obj, sep=sep_): return NCS(obj,Fore.SlateBlue,Style.NoForeground,sep) + @staticmethod + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,Fore.MediumSlateBlue,Style.NoForeground,sep) + @staticmethod + def MediumPurple(*obj, sep=sep_): return NCS(obj,Fore.MediumPurple,Style.NoForeground,sep) + @staticmethod + def DarkMagenta(*obj, sep=sep_): return NCS(obj,Fore.DarkMagenta,Style.NoForeground,sep) + @staticmethod + def DarkViolet(*obj, sep=sep_): return NCS(obj,Fore.DarkViolet,Style.NoForeground,sep) + @staticmethod + def DarkOrchid(*obj, sep=sep_): return NCS(obj,Fore.DarkOrchid,Style.NoForeground,sep) + @staticmethod + def MediumOrchid(*obj, sep=sep_): return NCS(obj,Fore.MediumOrchid,Style.NoForeground,sep) + @staticmethod + def Purple(*obj, sep=sep_): return NCS(obj,Fore.Purple,Style.NoForeground,sep) + @staticmethod + def Thistle(*obj, sep=sep_): return NCS(obj,Fore.Thistle,Style.NoForeground,sep) + @staticmethod + def Plum(*obj, sep=sep_): return NCS(obj,Fore.Plum,Style.NoForeground,sep) + @staticmethod + def Violet(*obj, sep=sep_): return NCS(obj,Fore.Violet,Style.NoForeground,sep) + @staticmethod + def Magenta(*obj, sep=sep_): return NCS(obj,Fore.Magenta,Style.NoForeground,sep) + @staticmethod + def Orchid(*obj, sep=sep_): return NCS(obj,Fore.Orchid,Style.NoForeground,sep) + @staticmethod + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,Fore.MediumVioletRed,Style.NoForeground,sep) + @staticmethod + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,Fore.PaleVioletRed,Style.NoForeground,sep) + @staticmethod + def DeepPink(*obj, sep=sep_): return NCS(obj,Fore.DeepPink,Style.NoForeground,sep) + @staticmethod + def HotPink(*obj, sep=sep_): return NCS(obj,Fore.HotPink,Style.NoForeground,sep) + @staticmethod + def LightPink(*obj, sep=sep_): return NCS(obj,Fore.LightPink,Style.NoForeground,sep) + @staticmethod + def Pink(*obj, sep=sep_): return NCS(obj,Fore.Pink,Style.NoForeground,sep) + @staticmethod + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,Fore.AntiqueWhite,Style.NoForeground,sep) + @staticmethod + def Beige(*obj, sep=sep_): return NCS(obj,Fore.Beige,Style.NoForeground,sep) + @staticmethod + def Bisque(*obj, sep=sep_): return NCS(obj,Fore.Bisque,Style.NoForeground,sep) + @staticmethod + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,Fore.BlanchedAlmond,Style.NoForeground,sep) + @staticmethod + def Wheat(*obj, sep=sep_): return NCS(obj,Fore.Wheat,Style.NoForeground,sep) + @staticmethod + def CornSilk(*obj, sep=sep_): return NCS(obj,Fore.CornSilk,Style.NoForeground,sep) + @staticmethod + def LemonChiffon(*obj, sep=sep_): return NCS(obj,Fore.LemonChiffon,Style.NoForeground,sep) + @staticmethod + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,Fore.LightGoldenRodYellow,Style.NoForeground,sep) + @staticmethod + def LightYellow(*obj, sep=sep_): return NCS(obj,Fore.LightYellow,Style.NoForeground,sep) + @staticmethod + def SaddleBrown(*obj, sep=sep_): return NCS(obj,Fore.SaddleBrown,Style.NoForeground,sep) + @staticmethod + def Sienna(*obj, sep=sep_): return NCS(obj,Fore.Sienna,Style.NoForeground,sep) + @staticmethod + def Chocolate(*obj, sep=sep_): return NCS(obj,Fore.Chocolate,Style.NoForeground,sep) + @staticmethod + def Peru(*obj, sep=sep_): return NCS(obj,Fore.Peru,Style.NoForeground,sep) + @staticmethod + def SandyBrown(*obj, sep=sep_): return NCS(obj,Fore.SandyBrown,Style.NoForeground,sep) + @staticmethod + def BurlyWood(*obj, sep=sep_): return NCS(obj,Fore.BurlyWood,Style.NoForeground,sep) + @staticmethod + def Tan(*obj, sep=sep_): return NCS(obj,Fore.Tan,Style.NoForeground,sep) + @staticmethod + def RosyBrown(*obj, sep=sep_): return NCS(obj,Fore.RosyBrown,Style.NoForeground,sep) + @staticmethod + def Moccasin(*obj, sep=sep_): return NCS(obj,Fore.Moccasin,Style.NoForeground,sep) + @staticmethod + def NavajoWhite(*obj, sep=sep_): return NCS(obj,Fore.NavajoWhite,Style.NoForeground,sep) + @staticmethod + def PeachPuff(*obj, sep=sep_): return NCS(obj,Fore.PeachPuff,Style.NoForeground,sep) + @staticmethod + def MistyRose(*obj, sep=sep_): return NCS(obj,Fore.MistyRose,Style.NoForeground,sep) + @staticmethod + def LavenderBlush(*obj, sep=sep_): return NCS(obj,Fore.LavenderBlush,Style.NoForeground,sep) + @staticmethod + def Linen(*obj, sep=sep_): return NCS(obj,Fore.Linen,Style.NoForeground,sep) + @staticmethod + def OldLace(*obj, sep=sep_): return NCS(obj,Fore.OldLace,Style.NoForeground,sep) + @staticmethod + def PapayaWhip(*obj, sep=sep_): return NCS(obj,Fore.PapayaWhip,Style.NoForeground,sep) + @staticmethod + def WeaShell(*obj, sep=sep_): return NCS(obj,Fore.WeaShell,Style.NoForeground,sep) + @staticmethod + def MintCream(*obj, sep=sep_): return NCS(obj,Fore.MintCream,Style.NoForeground,sep) + @staticmethod + def SlateGray(*obj, sep=sep_): return NCS(obj,Fore.SlateGray,Style.NoForeground,sep) + @staticmethod + def LightSlateGray(*obj, sep=sep_): return NCS(obj,Fore.LightSlateGray,Style.NoForeground,sep) + @staticmethod + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,Fore.LightSteelBlue,Style.NoForeground,sep) + @staticmethod + def Lavender(*obj, sep=sep_): return NCS(obj,Fore.Lavender,Style.NoForeground,sep) + @staticmethod + def FloralWhite(*obj, sep=sep_): return NCS(obj,Fore.FloralWhite,Style.NoForeground,sep) + @staticmethod + def AliceBlue(*obj, sep=sep_): return NCS(obj,Fore.AliceBlue,Style.NoForeground,sep) + @staticmethod + def GhostWhite(*obj, sep=sep_): return NCS(obj,Fore.GhostWhite,Style.NoForeground,sep) + @staticmethod + def Honeydew(*obj, sep=sep_): return NCS(obj,Fore.Honeydew,Style.NoForeground,sep) + @staticmethod + def Ivory(*obj, sep=sep_): return NCS(obj,Fore.Ivory,Style.NoForeground,sep) + @staticmethod + def Azure(*obj, sep=sep_): return NCS(obj,Fore.Azure,Style.NoForeground,sep) + @staticmethod + def Snow(*obj, sep=sep_): return NCS(obj,Fore.Snow,Style.NoForeground,sep) + @staticmethod + def Black(*obj, sep=sep_): return NCS(obj,Fore.Black,Style.NoForeground,sep) + @staticmethod + def DimGray(*obj, sep=sep_): return NCS(obj,Fore.DimGray,Style.NoForeground,sep) + @staticmethod + def Gray(*obj, sep=sep_): return NCS(obj,Fore.Gray,Style.NoForeground,sep) + @staticmethod + def DarkGray(*obj, sep=sep_): return NCS(obj,Fore.DarkGray,Style.NoForeground,sep) + @staticmethod + def Silver(*obj, sep=sep_): return NCS(obj,Fore.Silver,Style.NoForeground,sep) + @staticmethod + def LightGray(*obj, sep=sep_): return NCS(obj,Fore.LightGray,Style.NoForeground,sep) + @staticmethod + def Gainsboro(*obj, sep=sep_): return NCS(obj,Fore.Gainsboro,Style.NoForeground,sep) + @staticmethod + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,Fore.WhiteSmoke,Style.NoForeground,sep) + @staticmethod + 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_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 96f71da..c09b338 100644 --- a/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py +++ b/src/AthenaColor/Objects/Console/Styling/Nested/Nested_MakeUp.py @@ -2,12 +2,12 @@ # - Package Imports - # ---------------------------------------------------------------------------------------------------------------------- # General Packages -from functools import partial # Custom Library # Custom Packages -from AthenaColor.Functions.ANSIsquences import NestedColorSequence +from AthenaColor.Functions.ANSIsquences import NestedColorSequence,NestedColorSequence_NoReset +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style, Basic # ---------------------------------------------------------------------------------------------------------------------- # - All - @@ -19,119 +19,186 @@ # ---------------------------------------------------------------------------------------------------------------------- # - StyleNest Sequences - # ---------------------------------------------------------------------------------------------------------------------- -class StyleNest: - # noinspection PyUnresolvedReferences - __all__ = [ - "Reset", - "Italic", - "NoItalic", - "Bold", - "NoBold", - "UnderlineNest", - "NoUnderline", - "Crossed", - "NoCrossed", - "Reversed", - "NoReversed", - "Frame", - "NoFrame", - "Circle", - "NoCircle", - "UnderlineDouble", - "NoForeground", - "NoBackground" - ] +NCS = NestedColorSequence # Done for slight speed increase +NCSNO = NestedColorSequence_NoReset # Done for slight speed increase +sep_ = " " - 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) +class StyleNest: + @staticmethod + def Reset(*obj,sep=sep_): return NCSNO(obj,Style.Reset,sep) + @staticmethod + def Bold(*obj,sep=sep_): return NCS(obj,Style.Bold,Style.NoBold,sep) + @staticmethod + def NoBold(*obj,sep=sep_): return NCSNO(obj,Style.NoBold,sep) + @staticmethod + def Dim(*obj,sep=sep_): return NCS(obj,Style.Dim,Style.NoBold,sep) + @staticmethod + def NoDim(*obj,sep=sep_): return NCSNO(obj,Style.NoBold,sep) + @staticmethod + def Italic(*obj,sep=sep_): return NCS(obj,Style.Italic,Style.NoItalic,sep) + @staticmethod + def NoItalic(*obj,sep=sep_): return NCSNO(obj,Style.NoItalic,sep) + @staticmethod + def Underline(*obj,sep=sep_): return NCS(obj,Style.Underline,Style.NoUnderline,sep) + @staticmethod + def NoUnderline(*obj,sep=sep_): return NCSNO(obj,Style.NoUnderline,sep) + @staticmethod + def BlinkSlow(*obj,sep=sep_): return NCS(obj,Style.BlinkSlow,Style.NoBlinkSlow,sep) + @staticmethod + def NoBlinkSlow(*obj,sep=sep_): return NCSNO(obj,Style.NoBlinkSlow,sep) + @staticmethod + def BlinkRapid(*obj,sep=sep_): return NCS(obj,Style.BlinkRapid,Style.NoBlinkRapid,sep) + @staticmethod + def NoBlinkRapid(*obj,sep=sep_): return NCSNO(obj,Style.NoBlinkRapid,sep) + @staticmethod + def Reversed(*obj,sep=sep_): return NCS(obj,Style.Reversed,Style.NoReversed,sep) + @staticmethod + def NoReversed(*obj,sep=sep_): return NCSNO(obj,Style.NoReversed,sep) + @staticmethod + def Conceal(*obj,sep=sep_): return NCS(obj,Style.Conceal,Style.NoConceal,sep) + @staticmethod + def NoConceal(*obj,sep=sep_): return NCSNO(obj,Style.NoConceal,sep) + @staticmethod + def Crossed(*obj,sep=sep_): return NCS(obj,Style.Crossed,Style.NoCrossed,sep) + @staticmethod + def NoCrossed(*obj,sep=sep_): return NCSNO(obj,Style.NoCrossed,sep) + @staticmethod + def FontPrimary(*obj,sep=sep_): return NCS(obj,Style.NoFont,Style.NoFont,sep) + @staticmethod + def FontSecond1(*obj,sep=sep_): return NCS(obj,Style.FontSecond1,Style.NoFont,sep) + @staticmethod + def FontSecond2(*obj,sep=sep_): return NCS(obj,Style.FontSecond2,Style.NoFont,sep) + @staticmethod + def FontSecond3(*obj,sep=sep_): return NCS(obj,Style.FontSecond3,Style.NoFont,sep) + @staticmethod + def FontSecond4(*obj,sep=sep_): return NCS(obj,Style.FontSecond4,Style.NoFont,sep) + @staticmethod + def FontSecond5(*obj,sep=sep_): return NCS(obj,Style.FontSecond5,Style.NoFont,sep) + @staticmethod + def FontSecond6(*obj,sep=sep_): return NCS(obj,Style.FontSecond6,Style.NoFont,sep) + @staticmethod + def FontSecond8(*obj,sep=sep_): return NCS(obj,Style.FontSecond8,Style.NoFont,sep) + @staticmethod + def FontSecond9(*obj,sep=sep_): return NCS(obj,Style.FontSecond9,Style.NoFont,sep) + @staticmethod + def FontSecond10(*obj,sep=sep_): return NCS(obj,Style.FontSecond10,Style.NoFont,sep) + @staticmethod + def NoFont(*obj,sep=sep_): return NCSNO(obj,Style.NoFont,sep) + @staticmethod + def Fraktur(*obj,sep=sep_): return NCSNO(obj,Style.Fraktur,sep) + @staticmethod + def UnderlineDouble(*obj,sep=sep_): return NCS(obj,Style.UnderlineDouble,Style.NoUnderline,sep) + @staticmethod + def NoUnderlineDouble(*obj,sep=sep_): return NCSNO(obj,Style.NoUnderline,sep) + @staticmethod + def PropSpacing(*obj,sep=sep_): return NCS(obj,Style.PropSpacing,Style.NoPropSpacing,sep) + @staticmethod + def NoPropSpacing(*obj,sep=sep_): return NCSNO(obj,Style.NoPropSpacing,sep) + @staticmethod + def NoForeground(*obj,sep=sep_): return NCSNO(obj,Style.NoForeground,sep) + @staticmethod + def NoBackground(*obj,sep=sep_): return NCSNO(obj,Style.NoBackground,sep) + @staticmethod + def Frame(*obj,sep=sep_): return NCS(obj,Style.Frame,Style.NoFrame,sep) + @staticmethod + def NoFrame(*obj,sep=sep_): return NCSNO(obj,Style.NoFrame,sep) + @staticmethod + def Circle(*obj,sep=sep_): return NCS(obj,Style.Circle,Style.NoFrame,sep) + @staticmethod + def NoCircle(*obj,sep=sep_): return NCSNO(obj,Style.NoFrame,sep) + @staticmethod + def OverLine(*obj,sep=sep_): return NCS(obj,Style.OverLine,Style.NoOverLine,sep) + @staticmethod + def NoOverLine(*obj,sep=sep_): return NCSNO(obj,Style.NoOverLine,sep) + @staticmethod + def UnderColourDefault(*obj,sep=sep_): return NCSNO(obj,Style.UnderColourDefault,sep) + @staticmethod + def IdeogramUnderLine(*obj,sep=sep_): return NCS(obj,Style.IdeogramUnderLine,Style.NoIdeogram,sep) + @staticmethod + def IdeogramUnderLineDouble(*obj,sep=sep_): return NCS(obj,Style.IdeogramUnderLineDouble,Style.NoIdeogram,sep) + @staticmethod + def IdeogramOverLine(*obj,sep=sep_): return NCS(obj,Style.IdeogramOverLine,Style.NoIdeogram,sep) + @staticmethod + def IdeogramOverLineDouble(*obj,sep=sep_): return NCS(obj,Style.IdeogramOverLineDouble,Style.NoIdeogram,sep) + @staticmethod + def IdeogramStress(*obj,sep=sep_): return NCS(obj,Style.IdeogramStress,Style.NoIdeogram,sep) + @staticmethod + def NoIdeogram(*obj,sep=sep_): return NCSNO(obj,Style.NoIdeogram,sep) + @staticmethod + def SuperScript(*obj,sep=sep_): return NCS(obj,Style.SuperScript,Style.NoScript,sep) + @staticmethod + def SubScript(*obj,sep=sep_): return NCS(obj,Style.SubScript,Style.NoScript,sep) + @staticmethod + def NoScript(*obj,sep=sep_): return NCSNO(obj,Style.NoScript,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=sep_): return NCS(obj, Basic.Fore.Black, Style.NoForeground,sep) + @staticmethod + def Red(*obj,sep=sep_): return NCS(obj, Basic.Fore.Red, Style.NoForeground,sep) + @staticmethod + def Green(*obj,sep=sep_): return NCS(obj, Basic.Fore.Green, Style.NoForeground,sep) + @staticmethod + def Yellow(*obj,sep=sep_): return NCS(obj, Basic.Fore.Yellow, Style.NoForeground,sep) + @staticmethod + def Blue(*obj,sep=sep_): return NCS(obj, Basic.Fore.Blue, Style.NoForeground,sep) + @staticmethod + def Magenta(*obj,sep=sep_): return NCS(obj, Basic.Fore.Magenta, Style.NoForeground,sep) + @staticmethod + def Cyan(*obj,sep=sep_): return NCS(obj, Basic.Fore.Cyan, Style.NoForeground,sep) + @staticmethod + def White(*obj,sep=sep_): return NCS(obj, Basic.Fore.White, Style.NoForeground,sep) + @staticmethod + def BrightBlack(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightBlack, Style.NoForeground,sep) + @staticmethod + def BrightRed(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightRed, Style.NoForeground,sep) + @staticmethod + def BrightGreen(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightGreen, Style.NoForeground,sep) + @staticmethod + def BrightYellow(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightYellow, Style.NoForeground,sep) + @staticmethod + def BrightBlue(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightBlue, Style.NoForeground,sep) + @staticmethod + def BrightMagenta(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightMagenta, Style.NoForeground,sep) + @staticmethod + def BrightCyan(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightCyan, Style.NoForeground,sep) + @staticmethod + def BrightWhite(*obj,sep=sep_): return NCS(obj, Basic.Fore.BrightWhite, Style.NoForeground,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=sep_): return NCS(obj, Basic.Back.Black, Style.NoBackground,sep) + @staticmethod + def Red(*obj,sep=sep_): return NCS(obj, Basic.Back.Red, Style.NoBackground,sep) + @staticmethod + def Green(*obj,sep=sep_): return NCS(obj, Basic.Back.Green, Style.NoBackground,sep) + @staticmethod + def Yellow(*obj,sep=sep_): return NCS(obj, Basic.Back.Yellow, Style.NoBackground,sep) + @staticmethod + def Blue(*obj,sep=sep_): return NCS(obj, Basic.Back.Blue, Style.NoBackground,sep) + @staticmethod + def Magenta(*obj,sep=sep_): return NCS(obj, Basic.Back.Magenta, Style.NoBackground,sep) + @staticmethod + def Cyan(*obj,sep=sep_): return NCS(obj, Basic.Back.Cyan, Style.NoBackground,sep) + @staticmethod + def White(*obj,sep=sep_): return NCS(obj, Basic.Back.White, Style.NoBackground,sep) + @staticmethod + def BrightBlack(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightBlack, Style.NoBackground,sep) + @staticmethod + def BrightRed(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightRed, Style.NoBackground,sep) + @staticmethod + def BrightGreen(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightGreen, Style.NoBackground,sep) + @staticmethod + def BrightYellow(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightYellow, Style.NoBackground,sep) + @staticmethod + def BrightBlue(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightBlue, Style.NoBackground,sep) + @staticmethod + def BrightMagenta(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightMagenta, Style.NoBackground,sep) + @staticmethod + def BrightCyan(*obj,sep=sep_): return NCS(obj, Basic.Back.BrightCyan, Style.NoBackground,sep) + @staticmethod + 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/RgbControlledNest.py b/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py deleted file mode 100644 index 11e9cce..0000000 --- a/src/AthenaColor/Objects/Console/Styling/Nested/RgbControlledNest.py +++ /dev/null @@ -1,195 +0,0 @@ -# ---------------------------------------------------------------------------------------------------------------------- -# - Package Imports - -# ---------------------------------------------------------------------------------------------------------------------- -# General Packages -from __future__ import annotations -from functools import partialmethod - -# Custom Library - -# Custom Packages -from AthenaColor.Objects.Color.ColorSystem import RGB,HEX -from AthenaColor.Functions.ANSIsquences import NestedColorSequence -from AthenaColor.Data.HtmlColors import HtmlColorObjects as HtmlColors -from AthenaColor.Functions.General import StrictType - -# ---------------------------------------------------------------------------------------------------------------------- -# - All - -# ---------------------------------------------------------------------------------------------------------------------- -__all__=[ - "RgbControlledNest" -] - -# ---------------------------------------------------------------------------------------------------------------------- -# - Code - -# ---------------------------------------------------------------------------------------------------------------------- -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 ';' - color = RGB(r, g, b) - return NestedColorSequence( - *obj, - control_code=f"{self._param_code}{color.r};{color.g};{color.b}", - reset_code=self._reset, - **kwargs - ) - - # ------------------------------------------------------------------------------------------------------------------ - # - 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 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..da022a9 --- /dev/null +++ b/src/AthenaColor/Objects/Console/Styling/Nested/UnderlineNest.py @@ -0,0 +1,334 @@ +# ---------------------------------------------------------------------------------------------------------------------- +# - 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.Objects.Console.Styling.Inline.Bodies import Underline +from AthenaColor.Objects.Console.Styling.Inline.MakeUp import Style + + +# ---------------------------------------------------------------------------------------------------------------------- +# - All - +# ---------------------------------------------------------------------------------------------------------------------- +__all__=[ + "UnderlineNest" +] + +# ---------------------------------------------------------------------------------------------------------------------- +# - Code - +# ---------------------------------------------------------------------------------------------------------------------- +NCS = NestedColorSequence # Done for slight speed increase +sep_=" " + +class UnderlineNest: + # ------------------------------------------------------------------------------------------------------------------ + # - Methods - + # ------------------------------------------------------------------------------------------------------------------ + @staticmethod + 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(*color.export())}m", + Style.NoForeground, + sep=sep + ) + + @staticmethod + 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 ';' + return NestedColorSequence( + obj, + f"\033[58;2;{';'.join(*NormalizeRgb(r, g, b))}m", + Style.NoForeground, + sep=sep + ) + + # ------------------------------------------------------------------------------------------------------------------ + # - HTML colors - + # ------------------------------------------------------------------------------------------------------------------ + # No partial methods, as this was increase the speed impact 2-fold + @staticmethod + def Maroon( *obj, sep=sep_): return NCS(obj,Underline.Maroon,Style.NoUnderline,sep) + @staticmethod + def DarkRed(*obj, sep=sep_): return NCS(obj,Underline.DarkRed,Style.NoUnderline,sep) + @staticmethod + def Brown(*obj, sep=sep_): return NCS(obj,Underline.Brown,Style.NoUnderline,sep) + @staticmethod + def Firebrick(*obj, sep=sep_): return NCS(obj,Underline.Firebrick,Style.NoUnderline,sep) + @staticmethod + def Crimson(*obj, sep=sep_): return NCS(obj,Underline.Crimson,Style.NoUnderline,sep) + @staticmethod + def Red(*obj, sep=sep_): return NCS(obj,Underline.Red,Style.NoUnderline,sep) + @staticmethod + def Tomato(*obj, sep=sep_): return NCS(obj,Underline.Tomato,Style.NoUnderline,sep) + @staticmethod + def Coral(*obj, sep=sep_): return NCS(obj,Underline.Coral,Style.NoUnderline,sep) + @staticmethod + def IndianRed(*obj, sep=sep_): return NCS(obj,Underline.IndianRed,Style.NoUnderline,sep) + @staticmethod + def LightCoral(*obj, sep=sep_): return NCS(obj,Underline.LightCoral,Style.NoUnderline,sep) + @staticmethod + def DarkSalmon(*obj, sep=sep_): return NCS(obj,Underline.DarkSalmon,Style.NoUnderline,sep) + @staticmethod + def Salmon(*obj, sep=sep_): return NCS(obj,Underline.Salmon,Style.NoUnderline,sep) + @staticmethod + def LightSalmon(*obj, sep=sep_): return NCS(obj,Underline.LightSalmon,Style.NoUnderline,sep) + @staticmethod + def OrangeRed(*obj, sep=sep_): return NCS(obj,Underline.OrangeRed,Style.NoUnderline,sep) + @staticmethod + def DarkOrange(*obj, sep=sep_): return NCS(obj,Underline.DarkOrange,Style.NoUnderline,sep) + @staticmethod + def Orange(*obj, sep=sep_): return NCS(obj,Underline.Orange,Style.NoUnderline,sep) + @staticmethod + def Gold(*obj, sep=sep_): return NCS(obj,Underline.Gold,Style.NoUnderline,sep) + @staticmethod + def DarkGoldenRod(*obj, sep=sep_): return NCS(obj,Underline.DarkGoldenRod,Style.NoUnderline,sep) + @staticmethod + def GoldenRod(*obj, sep=sep_): return NCS(obj,Underline.GoldenRod,Style.NoUnderline,sep) + @staticmethod + def PaleGoldenRod(*obj, sep=sep_): return NCS(obj,Underline.PaleGoldenRod,Style.NoUnderline,sep) + @staticmethod + def DarkKhaki(*obj, sep=sep_): return NCS(obj,Underline.DarkKhaki,Style.NoUnderline,sep) + @staticmethod + def Khaki(*obj, sep=sep_): return NCS(obj,Underline.Khaki,Style.NoUnderline,sep) + @staticmethod + def Olive(*obj, sep=sep_): return NCS(obj,Underline.Olive,Style.NoUnderline,sep) + @staticmethod + def Yellow(*obj, sep=sep_): return NCS(obj,Underline.Yellow,Style.NoUnderline,sep) + @staticmethod + def YellowGreen(*obj, sep=sep_): return NCS(obj,Underline.YellowGreen,Style.NoUnderline,sep) + @staticmethod + def DarkOliveGreen(*obj, sep=sep_): return NCS(obj,Underline.DarkOliveGreen,Style.NoUnderline,sep) + @staticmethod + def OliveDrab(*obj, sep=sep_): return NCS(obj,Underline.OliveDrab,Style.NoUnderline,sep) + @staticmethod + def LawnGreen(*obj, sep=sep_): return NCS(obj,Underline.LawnGreen,Style.NoUnderline,sep) + @staticmethod + def Chartreuse(*obj, sep=sep_): return NCS(obj,Underline.Chartreuse,Style.NoUnderline,sep) + @staticmethod + def GreenYellow(*obj, sep=sep_): return NCS(obj,Underline.GreenYellow,Style.NoUnderline,sep) + @staticmethod + def DarkGreen(*obj, sep=sep_): return NCS(obj,Underline.DarkGreen,Style.NoUnderline,sep) + @staticmethod + def Green(*obj, sep=sep_): return NCS(obj,Underline.Green,Style.NoUnderline,sep) + @staticmethod + def ForestGreen(*obj, sep=sep_): return NCS(obj,Underline.ForestGreen,Style.NoUnderline,sep) + @staticmethod + def Lime(*obj, sep=sep_): return NCS(obj,Underline.Lime,Style.NoUnderline,sep) + @staticmethod + def LimeGreen(*obj, sep=sep_): return NCS(obj,Underline.LimeGreen,Style.NoUnderline,sep) + @staticmethod + def LightGreen(*obj, sep=sep_): return NCS(obj,Underline.LightGreen,Style.NoUnderline,sep) + @staticmethod + def PaleGreen(*obj, sep=sep_): return NCS(obj,Underline.PaleGreen,Style.NoUnderline,sep) + @staticmethod + def DarkSeaGreen(*obj, sep=sep_): return NCS(obj,Underline.DarkSeaGreen,Style.NoUnderline,sep) + @staticmethod + def MediumSpringGreen(*obj, sep=sep_): return NCS(obj,Underline.MediumSpringGreen,Style.NoUnderline,sep) + @staticmethod + def SpringGreen(*obj, sep=sep_): return NCS(obj,Underline.SpringGreen,Style.NoUnderline,sep) + @staticmethod + def SeaGreen(*obj, sep=sep_): return NCS(obj,Underline.SeaGreen,Style.NoUnderline,sep) + @staticmethod + def MediumAquaMarine(*obj, sep=sep_): return NCS(obj,Underline.MediumAquaMarine,Style.NoUnderline,sep) + @staticmethod + def MediumSeaGreen(*obj, sep=sep_): return NCS(obj,Underline.MediumSeaGreen,Style.NoUnderline,sep) + @staticmethod + def LightSeaGreen(*obj, sep=sep_): return NCS(obj,Underline.LightSeaGreen,Style.NoUnderline,sep) + @staticmethod + def DarkSlateGray(*obj, sep=sep_): return NCS(obj,Underline.DarkSlateGray,Style.NoUnderline,sep) + @staticmethod + def Teal(*obj, sep=sep_): return NCS(obj,Underline.Teal,Style.NoUnderline,sep) + @staticmethod + def DarkCyan(*obj, sep=sep_): return NCS(obj,Underline.DarkCyan,Style.NoUnderline,sep) + @staticmethod + def Aqua(*obj, sep=sep_): return NCS(obj,Underline.Aqua,Style.NoUnderline,sep) + @staticmethod + def Cyan(*obj, sep=sep_): return NCS(obj,Underline.Cyan,Style.NoUnderline,sep) + @staticmethod + def LightCyan(*obj, sep=sep_): return NCS(obj,Underline.LightCyan,Style.NoUnderline,sep) + @staticmethod + def DarkTurquoise(*obj, sep=sep_): return NCS(obj,Underline.DarkTurquoise,Style.NoUnderline,sep) + @staticmethod + def Turquoise(*obj, sep=sep_): return NCS(obj,Underline.Turquoise,Style.NoUnderline,sep) + @staticmethod + def MediumTurquoise(*obj, sep=sep_): return NCS(obj,Underline.MediumTurquoise,Style.NoUnderline,sep) + @staticmethod + def PaleTurquoise(*obj, sep=sep_): return NCS(obj,Underline.PaleTurquoise,Style.NoUnderline,sep) + @staticmethod + def AquaMarine(*obj, sep=sep_): return NCS(obj,Underline.AquaMarine,Style.NoUnderline,sep) + @staticmethod + def PowderBlue(*obj, sep=sep_): return NCS(obj,Underline.PowderBlue,Style.NoUnderline,sep) + @staticmethod + def CadetBlue(*obj, sep=sep_): return NCS(obj,Underline.CadetBlue,Style.NoUnderline,sep) + @staticmethod + def SteelBlue(*obj, sep=sep_): return NCS(obj,Underline.SteelBlue,Style.NoUnderline,sep) + @staticmethod + def CornFlowerBlue(*obj, sep=sep_): return NCS(obj,Underline.CornFlowerBlue,Style.NoUnderline,sep) + @staticmethod + def DeepSkyBlue(*obj, sep=sep_): return NCS(obj,Underline.DeepSkyBlue,Style.NoUnderline,sep) + @staticmethod + def DodgerBlue(*obj, sep=sep_): return NCS(obj,Underline.DodgerBlue,Style.NoUnderline,sep) + @staticmethod + def LightBlue(*obj, sep=sep_): return NCS(obj,Underline.LightBlue,Style.NoUnderline,sep) + @staticmethod + def SkyBlue(*obj, sep=sep_): return NCS(obj,Underline.SkyBlue,Style.NoUnderline,sep) + @staticmethod + def LightSkyBlue(*obj, sep=sep_): return NCS(obj,Underline.LightSkyBlue,Style.NoUnderline,sep) + @staticmethod + def MidnightBlue(*obj, sep=sep_): return NCS(obj,Underline.MidnightBlue,Style.NoUnderline,sep) + @staticmethod + def Navy(*obj, sep=sep_): return NCS(obj,Underline.Navy,Style.NoUnderline,sep) + @staticmethod + def DarkBlue(*obj, sep=sep_): return NCS(obj,Underline.DarkBlue,Style.NoUnderline,sep) + @staticmethod + def MediumBlue(*obj, sep=sep_): return NCS(obj,Underline.MediumBlue,Style.NoUnderline,sep) + @staticmethod + def Blue(*obj, sep=sep_): return NCS(obj,Underline.Blue,Style.NoUnderline,sep) + @staticmethod + def RoyalBlue(*obj, sep=sep_): return NCS(obj,Underline.RoyalBlue,Style.NoUnderline,sep) + @staticmethod + def BlueViolet(*obj, sep=sep_): return NCS(obj,Underline.BlueViolet,Style.NoUnderline,sep) + @staticmethod + def Indigo(*obj, sep=sep_): return NCS(obj,Underline.Indigo,Style.NoUnderline,sep) + @staticmethod + def DarkSlateBlue(*obj, sep=sep_): return NCS(obj,Underline.DarkSlateBlue,Style.NoUnderline,sep) + @staticmethod + def SlateBlue(*obj, sep=sep_): return NCS(obj,Underline.SlateBlue,Style.NoUnderline,sep) + @staticmethod + def MediumSlateBlue(*obj, sep=sep_): return NCS(obj,Underline.MediumSlateBlue,Style.NoUnderline,sep) + @staticmethod + def MediumPurple(*obj, sep=sep_): return NCS(obj,Underline.MediumPurple,Style.NoUnderline,sep) + @staticmethod + def DarkMagenta(*obj, sep=sep_): return NCS(obj,Underline.DarkMagenta,Style.NoUnderline,sep) + @staticmethod + def DarkViolet(*obj, sep=sep_): return NCS(obj,Underline.DarkViolet,Style.NoUnderline,sep) + @staticmethod + def DarkOrchid(*obj, sep=sep_): return NCS(obj,Underline.DarkOrchid,Style.NoUnderline,sep) + @staticmethod + def MediumOrchid(*obj, sep=sep_): return NCS(obj,Underline.MediumOrchid,Style.NoUnderline,sep) + @staticmethod + def Purple(*obj, sep=sep_): return NCS(obj,Underline.Purple,Style.NoUnderline,sep) + @staticmethod + def Thistle(*obj, sep=sep_): return NCS(obj,Underline.Thistle,Style.NoUnderline,sep) + @staticmethod + def Plum(*obj, sep=sep_): return NCS(obj,Underline.Plum,Style.NoUnderline,sep) + @staticmethod + def Violet(*obj, sep=sep_): return NCS(obj,Underline.Violet,Style.NoUnderline,sep) + @staticmethod + def Magenta(*obj, sep=sep_): return NCS(obj,Underline.Magenta,Style.NoUnderline,sep) + @staticmethod + def Orchid(*obj, sep=sep_): return NCS(obj,Underline.Orchid,Style.NoUnderline,sep) + @staticmethod + def MediumVioletRed(*obj, sep=sep_): return NCS(obj,Underline.MediumVioletRed,Style.NoUnderline,sep) + @staticmethod + def PaleVioletRed(*obj, sep=sep_): return NCS(obj,Underline.PaleVioletRed,Style.NoUnderline,sep) + @staticmethod + def DeepPink(*obj, sep=sep_): return NCS(obj,Underline.DeepPink,Style.NoUnderline,sep) + @staticmethod + def HotPink(*obj, sep=sep_): return NCS(obj,Underline.HotPink,Style.NoUnderline,sep) + @staticmethod + def LightPink(*obj, sep=sep_): return NCS(obj,Underline.LightPink,Style.NoUnderline,sep) + @staticmethod + def Pink(*obj, sep=sep_): return NCS(obj,Underline.Pink,Style.NoUnderline,sep) + @staticmethod + def AntiqueWhite(*obj, sep=sep_): return NCS(obj,Underline.AntiqueWhite,Style.NoUnderline,sep) + @staticmethod + def Beige(*obj, sep=sep_): return NCS(obj,Underline.Beige,Style.NoUnderline,sep) + @staticmethod + def Bisque(*obj, sep=sep_): return NCS(obj,Underline.Bisque,Style.NoUnderline,sep) + @staticmethod + def BlanchedAlmond(*obj, sep=sep_): return NCS(obj,Underline.BlanchedAlmond,Style.NoUnderline,sep) + @staticmethod + def Wheat(*obj, sep=sep_): return NCS(obj,Underline.Wheat,Style.NoUnderline,sep) + @staticmethod + def CornSilk(*obj, sep=sep_): return NCS(obj,Underline.CornSilk,Style.NoUnderline,sep) + @staticmethod + def LemonChiffon(*obj, sep=sep_): return NCS(obj,Underline.LemonChiffon,Style.NoUnderline,sep) + @staticmethod + def LightGoldenRodYellow(*obj, sep=sep_):return NCS(obj,Underline.LightGoldenRodYellow,Style.NoUnderline,sep) + @staticmethod + def LightYellow(*obj, sep=sep_): return NCS(obj,Underline.LightYellow,Style.NoUnderline,sep) + @staticmethod + def SaddleBrown(*obj, sep=sep_): return NCS(obj,Underline.SaddleBrown,Style.NoUnderline,sep) + @staticmethod + def Sienna(*obj, sep=sep_): return NCS(obj,Underline.Sienna,Style.NoUnderline,sep) + @staticmethod + def Chocolate(*obj, sep=sep_): return NCS(obj,Underline.Chocolate,Style.NoUnderline,sep) + @staticmethod + def Peru(*obj, sep=sep_): return NCS(obj,Underline.Peru,Style.NoUnderline,sep) + @staticmethod + def SandyBrown(*obj, sep=sep_): return NCS(obj,Underline.SandyBrown,Style.NoUnderline,sep) + @staticmethod + def BurlyWood(*obj, sep=sep_): return NCS(obj,Underline.BurlyWood,Style.NoUnderline,sep) + @staticmethod + def Tan(*obj, sep=sep_): return NCS(obj,Underline.Tan,Style.NoUnderline,sep) + @staticmethod + def RosyBrown(*obj, sep=sep_): return NCS(obj,Underline.RosyBrown,Style.NoUnderline,sep) + @staticmethod + def Moccasin(*obj, sep=sep_): return NCS(obj,Underline.Moccasin,Style.NoUnderline,sep) + @staticmethod + def NavajoWhite(*obj, sep=sep_): return NCS(obj,Underline.NavajoWhite,Style.NoUnderline,sep) + @staticmethod + def PeachPuff(*obj, sep=sep_): return NCS(obj,Underline.PeachPuff,Style.NoUnderline,sep) + @staticmethod + def MistyRose(*obj, sep=sep_): return NCS(obj,Underline.MistyRose,Style.NoUnderline,sep) + @staticmethod + def LavenderBlush(*obj, sep=sep_): return NCS(obj,Underline.LavenderBlush,Style.NoUnderline,sep) + @staticmethod + def Linen(*obj, sep=sep_): return NCS(obj,Underline.Linen,Style.NoUnderline,sep) + @staticmethod + def OldLace(*obj, sep=sep_): return NCS(obj,Underline.OldLace,Style.NoUnderline,sep) + @staticmethod + def PapayaWhip(*obj, sep=sep_): return NCS(obj,Underline.PapayaWhip,Style.NoUnderline,sep) + @staticmethod + def WeaShell(*obj, sep=sep_): return NCS(obj,Underline.WeaShell,Style.NoUnderline,sep) + @staticmethod + def MintCream(*obj, sep=sep_): return NCS(obj,Underline.MintCream,Style.NoUnderline,sep) + @staticmethod + def SlateGray(*obj, sep=sep_): return NCS(obj,Underline.SlateGray,Style.NoUnderline,sep) + @staticmethod + def LightSlateGray(*obj, sep=sep_): return NCS(obj,Underline.LightSlateGray,Style.NoUnderline,sep) + @staticmethod + def LightSteelBlue(*obj, sep=sep_): return NCS(obj,Underline.LightSteelBlue,Style.NoUnderline,sep) + @staticmethod + def Lavender(*obj, sep=sep_): return NCS(obj,Underline.Lavender,Style.NoUnderline,sep) + @staticmethod + def FloralWhite(*obj, sep=sep_): return NCS(obj,Underline.FloralWhite,Style.NoUnderline,sep) + @staticmethod + def AliceBlue(*obj, sep=sep_): return NCS(obj,Underline.AliceBlue,Style.NoUnderline,sep) + @staticmethod + def GhostWhite(*obj, sep=sep_): return NCS(obj,Underline.GhostWhite,Style.NoUnderline,sep) + @staticmethod + def Honeydew(*obj, sep=sep_): return NCS(obj,Underline.Honeydew,Style.NoUnderline,sep) + @staticmethod + def Ivory(*obj, sep=sep_): return NCS(obj,Underline.Ivory,Style.NoUnderline,sep) + @staticmethod + def Azure(*obj, sep=sep_): return NCS(obj,Underline.Azure,Style.NoUnderline,sep) + @staticmethod + def Snow(*obj, sep=sep_): return NCS(obj,Underline.Snow,Style.NoUnderline,sep) + @staticmethod + def Black(*obj, sep=sep_): return NCS(obj,Underline.Black,Style.NoUnderline,sep) + @staticmethod + def DimGray(*obj, sep=sep_): return NCS(obj,Underline.DimGray,Style.NoUnderline,sep) + @staticmethod + def Gray(*obj, sep=sep_): return NCS(obj,Underline.Gray,Style.NoUnderline,sep) + @staticmethod + def DarkGray(*obj, sep=sep_): return NCS(obj,Underline.DarkGray,Style.NoUnderline,sep) + @staticmethod + def Silver(*obj, sep=sep_): return NCS(obj,Underline.Silver,Style.NoUnderline,sep) + @staticmethod + def LightGray(*obj, sep=sep_): return NCS(obj,Underline.LightGray,Style.NoUnderline,sep) + @staticmethod + def Gainsboro(*obj, sep=sep_): return NCS(obj,Underline.Gainsboro,Style.NoUnderline,sep) + @staticmethod + def WhiteSmoke(*obj, sep=sep_): return NCS(obj,Underline.WhiteSmoke,Style.NoUnderline,sep) + @staticmethod + def White(*obj, sep=sep_): return NCS(obj,Underline.White,Style.NoUnderline,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 )