Skip to content

Binarypath

Demo

Quick Start

binarypath.py
from terminaltexteffects.effects.effect_binarypath import BinaryPath

effect = BinaryPath("YourTextHere")
with effect.terminal_output() as terminal:
    for frame in effect:
        terminal.print(frame)

Decodes characters into their binary form. Characters travel from outside the canvas towards their input coordinate, moving at right angles.

Classes:

Name Description
BinaryPath

Decodes characters into their binary form. Characters travel from outside the canvas towards their input coordinate, moving at right angles.

BinaryPathConfig

Configuration for the BinaryPath effect.

BinaryPathIterator

Effect iterator for the BinaryPath effect. Does not normally need to be called directly.

BinaryPath

Bases: BaseEffect

Decodes characters into their binary form. Characters travel from outside the canvas towards their input coordinate, moving at right angles.

Attributes:

Name Type Description
effect_config BinaryPathConfig

Configuration for the BinaryPath effect.

terminal_config TerminalConfig

Configuration for the terminal.

Source code in terminaltexteffects/effects/effect_binarypath.py
class BinaryPath(BaseEffect):
    """Decodes characters into their binary form. Characters travel from outside the canvas towards their input coordinate, moving at right angles.

    Attributes:
        effect_config (BinaryPathConfig): Configuration for the BinaryPath effect.
        terminal_config (TerminalConfig): Configuration for the terminal.


    """

    _config_cls = BinaryPathConfig
    _iterator_cls = BinaryPathIterator

    def __init__(self, input_data: str) -> None:
        """Initializes the BinaryPath effect with the provided input data.

        Args:
            input_data (str): The input data to use for the BinaryPath effect."""
        super().__init__(input_data)

__init__(input_data)

Initializes the BinaryPath effect with the provided input data.

Parameters:

Name Type Description Default
input_data str

The input data to use for the BinaryPath effect.

required
Source code in terminaltexteffects/effects/effect_binarypath.py
def __init__(self, input_data: str) -> None:
    """Initializes the BinaryPath effect with the provided input data.

    Args:
        input_data (str): The input data to use for the BinaryPath effect."""
    super().__init__(input_data)

BinaryPathConfig dataclass

Bases: ArgsDataClass

Configuration for the BinaryPath effect.

Attributes:

Name Type Description
final_gradient_stops tuple[Color, ...]

Tuple of colors for the final color gradient. If only one color is provided, the characters will be displayed in that color.

final_gradient_steps tuple[int, ...] | int

Tuple of the number of gradient steps to use. More steps will create a smoother and longer gradient animation. Valid values are n > 0.

final_gradient_direction Direction

Direction of the final gradient.

binary_colors tuple[Color, ...]

Tuple of colors for the binary characters. Character color is randomly assigned from this list.

movement_speed float

Speed of the binary groups as they travel around the terminal. Valid values are n > 0.

active_binary_groups float

Maximum number of binary groups that are active at any given time as a percentage of the total number of binary groups. Lower this to improve performance. Valid values are 0 < n <= 1.

Source code in terminaltexteffects/effects/effect_binarypath.py
@argclass(
    name="binarypath",
    help="Binary representations of each character move through the terminal towards the home coordinate of the character.",
    description="binarypath | Binary representations of each character move through the terminal towards the home coordinate of the character.",
    epilog="""Example: terminaltexteffects binarypath --final-gradient-stops 00d500 007500 --final-gradient-steps 12 --final-gradient-direction vertical --binary-colors 044E29 157e38 45bf55 95ed87 --movement-speed 1.0 --active-binary-groups 0.05""",
)
@dataclass
class BinaryPathConfig(ArgsDataClass):
    """Configuration for the BinaryPath effect.

    Attributes:
        final_gradient_stops (tuple[Color, ...]): Tuple of colors for the final color gradient. If only one color is provided, the characters will be displayed in that color.
        final_gradient_steps (tuple[int, ...] | int): Tuple of the number of gradient steps to use. More steps will create a smoother and longer gradient animation. Valid values are n > 0.
        final_gradient_direction (Gradient.Direction): Direction of the final gradient.
        binary_colors (tuple[Color, ...]): Tuple of colors for the binary characters. Character color is randomly assigned from this list.
        movement_speed (float): Speed of the binary groups as they travel around the terminal. Valid values are n > 0.
        active_binary_groups (float): Maximum number of binary groups that are active at any given time as a percentage of the total number of binary groups. Lower this to improve performance. Valid values are 0 < n <= 1."""

    final_gradient_stops: tuple[Color, ...] = ArgField(
        cmd_name=["--final-gradient-stops"],
        type_parser=argvalidators.ColorArg.type_parser,
        nargs="+",
        default=(Color("00d500"), Color("007500")),
        metavar=argvalidators.ColorArg.METAVAR,
        help="Space separated, unquoted, list of colors for the character gradient (applied from bottom to top). If only one color is provided, the characters will be displayed in that color.",
    )  # type: ignore[assignment]

    "tuple[Color, ...] : Tuple of colors for the final color gradient. If only one color is provided, the characters will be displayed in that color."

    final_gradient_steps: tuple[int, ...] | int = ArgField(
        cmd_name=["--final-gradient-steps"],
        type_parser=argvalidators.PositiveInt.type_parser,
        nargs="+",
        default=12,
        metavar=argvalidators.PositiveInt.METAVAR,
        help="Space separated, unquoted, list of the number of gradient steps to use. More steps will create a smoother and longer gradient animation.",
    )  # type: ignore[assignment]

    "tuple[int, ...] | int : Int or Tuple of ints for the number (n > 0) of gradient steps to use. More steps will create a smoother and longer gradient animation."

    final_gradient_direction: Gradient.Direction = ArgField(
        cmd_name="--final-gradient-direction",
        type_parser=argvalidators.GradientDirection.type_parser,
        default=Gradient.Direction.RADIAL,
        metavar=argvalidators.GradientDirection.METAVAR,
        help="Direction of the final gradient.",
    )  # type: ignore[assignment]

    "Gradient.Direction : Direction of the final gradient."

    binary_colors: tuple[Color, ...] = ArgField(
        cmd_name=["--binary-colors"],
        type_parser=argvalidators.ColorArg.type_parser,
        nargs="+",
        default=(Color("044E29"), Color("157e38"), Color("45bf55"), Color("95ed87")),
        metavar=argvalidators.ColorArg.METAVAR,
        help="Space separated, unquoted, list of colors for the binary characters. Character color is randomly assigned from this list.",
    )  # type: ignore[assignment]

    "tuple[Color, ...] : Tuple of colors for the binary characters. Character color is randomly assigned from this list."

    movement_speed: float = ArgField(
        cmd_name="--movement-speed",
        type_parser=argvalidators.PositiveFloat.type_parser,
        default=1.0,
        metavar=argvalidators.PositiveFloat.METAVAR,
        help="Speed of the binary groups as they travel around the terminal.",
    )  # type: ignore[assignment]

    "float : Speed of the binary groups as they travel around the terminal."

    active_binary_groups: float = ArgField(
        cmd_name="--active-binary-groups",
        type_parser=argvalidators.Ratio.type_parser,
        default=0.05,
        metavar=argvalidators.Ratio.METAVAR,
        help="Maximum number of binary groups that are active at any given time as a percentage of the total number of binary groups. Lower this to improve performance.",
    )  # type: ignore[assignment]

    "float : Maximum number of binary groups that are active at any given time as a percentage of the total number of binary groups. Lower this to improve performance."

    @classmethod
    def get_effect_class(cls):
        return BinaryPath

active_binary_groups: float = ArgField(cmd_name='--active-binary-groups', type_parser=argvalidators.Ratio.type_parser, default=0.05, metavar=argvalidators.Ratio.METAVAR, help='Maximum number of binary groups that are active at any given time as a percentage of the total number of binary groups. Lower this to improve performance.') class-attribute instance-attribute

float : Maximum number of binary groups that are active at any given time as a percentage of the total number of binary groups. Lower this to improve performance.

binary_colors: tuple[Color, ...] = ArgField(cmd_name=['--binary-colors'], type_parser=argvalidators.ColorArg.type_parser, nargs='+', default=(Color('044E29'), Color('157e38'), Color('45bf55'), Color('95ed87')), metavar=argvalidators.ColorArg.METAVAR, help='Space separated, unquoted, list of colors for the binary characters. Character color is randomly assigned from this list.') class-attribute instance-attribute

tuple[Color, ...] : Tuple of colors for the binary characters. Character color is randomly assigned from this list.

final_gradient_direction: Gradient.Direction = ArgField(cmd_name='--final-gradient-direction', type_parser=argvalidators.GradientDirection.type_parser, default=Gradient.Direction.RADIAL, metavar=argvalidators.GradientDirection.METAVAR, help='Direction of the final gradient.') class-attribute instance-attribute

Gradient.Direction : Direction of the final gradient.

final_gradient_steps: tuple[int, ...] | int = ArgField(cmd_name=['--final-gradient-steps'], type_parser=argvalidators.PositiveInt.type_parser, nargs='+', default=12, metavar=argvalidators.PositiveInt.METAVAR, help='Space separated, unquoted, list of the number of gradient steps to use. More steps will create a smoother and longer gradient animation.') class-attribute instance-attribute

tuple[int, ...] | int : Int or Tuple of ints for the number (n > 0) of gradient steps to use. More steps will create a smoother and longer gradient animation.

final_gradient_stops: tuple[Color, ...] = ArgField(cmd_name=['--final-gradient-stops'], type_parser=argvalidators.ColorArg.type_parser, nargs='+', default=(Color('00d500'), Color('007500')), metavar=argvalidators.ColorArg.METAVAR, help='Space separated, unquoted, list of colors for the character gradient (applied from bottom to top). If only one color is provided, the characters will be displayed in that color.') class-attribute instance-attribute

tuple[Color, ...] : Tuple of colors for the final color gradient. If only one color is provided, the characters will be displayed in that color.

movement_speed: float = ArgField(cmd_name='--movement-speed', type_parser=argvalidators.PositiveFloat.type_parser, default=1.0, metavar=argvalidators.PositiveFloat.METAVAR, help='Speed of the binary groups as they travel around the terminal.') class-attribute instance-attribute

float : Speed of the binary groups as they travel around the terminal.