tbapi.api.models.color
1from __future__ import annotations 2from typing import TYPE_CHECKING 3from tbapi.common.decorators import tb_class 4from tbapi.common.converters import to_python_datetime, to_net_datetime 5from datetime import datetime 6from Tickblaze.Scripts.Api.Models import Color as _Color 7from typing import Any, overload 8 9@tb_class(_Color) 10class Color(): 11 """Represents a color with alpha, red, green, and blue values. The alpha value of the color. The red value of the color. The green value of the color. The blue value of the color.""" 12 13 @overload 14 @staticmethod 15 def new(a: int, r: int, g: int, b: int) -> "Color": 16 """Constructor overload with arguments: a, r, g, b""" 17 ... 18 @overload 19 @staticmethod 20 def new() -> "Color": 21 """Constructor overload with arguments: """ 22 ... 23 @staticmethod 24 def new(*args, **kwargs): 25 """Generic factory method for Color. Use overloads for IDE type hints.""" 26 return Color(*args, **kwargs) 27 28 @property 29 def a(self) -> int: 30 """The alpha value of the color.""" 31 val = self._value.A 32 return val 33 @a.setter 34 def a(self, val: int): 35 tmp = self._value 36 tmp.A = val 37 self._value = tmp 38 @property 39 def r(self) -> int: 40 """The red value of the color.""" 41 val = self._value.R 42 return val 43 @r.setter 44 def r(self, val: int): 45 tmp = self._value 46 tmp.R = val 47 self._value = tmp 48 @property 49 def g(self) -> int: 50 """The green value of the color.""" 51 val = self._value.G 52 return val 53 @g.setter 54 def g(self, val: int): 55 tmp = self._value 56 tmp.G = val 57 self._value = tmp 58 @property 59 def b(self) -> int: 60 """The blue value of the color.""" 61 val = self._value.B 62 return val 63 @b.setter 64 def b(self, val: int): 65 tmp = self._value 66 tmp.B = val 67 self._value = tmp 68 @property 69 def hex(self) -> str: 70 """The HEX value of the color.""" 71 val = self._value.Hex 72 return val 73 74 def to_rgb_hex(self) -> str: 75 """Converts the color to its RGB hex representation. A string representing the RGB hex value of the color.""" 76 result = self._value.ToRgbHex() 77 return result 78 79 def to_argb_hex(self) -> str: 80 """Converts the color to its ARGB hex representation. A string representing the ARGB hex value of the color.""" 81 result = self._value.ToArgbHex() 82 return result 83 84 def to_rgba_hex(self) -> str: 85 """Converts the color to its RGBA hex representation. A string representing the RGBA hex value of the color.""" 86 result = self._value.ToRgbaHex() 87 return result 88 89 @staticmethod 90 def from_rgb(r: int, g: int, b: int) -> Color: 91 """Creates a color from RGB values. Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified RGB values.""" 92 result = _Color.FromRgb(r, g, b) 93 from tbapi.api.models.color import Color 94 return Color(_existing=result) 95 96 @staticmethod 97 def from_rgba(r: int, g: int, b: int, a: int) -> Color: 98 """Creates a color from RGBA values. Red value (0-255). Green value (0-255). Blue value (0-255). Alpha value (0-255). A new instance with the specified RGBA values.""" 99 result = _Color.FromRgba(r, g, b, a) 100 from tbapi.api.models.color import Color 101 return Color(_existing=result) 102 103 @staticmethod 104 def from_argb(a: int, r: int, g: int, b: int) -> Color: 105 """Creates a color from ARGB values. Alpha value (0-255). Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified ARGB values.""" 106 result = _Color.FromArgb(a, r, g, b) 107 from tbapi.api.models.color import Color 108 return Color(_existing=result) 109 110 @staticmethod 111 def try_parse_hex(hex: str, color: Color) -> bool: 112 """Attempts to parse a from a given HEX string. The HEX string to parse. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.""" 113 result = _Color.TryParseHex(hex, color._value) 114 return result 115 116 @staticmethod 117 def try_parse_from_name(name: str, color: Color) -> bool: 118 """Attempts to parse a from a given name. The name of the color to be parsed. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.""" 119 result = _Color.TryParseFromName(name, color._value) 120 return result 121 122 @staticmethod 123 def from_name(color_name: str, fallback_color_name: str = None) -> Color: 124 """Creates a color from the specified name. The name of the color. The fallback color name if the first is not found. A new instance corresponding to the name.""" 125 result = _Color.FromName(color_name, fallback_color_name) 126 from tbapi.api.models.color import Color 127 return Color(_existing=result) 128 129 @staticmethod 130 def try_parse(hex_or_name: str, fallback_color_name: str, color: Color) -> bool: 131 """Tries to parse a color from a hex string or color name. The hex string or color name. The fallback color name if parsing fails. The resulting color. True if the parsing was successful; otherwise, false.""" 132 result = _Color.TryParse(hex_or_name, fallback_color_name, color._value) 133 return result 134 135 @staticmethod 136 def from_drawing_color(color: Color) -> Color: 137 """Converts a to a . The instance. A new instance representing the system drawing color.""" 138 result = _Color.FromDrawingColor(color) 139 from tbapi.api.models.color import Color 140 return Color(_existing=result) 141 142 143 Empty: 'Color' = None 144 Transparent: 'Color' = None 145 White: 'Color' = None 146 LightGray: 'Color' = None 147 Silver: 'Color' = None 148 CoolGray: 'Color' = None 149 SteelGray: 'Color' = None 150 Gunmetal: 'Color' = None 151 Gray: 'Color' = None 152 DimGray: 'Color' = None 153 DarkGray: 'Color' = None 154 Black: 'Color' = None 155 Red: 'Color' = None 156 Orange: 'Color' = None 157 Yellow: 'Color' = None 158 Green: 'Color' = None 159 TealGreen: 'Color' = None 160 Cyan: 'Color' = None 161 Blue: 'Color' = None 162 DeepPurple: 'Color' = None 163 Purple: 'Color' = None 164 Pink: 'Color' = None 165 166Color.Empty = Color(_existing=_Color.Empty) # type: Color 167Color.Transparent = Color(_existing=_Color.Transparent) # type: Color 168Color.White = Color(_existing=_Color.White) # type: Color 169Color.LightGray = Color(_existing=_Color.LightGray) # type: Color 170Color.Silver = Color(_existing=_Color.Silver) # type: Color 171Color.CoolGray = Color(_existing=_Color.CoolGray) # type: Color 172Color.SteelGray = Color(_existing=_Color.SteelGray) # type: Color 173Color.Gunmetal = Color(_existing=_Color.Gunmetal) # type: Color 174Color.Gray = Color(_existing=_Color.Gray) # type: Color 175Color.DimGray = Color(_existing=_Color.DimGray) # type: Color 176Color.DarkGray = Color(_existing=_Color.DarkGray) # type: Color 177Color.Black = Color(_existing=_Color.Black) # type: Color 178Color.Red = Color(_existing=_Color.Red) # type: Color 179Color.Orange = Color(_existing=_Color.Orange) # type: Color 180Color.Yellow = Color(_existing=_Color.Yellow) # type: Color 181Color.Green = Color(_existing=_Color.Green) # type: Color 182Color.TealGreen = Color(_existing=_Color.TealGreen) # type: Color 183Color.Cyan = Color(_existing=_Color.Cyan) # type: Color 184Color.Blue = Color(_existing=_Color.Blue) # type: Color 185Color.DeepPurple = Color(_existing=_Color.DeepPurple) # type: Color 186Color.Purple = Color(_existing=_Color.Purple) # type: Color 187Color.Pink = Color(_existing=_Color.Pink) # type: Color
16@tb_class(_Color) 17class Color(): 18 """Represents a color with alpha, red, green, and blue values. The alpha value of the color. The red value of the color. The green value of the color. The blue value of the color.""" 19 20 @overload 21 @staticmethod 22 def new(a: int, r: int, g: int, b: int) -> "Color": 23 """Constructor overload with arguments: a, r, g, b""" 24 ... 25 @overload 26 @staticmethod 27 def new() -> "Color": 28 """Constructor overload with arguments: """ 29 ... 30 @staticmethod 31 def new(*args, **kwargs): 32 """Generic factory method for Color. Use overloads for IDE type hints.""" 33 return Color(*args, **kwargs) 34 35 @property 36 def a(self) -> int: 37 """The alpha value of the color.""" 38 val = self._value.A 39 return val 40 @a.setter 41 def a(self, val: int): 42 tmp = self._value 43 tmp.A = val 44 self._value = tmp 45 @property 46 def r(self) -> int: 47 """The red value of the color.""" 48 val = self._value.R 49 return val 50 @r.setter 51 def r(self, val: int): 52 tmp = self._value 53 tmp.R = val 54 self._value = tmp 55 @property 56 def g(self) -> int: 57 """The green value of the color.""" 58 val = self._value.G 59 return val 60 @g.setter 61 def g(self, val: int): 62 tmp = self._value 63 tmp.G = val 64 self._value = tmp 65 @property 66 def b(self) -> int: 67 """The blue value of the color.""" 68 val = self._value.B 69 return val 70 @b.setter 71 def b(self, val: int): 72 tmp = self._value 73 tmp.B = val 74 self._value = tmp 75 @property 76 def hex(self) -> str: 77 """The HEX value of the color.""" 78 val = self._value.Hex 79 return val 80 81 def to_rgb_hex(self) -> str: 82 """Converts the color to its RGB hex representation. A string representing the RGB hex value of the color.""" 83 result = self._value.ToRgbHex() 84 return result 85 86 def to_argb_hex(self) -> str: 87 """Converts the color to its ARGB hex representation. A string representing the ARGB hex value of the color.""" 88 result = self._value.ToArgbHex() 89 return result 90 91 def to_rgba_hex(self) -> str: 92 """Converts the color to its RGBA hex representation. A string representing the RGBA hex value of the color.""" 93 result = self._value.ToRgbaHex() 94 return result 95 96 @staticmethod 97 def from_rgb(r: int, g: int, b: int) -> Color: 98 """Creates a color from RGB values. Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified RGB values.""" 99 result = _Color.FromRgb(r, g, b) 100 from tbapi.api.models.color import Color 101 return Color(_existing=result) 102 103 @staticmethod 104 def from_rgba(r: int, g: int, b: int, a: int) -> Color: 105 """Creates a color from RGBA values. Red value (0-255). Green value (0-255). Blue value (0-255). Alpha value (0-255). A new instance with the specified RGBA values.""" 106 result = _Color.FromRgba(r, g, b, a) 107 from tbapi.api.models.color import Color 108 return Color(_existing=result) 109 110 @staticmethod 111 def from_argb(a: int, r: int, g: int, b: int) -> Color: 112 """Creates a color from ARGB values. Alpha value (0-255). Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified ARGB values.""" 113 result = _Color.FromArgb(a, r, g, b) 114 from tbapi.api.models.color import Color 115 return Color(_existing=result) 116 117 @staticmethod 118 def try_parse_hex(hex: str, color: Color) -> bool: 119 """Attempts to parse a from a given HEX string. The HEX string to parse. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.""" 120 result = _Color.TryParseHex(hex, color._value) 121 return result 122 123 @staticmethod 124 def try_parse_from_name(name: str, color: Color) -> bool: 125 """Attempts to parse a from a given name. The name of the color to be parsed. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.""" 126 result = _Color.TryParseFromName(name, color._value) 127 return result 128 129 @staticmethod 130 def from_name(color_name: str, fallback_color_name: str = None) -> Color: 131 """Creates a color from the specified name. The name of the color. The fallback color name if the first is not found. A new instance corresponding to the name.""" 132 result = _Color.FromName(color_name, fallback_color_name) 133 from tbapi.api.models.color import Color 134 return Color(_existing=result) 135 136 @staticmethod 137 def try_parse(hex_or_name: str, fallback_color_name: str, color: Color) -> bool: 138 """Tries to parse a color from a hex string or color name. The hex string or color name. The fallback color name if parsing fails. The resulting color. True if the parsing was successful; otherwise, false.""" 139 result = _Color.TryParse(hex_or_name, fallback_color_name, color._value) 140 return result 141 142 @staticmethod 143 def from_drawing_color(color: Color) -> Color: 144 """Converts a to a . The instance. A new instance representing the system drawing color.""" 145 result = _Color.FromDrawingColor(color) 146 from tbapi.api.models.color import Color 147 return Color(_existing=result) 148 149 150 Empty: 'Color' = None 151 Transparent: 'Color' = None 152 White: 'Color' = None 153 LightGray: 'Color' = None 154 Silver: 'Color' = None 155 CoolGray: 'Color' = None 156 SteelGray: 'Color' = None 157 Gunmetal: 'Color' = None 158 Gray: 'Color' = None 159 DimGray: 'Color' = None 160 DarkGray: 'Color' = None 161 Black: 'Color' = None 162 Red: 'Color' = None 163 Orange: 'Color' = None 164 Yellow: 'Color' = None 165 Green: 'Color' = None 166 TealGreen: 'Color' = None 167 Cyan: 'Color' = None 168 Blue: 'Color' = None 169 DeepPurple: 'Color' = None 170 Purple: 'Color' = None 171 Pink: 'Color' = None
Represents a color with alpha, red, green, and blue values. The alpha value of the color. The red value of the color. The green value of the color. The blue value of the color.
30 @staticmethod 31 def new(*args, **kwargs): 32 """Generic factory method for Color. Use overloads for IDE type hints.""" 33 return Color(*args, **kwargs)
Generic factory method for Color. Use overloads for IDE type hints.
35 @property 36 def a(self) -> int: 37 """The alpha value of the color.""" 38 val = self._value.A 39 return val
The alpha value of the color.
45 @property 46 def r(self) -> int: 47 """The red value of the color.""" 48 val = self._value.R 49 return val
The red value of the color.
55 @property 56 def g(self) -> int: 57 """The green value of the color.""" 58 val = self._value.G 59 return val
The green value of the color.
65 @property 66 def b(self) -> int: 67 """The blue value of the color.""" 68 val = self._value.B 69 return val
The blue value of the color.
75 @property 76 def hex(self) -> str: 77 """The HEX value of the color.""" 78 val = self._value.Hex 79 return val
The HEX value of the color.
81 def to_rgb_hex(self) -> str: 82 """Converts the color to its RGB hex representation. A string representing the RGB hex value of the color.""" 83 result = self._value.ToRgbHex() 84 return result
Converts the color to its RGB hex representation. A string representing the RGB hex value of the color.
86 def to_argb_hex(self) -> str: 87 """Converts the color to its ARGB hex representation. A string representing the ARGB hex value of the color.""" 88 result = self._value.ToArgbHex() 89 return result
Converts the color to its ARGB hex representation. A string representing the ARGB hex value of the color.
91 def to_rgba_hex(self) -> str: 92 """Converts the color to its RGBA hex representation. A string representing the RGBA hex value of the color.""" 93 result = self._value.ToRgbaHex() 94 return result
Converts the color to its RGBA hex representation. A string representing the RGBA hex value of the color.
96 @staticmethod 97 def from_rgb(r: int, g: int, b: int) -> Color: 98 """Creates a color from RGB values. Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified RGB values.""" 99 result = _Color.FromRgb(r, g, b) 100 from tbapi.api.models.color import Color 101 return Color(_existing=result)
Creates a color from RGB values. Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified RGB values.
103 @staticmethod 104 def from_rgba(r: int, g: int, b: int, a: int) -> Color: 105 """Creates a color from RGBA values. Red value (0-255). Green value (0-255). Blue value (0-255). Alpha value (0-255). A new instance with the specified RGBA values.""" 106 result = _Color.FromRgba(r, g, b, a) 107 from tbapi.api.models.color import Color 108 return Color(_existing=result)
Creates a color from RGBA values. Red value (0-255). Green value (0-255). Blue value (0-255). Alpha value (0-255). A new instance with the specified RGBA values.
110 @staticmethod 111 def from_argb(a: int, r: int, g: int, b: int) -> Color: 112 """Creates a color from ARGB values. Alpha value (0-255). Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified ARGB values.""" 113 result = _Color.FromArgb(a, r, g, b) 114 from tbapi.api.models.color import Color 115 return Color(_existing=result)
Creates a color from ARGB values. Alpha value (0-255). Red value (0-255). Green value (0-255). Blue value (0-255). A new instance with the specified ARGB values.
117 @staticmethod 118 def try_parse_hex(hex: str, color: Color) -> bool: 119 """Attempts to parse a from a given HEX string. The HEX string to parse. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.""" 120 result = _Color.TryParseHex(hex, color._value) 121 return result
Attempts to parse a from a given HEX string. The HEX string to parse. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.
123 @staticmethod 124 def try_parse_from_name(name: str, color: Color) -> bool: 125 """Attempts to parse a from a given name. The name of the color to be parsed. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.""" 126 result = _Color.TryParseFromName(name, color._value) 127 return result
Attempts to parse a from a given name. The name of the color to be parsed. The parsed color if the operation is successful. True if the parsing was successful; otherwise, false.
129 @staticmethod 130 def from_name(color_name: str, fallback_color_name: str = None) -> Color: 131 """Creates a color from the specified name. The name of the color. The fallback color name if the first is not found. A new instance corresponding to the name.""" 132 result = _Color.FromName(color_name, fallback_color_name) 133 from tbapi.api.models.color import Color 134 return Color(_existing=result)
Creates a color from the specified name. The name of the color. The fallback color name if the first is not found. A new instance corresponding to the name.
136 @staticmethod 137 def try_parse(hex_or_name: str, fallback_color_name: str, color: Color) -> bool: 138 """Tries to parse a color from a hex string or color name. The hex string or color name. The fallback color name if parsing fails. The resulting color. True if the parsing was successful; otherwise, false.""" 139 result = _Color.TryParse(hex_or_name, fallback_color_name, color._value) 140 return result
Tries to parse a color from a hex string or color name. The hex string or color name. The fallback color name if parsing fails. The resulting color. True if the parsing was successful; otherwise, false.
142 @staticmethod 143 def from_drawing_color(color: Color) -> Color: 144 """Converts a to a . The instance. A new instance representing the system drawing color.""" 145 result = _Color.FromDrawingColor(color) 146 from tbapi.api.models.color import Color 147 return Color(_existing=result)
Converts a to a . The instance. A new instance representing the system drawing color.