SplitTemplate¶
src.templates.split.SplitTemplate
¶
Bases: BaseTemplate
- A template for split cards introduced in Invasion.
Adds
- Must return all properties shared by both halves as a list of two items (left, right).
- Must overwrite a lot of core functionality to navigate rendering 2 cards in one template.
Todo
- Formalize as a vector template, implement 'Modifier' class.
Source code in src\templates\split.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 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 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
Attributes¶
RGB_BLACK: SolidColor
¶
RGB_WHITE: SolidColor
¶
active_layer: Union[ArtLayer, LayerSet]
¶
Union[ArtLayer, LayerSet]: Get the currently active layer in the Photoshop document.
app: PhotoshopHandler
¶
art_action: Optional[Callable]
¶
Function that is called to perform an action on the imported art.
art_action_args: Optional[dict]
¶
Args to pass to art_action.
art_frame: str
¶
art_frame_vertical: str
¶
art_layer: list[ArtLayer]
¶
Art layer for each side.
art_reference: list[ArtLayer]
¶
Art layer positioning reference for each side.
background: str
¶
background_groups: list[LayerSet]
¶
Background group for each side.
background_layer: list[ArtLayer]
¶
Background layer for each side.
background_reference: list[ArtLayer]
¶
Background positioning reference for each side.
basic_watermark_color: SolidColor
¶
Color to use for the Basic Land Watermark.
basic_watermark_color_map: dict
¶
Maps color values for Basic Land Watermark.
basic_watermark_fx: list[LayerEffects]
¶
Defines the layer effects used on the Basic Land Watermark.
border_color: str
¶
Use 'black' unless an alternate color and a valid border group is provided.
border_group: Optional[Union[LayerSet, ArtLayer]]
¶
Optional[Union[LayerSet, ArtLayer]]: Group, or sometimes a layer, containing the card border.
card_groups
¶
Left and Right side parent groups.
color_indicator_layer: Optional[ArtLayer]
¶
Color indicator icon layer.
color_limit: int
¶
One more than the max number of colors this card can split by.
console: type[CONSOLE]
¶
type[CONSOLE]: Console output object used to communicate with the user.
crown_layer: Optional[ArtLayer]
¶
Legendary crown layer.
crown_shadow_layer: Union[ArtLayer, LayerSet, None]
¶
Legendary crown hollow shadow layer.
dfc_group: Optional[LayerSet]
¶
Optional[LayerSet]: Group containing double face elements.
divider_layer: list[Optional[ArtLayer]]
¶
Divider layer for each side. List updated if either side has flavor text.
doc_selection: Selection
¶
docref: Optional[Document]
¶
Optional[Document]: This template's document open in Photoshop.
event: Event
¶
expansion_reference: Optional[ArtLayer]
¶
Expansion symbol reference layer
expansion_reference_right: None
¶
Right side expansion symbol reference.
expansion_references: list[ArtLayer]
¶
Expansion reference for each side.
expansion_symbol_alignments: list[Dimensions]
¶
Alignments used for positioning the expansion symbol
expansion_symbol_layer: Optional[ArtLayer]
¶
Expansion symbol layer, value set during the load_expansion_symbol method.
expansion_symbols: list[Optional[ArtLayer]]
¶
Expansion symbol layers for each side. Right side is generated duplicating the left side.
frame_layer_methods: list[Callable]
¶
list[Callable]: Methods called to insert and enable frame layers.
Functions:
| Name | Description |
|---|---|
`color_border` |
Changes the border color if required and supported by the template. |
`enable_frame_layers` |
|
fuse_group: Optional[LayerSet]
¶
Fuse elements parent group.
fuse_pinline_colors: Union[list[int], list[dict]]
¶
Color definition for Fuse pinlines.
fuse_pinlines: str
¶
Merged pinline colors of each side.
fuse_pinlines_action: Union[psd.create_color_layer, psd.create_gradient_layer]
¶
Action used to render Fuse pinlines.
fuse_pinlines_group: Optional[LayerSet]
¶
Fuse pinlines group.
fuse_textbox_colors: str
¶
Gold if Fuse colors are more than 3, otherwise use Fuse colors.
fuse_textbox_group: Optional[LayerSet]
¶
Fuse textbox group.
hooks: list[Callable]
¶
list[Callable]: List of methods that will be called during the hooks execution step
identity: str
¶
is_art_vertical: bool
¶
is_basic_land: bool
¶
is_centered: list[bool]
¶
Allow centered text for each side independently.
is_collector_promo: bool
¶
is_colorless: bool
¶
is_companion: bool
¶
is_content_aware_enabled: bool
¶
is_creature: bool
¶
is_emblem: bool
¶
is_flipside_creature: bool
¶
is_front: bool
¶
is_fullart: bool
¶
is_fuse: bool
¶
Determine if this is a 'Fuse' split card.
is_hollow_crown: bool
¶
is_hybrid: bool
¶
is_land: bool
¶
is_legendary: bool
¶
is_mdfc: bool
¶
is_miracle: bool
¶
is_name_shifted: bool
¶
is_nyx: bool
¶
is_snow: bool
¶
is_token: bool
¶
is_transform: bool
¶
is_type_shifted: bool
¶
legal_group: LayerSet
¶
mask_group: Optional[LayerSet]
¶
mask_layers: list[ArtLayer]
¶
Blending masks supported by this template.
name_reference: list[ArtLayer]
¶
list[ArtLayer]: Name reference for each side.
output_directory: Path
¶
PathL Directory to save the rendered image.
output_file_name: Path
¶
pinlines: str
¶
pinlines_action: list[Union[psd.create_color_layer, psd.create_gradient_layer]]
¶
Action used to render the pinlines of each side.
pinlines_colors: list[Union[list[int], list[dict]]]
¶
Color definitions used for pinlines of each side.
pinlines_groups: list[LayerSet]
¶
Pinlines group for each side.
pinlines_layer: Optional[ArtLayer]
¶
Pinlines (and textbox) layer.
post_save_methods: list[Callable]
¶
list[Callable]: Methods called after the rendered image is saved.
post_text_methods
¶
Rotate card sideways.
pre_render_methods: list[Callable]
¶
list[Callable]: Methods called before rendering begins.
Functions:
| Name | Description |
|---|---|
`process_layout_data` |
Processes layout data before it is used to generate the card. |
pt_layer: Optional[ArtLayer]
¶
Power and toughness box layer.
pt_reference: Optional[ReferenceLayer]
¶
save_mode: Callable
¶
text: list[FormattedTextLayer]
¶
List of text layer objects to execute.
text_group: Optional[LayerSet]
¶
One text and icons group located in the 'Left' side group.
text_layer_creator: Optional[ArtLayer]
¶
Optional[ArtLayer]: Proxy creator name text layer.
text_layer_mana: list[ArtLayer]
¶
Mana cost text layer for each side.
text_layer_methods: list[Callable]
¶
list[Callable]: Methods called to insert and format text layers.
text_layer_name: list[ArtLayer]
¶
Name text layer for each side.
text_layer_pt: Optional[ArtLayer]
¶
Optional[ArtLayer]: Card power and toughness text layer.
text_layer_rules: list[ArtLayer]
¶
Rules text layer for each side.
text_layer_type: list[ArtLayer]
¶
Typeline text layer for each side.
textbox_groups: list[LayerSet]
¶
Textbox group for each side.
textbox_layer: list[ArtLayer]
¶
Textbox layer for each side.
textbox_reference: list[ArtLayer]
¶
Textbox positioning reference for each side.
transform_icon_layer: Optional[ArtLayer]
¶
Optional[ArtLayer]: Transform icon layer.
twins: str
¶
twins_groups: list[LayerSet]
¶
Twins group for each side.
twins_layer: list[ArtLayer]
¶
Twins layer for each side.
twins_reference: list[ArtLayer]
¶
Twins positioning reference for each side.
type_reference: list[ArtLayer]
¶
list[ArtLayer]: Typeline reference for each side.
watermark_blend_mode: BlendMode
¶
Blend mode to use on the Watermark layer.
watermark_color_map: dict
¶
Maps color values for Watermark.
watermark_colors: list[list[SolidColor]]
¶
A list of 'SolidColor' objects for each face.
watermark_fx: list[list[LayerEffects]]
¶
A list of LayerEffects' objects for each face.
Functions¶
add_basic_watermark_snow_effects(wm: ArtLayer)
¶
Adds optional snow effects for 'Snow' Basic Land watermarks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wm
|
ArtLayer
|
ArtLayer containing the Basic Land Watermark. |
required |
basic_text_layers() -> None
¶
Add basic text layers for each side.
Source code in src\templates\split.py
check_photoshop() -> None
¶
Check if Photoshop is responsive to automation.
Source code in src\templates\_core.py
collector_info() -> None
¶
Format and add the collector info at the bottom.
Source code in src\templates\_core.py
collector_info_artist_only() -> None
¶
Called to generate 'Artist Only' collector info.
Source code in src\templates\_core.py
collector_info_authentic() -> None
¶
Called to generate realistic collector info.
Source code in src\templates\_core.py
collector_info_basic() -> None
¶
Called to generate basic collector info.
Source code in src\templates\_core.py
color_border() -> None
¶
Color this card's border based on given setting.
Source code in src\templates\_core.py
create_basic_watermark() -> None
¶
Builds a basic land watermark.
Source code in src\templates\_core.py
create_blended_layer(group: LayerSet, colors: Union[None, str, list[str]] = None, masks: Optional[list[ArtLayer]] = None, **kwargs)
¶
Either enable a single frame layer or create a multicolor layer using a gradient mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
LayerSet
|
Group to look for the color layers within. |
required |
colors
|
None | str | list[str]
|
Color layers to look for. |
None
|
masks
|
list[ArtLayer] | None
|
Masks to use for blending the layers. |
None
|
Source code in src\templates\_core.py
create_blended_solid_color(group: LayerSet, colors: list[ColorObject], masks: Optional[list[Union[ArtLayer, LayerSet]]] = None, **kwargs) -> None
¶
Either enable a single frame layer or create a multicolor layer using a gradient mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
LayerSet
|
Group to look for the color layers within. |
required |
colors
|
list[ColorObject]
|
Color layers to look for. |
required |
masks
|
list[ArtLayer | LayerSet] | None
|
Masks to use for blending the layers. |
None
|
Source code in src\templates\_core.py
create_watermark() -> None
¶
Render a watermark for each side that has one.
Source code in src\templates\split.py
enable_crown() -> None
¶
enable_frame_layers() -> None
¶
Enable frame layers for each side. Add Fuse layers if required.
Source code in src\templates\split.py
enable_hollow_crown() -> None
¶
execute() -> bool
¶
Perform actions to render the card using this template.
Notes
- Each action is wrapped in an exception check and breakpoint to cancel the thread if a cancellation signal was sent by the user.
- Never override this method!
Source code in src\templates\_core.py
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 | |
format_text_layers() -> None
¶
Validate and execute each formatted text layer.
Source code in src\templates\_core.py
generate_layer(group: Union[ArtLayer, LayerSet], colors: Union[str, ColorObject, list[ColorObject], list[dict]], masks: Optional[list[ArtLayer]] = None, **kwargs) -> Optional[ArtLayer]
¶
Takes information about a frame layer group and routes it to the correct generation function which blends rasterized layers, blends solid color layers, or generates a solid color/gradient adjustment layer.
Notes
The result for a given 'colors' schema: - str: Enable and/or blend one or more texture layers, unless string is a hex color, in which case create a solid color adjustment layer. - list[str]: Blend multiple texture layers. - list[int]: Create a solid color adjustment layer. - list[dict]: Create a gradient adjustment layer. - list[list[int]]: Blend multiple solid color adjustment layers. - list[SolidColor]: Blend multiple solid color adjustment layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
ArtLayer | LayerSet
|
Layer or group containing layers. |
required |
colors
|
str | ColorObject | list[ColorObject] | list[dict]
|
Color definition for this frame layer generation. |
required |
masks
|
list[ArtLayer] | None
|
Masks used to blend this generated layer. |
None
|
Source code in src\templates\_core.py
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 | |
get_template_route(layout, **kwargs) -> BaseTemplate
¶
Overwrite this method to reroute a template class to another class under a set of conditions. See the 'IxalanTemplate' class for an example.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout
|
The card layout object. |
required |
Returns:
| Type | Description |
|---|---|
BaseTemplate
|
Initialized template class object. |
Source code in src\templates\_core.py
hook_creature() -> None
¶
hook_large_mana() -> None
¶
load_artwork(art_file: Optional[str | Path | list[str | Path]] = None, art_layer: Optional[list[ArtLayer]] = None, art_reference: Optional[list[ReferenceLayer]] = None) -> None
¶
Loads the specified art file into the specified layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
art_file
|
str | Path | list[str | Path] | None
|
Optional path (as str or Path) to art file. Will use |
None
|
art_layer
|
list[ArtLayer] | None
|
Optional |
None
|
art_reference
|
list[ReferenceLayer] | None
|
Optional |
None
|
Source code in src\templates\split.py
load_expansion_symbol() -> None
¶
Imports and positions the expansion symbol SVG image.
Source code in src\templates\_core.py
log(text: str, e: Optional[Exception] = None) -> None
¶
Writes a message to console if test mode isn't enabled, logs an exception if provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Message to write to console. |
required |
e
|
Exception | None
|
Exception to log if provided. |
None
|
Source code in src\templates\_core.py
paste_scryfall_scan(rotate: bool = False, visible: bool = True) -> Optional[ArtLayer]
¶
Downloads the card's scryfall scan, pastes it into the document next to the active layer, and frames it to fill the given reference layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotate
|
bool
|
Will rotate the card horizontally if True, useful for Planar cards. |
False
|
visible
|
bool
|
Whether to leave the layer visible or hide it. |
True
|
Returns:
| Type | Description |
|---|---|
ArtLayer | None
|
ArtLayer if Scryfall scan was imported, otherwise None. |
Source code in src\templates\_core.py
process_layout_data() -> None
¶
Performs any required pre-processing on the provided layout data.
Source code in src\templates\_core.py
raise_error(message: str, error: Optional[Exception] = None) -> None
¶
Raise an error on the console display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to be displayed |
required |
error
|
Exception | None
|
Exception object |
None
|
Source code in src\templates\_core.py
raise_warning(message: str, error: Exception = None) -> None
¶
Raise a warning on the console display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to be displayed. |
required |
error
|
Exception
|
Exception object. |
None
|
Source code in src\templates\_core.py
redirect_template(template_class: type[BaseTemplate], template_file: Union[str, Path], layout, **kwargs) -> BaseTemplate
¶
Reroutes template initialization to another template class and PSD file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_class
|
type[BaseTemplate]
|
Template class to reroute to. |
required |
template_file
|
str | Path
|
Filename of the PSD to load with this template class. |
required |
layout
|
The card layout object. |
required |
Returns:
| Type | Description |
|---|---|
BaseTemplate
|
Initialized template class object. |
Source code in src\templates\_core.py
reset() -> None
¶
Reset the document, purge the cache, end await.
rules_text_and_pt_layers() -> None
¶
Add rules and P/T text for each face.
Source code in src\templates\split.py
run_tasks(funcs: list[Callable], message: str, warning: bool = False, args: Union[Iterable[Any], None] = None, kwargs: Optional[dict] = None) -> bool
¶
Run a list of functions, checking for thread cancellation and exceptions on each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
funcs
|
list[Callable]
|
List of functions to perform. |
required |
message
|
str
|
Error message to raise if exception occurs. |
required |
warning
|
bool
|
Warn the user if True, otherwise raise error. |
False
|
args
|
Iterable[Any] | None
|
Optional arguments to pass to the func. Empty tuple if not provided. |
None
|
kwargs
|
dict | None
|
Optional keyword arguments to pass to the func. Empty dict if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if tasks completed, False if exception occurs or thread is cancelled. |