Colors
src.helpers.colors.hex_to_rgb(color: str) -> list[int]
Convert a hexadecimal color code into RGB value list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color | str | Hexadecimal color code, e.g. #F5D676 | required |
Source code in src\helpers\colors.py
26 27 28 29 30 31 32 33 34 35 36 |
|
src.helpers.colors.rgb_black() -> SolidColor
Creates a black SolidColor object.
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object. |
Source code in src\helpers\colors.py
44 45 46 47 48 49 50 |
|
src.helpers.colors.rgb_grey() -> SolidColor
Creates a grey SolidColor object.
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object. |
Source code in src\helpers\colors.py
53 54 55 56 57 58 59 |
|
src.helpers.colors.rgb_white() -> SolidColor
Creates a white SolidColor object.
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object. |
Source code in src\helpers\colors.py
62 63 64 65 66 67 68 |
|
src.helpers.colors.get_rgb(r: int, g: int, b: int) -> SolidColor
Creates a SolidColor object with the given RGB values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r | int | Integer from 0 to 255 for red spectrum. | required |
g | int | Integer from 0 to 255 for green spectrum. | required |
b | int | Integer from 0 to 255 for blue spectrum. | required |
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object. |
Source code in src\helpers\colors.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
src.helpers.colors.get_rgb_from_hex(hex_code: str) -> SolidColor
Creates an RGB SolidColor object with the given hex value. Allows prepending # or without.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hex_code | str | Hexadecimal color code. | required |
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object. |
Source code in src\helpers\colors.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
src.helpers.colors.get_cmyk(c: float, m: float, y: float, k: float) -> SolidColor
Creates a SolidColor object with the given CMYK values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c | float | Float from 0.0 to 100.0 for Cyan component. | required |
m | float | Float from 0.0 to 100.0 for Magenta component. | required |
y | float | Float from 0.0 to 100.0 for Yellow component. | required |
k | float | Float from 0.0 to 100.0 for black component. | required |
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object. |
Source code in src\helpers\colors.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
src.helpers.colors.get_color(color: Union[SolidColor, list[int], str]) -> SolidColor
Automatically get either cmyk or rgb color given a range of possible input notations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color | SolidColor | list[int] | str | List of 3 (RGB) or 4 (CMYK) numbers between 0 and 255, the hex of a color, the name of a known color, or a SolidColor object. | required |
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object. |
Source code in src\helpers\colors.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
src.helpers.colors.get_text_layer_color(layer: ArtLayer) -> SolidColor
Occasionally, Photoshop has issues with retrieving the color of a text layer. This helper guards against errors and null values by defaulting to black in the event of a problem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer | ArtLayer | Layer object that must be TextLayer | required |
Returns:
Type | Description |
---|---|
SolidColor | SolidColor object representing the color of the text item. |
Source code in src\helpers\colors.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
src.helpers.colors.get_text_item_color(item: TextItem) -> SolidColor
Utility definition for get_text_layer_color
, targeting a known TextItem.
Source code in src\helpers\colors.py
179 180 181 182 183 184 185 |
|
src.helpers.colors.apply_rgb_from_list(action: ActionDescriptor, color: list[int], color_type: str = 'color') -> None
Applies RGB color to action descriptor from a list of values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action | ActionDescriptor | ActionDescriptor object. | required |
color | list[int] | List of integers for R, G, B. | required |
color_type | str | Color action descriptor type, defaults to 'color'. | 'color' |
Source code in src\helpers\colors.py
193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
src.helpers.colors.apply_cmyk_from_list(action: ActionDescriptor, color: list[int], color_type: str = 'color') -> None
Applies CMYK color to action descriptor from a list of values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action | ActionDescriptor | ActionDescriptor object. | required |
color | list[int] | List of integers for R, G, B. | required |
color_type | str | Color action descriptor type, defaults to 'color'. | 'color' |
Source code in src\helpers\colors.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
src.helpers.colors.apply_rgb(action: ActionDescriptor, c: SolidColor, color_type: str = 'color') -> None
Apply RGB SolidColor object to action descriptor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action | ActionDescriptor | ActionDescriptor object. | required |
c | SolidColor | SolidColor object matching RGB model. | required |
color_type | str | Color action descriptor type, defaults to 'color'. | 'color' |
Source code in src\helpers\colors.py
224 225 226 227 228 229 230 231 232 |
|
src.helpers.colors.apply_cmyk(action: ActionDescriptor, c: SolidColor, color_type: str = 'color') -> None
Apply CMYK SolidColor object to action descriptor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action | ActionDescriptor | ActionDescriptor object. | required |
c | SolidColor | SolidColor object matching CMYK model. | required |
color_type | str | Color action descriptor type, defaults to 'color'. | 'color' |
Source code in src\helpers\colors.py
235 236 237 238 239 240 241 242 243 |
|
src.helpers.colors.apply_color(action: ActionDescriptor, color: Union[list[int], SolidColor, str], color_type: str = 'color') -> None
Applies color to the specified action descriptor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action | ActionDescriptor | ActionDescriptor object. | required |
color | list[int] | SolidColor | str | RGB/CMYK SolidColor object, list of RGB/CMYK values, a hex string, or a named color. | required |
color_type | str | Color action descriptor type, defaults to 'color'. | 'color' |
Source code in src\helpers\colors.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
src.helpers.colors.add_color_to_gradient(action_list: ActionList, color: SolidColor, location: int, midpoint: int) -> None
Adds a SolidColor to gradient at a given location, with a given midpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action_list | ActionList | Action list to add this color to. | required |
color | SolidColor | SolidColor object. | required |
location | int | Location of the color along the track. | required |
midpoint | int | Percentage midpoint between this color and the next. | required |
Source code in src\helpers\colors.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
src.helpers.colors.fill_layer_primary()
Fill active layer using foreground color.
Source code in src\helpers\colors.py
298 299 300 301 302 |
|
src.helpers.colors.get_pinline_gradient(colors: str, color_map: Optional[dict] = None, location_map: dict = None) -> Union[list[int], list[dict]]
Return a gradient color list notation for some given pinline colors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
colors | str | Pinline colors to produce a gradient. | required |
color_map | dict | None | Color map to color the pinlines. | None |
location_map | dict | Location map to position gradients. | None |
Returns:
Type | Description |
---|---|
list[int] | list[dict] | Gradient color list notation. |
Source code in src\helpers\colors.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|