EffectCharacter
Module: terminaltexteffects.engine.base_character
A class representing a single character from the input data.
EffectCharacters are created and managed by the Terminal and are used to apply
animations and effects to individual characters. Additional non-input characters
can be created with Terminal.add_character().
Methods:
| Name | Description |
|---|---|
tick |
Progress the character's animation and motion by one step. |
Attributes:
| Name | Type | Description |
|---|---|---|
character_id |
int
|
The unique ID of the character, generated by the Terminal. |
input_symbol |
str
|
The symbol for the character in the input data. |
input_coord |
Coord
|
The coordinate of the character in the input data. |
is_visible |
bool
|
Whether the character is currently visible and should be printed to the terminal. |
animation |
Animation
|
The animation object that controls the character's appearance. |
motion |
Motion
|
The motion object that controls the character's movement. |
event_handler |
EventHandler
|
The event handler object that handles events related to the character. |
layer |
int
|
The layer of the character. Lower layers are painted first. When characters on the same layer
collide, the character with the higher |
is_fill_character |
bool
|
Whether the character is a fill character. Fill characters are used to fill the empty cells of the Canvas. |
uses_input_preexisting_colors |
bool
|
Whether engine-level |
links |
set[EffectCharacter]
|
Linked neighboring characters used by spanning-tree algorithms. |
neighbors |
dict[str, EffectCharacter | None]
|
Adjacent characters keyed by direction
( |
Source code in terminaltexteffects/engine/base_character.py
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 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | |
character_id
property
The unique ID of the character, generated by the Terminal.
input_coord
property
The coordinate of the character in the input data.
input_symbol
property
The symbol for the character in the input data.
is_active
property
Returns whether the character is currently active.
A character is active when its animation has an incomplete active scene or its motion has an incomplete active path or an active mount. A mount keeps the character active after its blend finishes, until it is released.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the character is active, False if not. |
is_visible
property
Whether the character is currently visible and should be printed to the terminal.
layer
property
writable
Rendering layer used to resolve character collisions.
neighbors
property
Adjacent characters keyed by cardinal direction.
Terminal-owned characters prepare their terminal's complete character graph on first access. Standalone characters receive an independent empty mapping.
__hash__()
Hash by character_id, so sets of characters iterate in the same order on every run.
Equality stays identity. Hashing by memory address made the order of active_characters vary between runs,
and with it the order effects drew random numbers, so --seed didn't reproduce some effects.
Source code in terminaltexteffects/engine/base_character.py
__init__(character_id, symbol, input_column, input_row)
Initialize the character instance with the character ID, symbol, and input coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
character_id
|
int
|
The unique ID of the character, generated by the Terminal. |
required |
symbol
|
str
|
The symbol for the character in the input data. |
required |
input_column
|
int
|
The column of the character in the input data. |
required |
input_row
|
int
|
The row of the character in the input data. |
required |
Source code in terminaltexteffects/engine/base_character.py
__repr__()
Return a string representation of the EffectCharacter instance.
Source code in terminaltexteffects/engine/base_character.py
tick()
Progress the character by one tick.
Motion is advanced first, then animation is stepped so animation logic can react to the character's updated motion state for the same tick.