Skip to content

xnano.effects

xnano.effects

xnano.effects

Animated effects that change how a buffer looks over time, such as fading or dissolving.

An effect is applied to a buffer like any operation and runs on the canvas's clock until it finishes or is cancelled.

Classes:

  • CancelEffect –

    Stop the running effect that was started with key.

  • Dissolve –

    Dissolve the glyphs of the target away cell by cell.

  • Effect –

    A composable animation with editable and bindable settings.

  • Fade –

    Fade the colors of the target toward a foreground and background color.

  • Fuzz –

    Replace a percentage of the visible glyphs of the target with noise glyphs, once.

  • Glitch –

    Randomly corrupt and displace glyphs of the target.

CancelEffect

CancelEffect(key: str)

Bases: Operation

Stop the running effect that was started with key.

Parameters:

  • key (str) –

    The key the effect was created with.

Examples:

runtime = Runtime.offscreen(width=10, height=1)
buffer = Buffer(width=10, height=1)
buffer.update(Write('hello'))
runtime.mount(buffer, geometry='inherit')
runtime.step()

buffer.update(Dissolve(duration_milliseconds=100, key='fade-out'))
buffer.update(CancelEffect('fade-out'))
runtime.step()
runtime.advance_clock(100)
runtime.step()
assert runtime.snapshot().lines()[0] == 'hello'

Create a CancelEffect.

Parameters:

  • key (str) –

    str.

Methods:

  • evaluate –

    Compute the expression's value.

  • then –

    An operation that applies this operation, then other.

  • when –

    An operation that applies only while condition is true.

  • __or__ –

    Combine this operation with other so both run in sequence.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(self, key: str) -> None:
    """
    Create a CancelEffect.

    Args:
        key: ``str``.
    """

evaluate

evaluate(context: EvaluationContext) -> ValueType_co

Compute the expression's value.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
context = EvaluationContext(buffer=Buffer(width=5, height=1))
assert (width * 2).evaluate(context) == 10
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def evaluate(self, context: EvaluationContext) -> ValueType_co:
    """
    Compute the expression's value.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        context = EvaluationContext(buffer=Buffer(width=5, height=1))
        assert (width * 2).evaluate(context) == 10
        ```
    """

then

then(other: Operation) -> Operation

An operation that applies this operation, then other.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab').then(Write('c', x=2)))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def then(self, other: Operation) -> Operation:
    """
    An operation that applies this operation, then ``other``.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab').then(Write('c', x=2)))
        assert buffer.text.startswith('abc')
        ```
    """

when

when(condition: Predicate) -> Operation

An operation that applies only while condition is true.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
buffer = Buffer(width=6, height=1)
buffer.update(Write('wide').when(width > 4))
assert buffer.text.startswith('wide')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def when(self, condition: Predicate) -> Operation:
    """
    An operation that applies only while ``condition`` is true.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('wide').when(width > 4))
        assert buffer.text.startswith('wide')
        ```
    """

__or__

__or__(other: Operation) -> Operation

Combine this operation with other so both run in sequence.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab') | Write('c', x=2))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __or__(self, other: Operation) -> Operation:
    """
    Combine this operation with ``other`` so both run in sequence.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab') | Write('c', x=2))
        assert buffer.text.startswith('abc')
        ```
    """

Dissolve

Dissolve(*, duration_milliseconds: int = 500, should_reverse: bool = False, seed: int | None = None, key: str | None = None)

Bases: Effect

Dissolve the glyphs of the target away cell by cell.

With should_reverse the glyphs instead appear cell by cell.

Maps to tachyonfx::fx::dissolve and tachyonfx::fx::coalesce.

Parameters:

  • duration_milliseconds (int, default: 500 ) –

    How long the effect plays.

  • should_reverse (bool, default: False ) –

    Make glyphs appear instead of disappear.

  • seed (int | None, default: None ) –

    Seed for a repeatable cell order; None is random.

  • key (str | None, default: None ) –

    A name that CancelEffect can target.

Examples:

runtime = Runtime.offscreen(width=10, height=1)
buffer = Buffer(width=10, height=1)
buffer.update(Write('hello'))
runtime.mount(buffer, geometry='inherit')
runtime.step()

buffer.update(Dissolve(duration_milliseconds=100, seed=1))
runtime.step()
runtime.advance_clock(100)
runtime.step()
assert runtime.snapshot().lines()[0].strip() == ''

Create a Dissolve.

Parameters:

  • duration_milliseconds (int, default: 500 ) –

    int. Defaults to 500.

  • should_reverse (bool, default: False ) –

    bool. Defaults to False.

  • seed (int | None, default: None ) –

    int | None. Defaults to None.

  • key (str | None, default: None ) –

    str | None. Defaults to None.

Methods:

  • evaluate –

    Compute the expression's value.

  • then –

    An operation that applies this operation, then other.

  • when –

    An operation that applies only while condition is true.

  • __or__ –

    Combine this operation with other so both run in sequence.

  • evolve –

    Step every cell through a set of symbols, from empty to full.

  • evolve_into –

    Step cells through a set of symbols until the content underneath shows.

  • evolve_from –

    Step cells through a set of symbols, starting from the content underneath.

  • expand –

    Grow a style outward from the center, horizontally or vertically.

  • stretch –

    Stretch a style across the area in a direction.

  • explode –

    Blow the cells outward and away.

  • translated –

    Move everything this effect draws by an offset over time.

  • with_area –

    Limit the effect to a rectangle relative to its target.

Attributes:

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(
    self,
    *,
    duration_milliseconds: int = 500,
    should_reverse: bool = False,
    seed: int | None = None,
    key: str | None = None,
) -> None:
    """
    Create a Dissolve.

    Args:
        duration_milliseconds: ``int``. Defaults to ``500``.
        should_reverse: ``bool``. Defaults to ``False``.
        seed: ``int | None``. Defaults to ``None``.
        key: ``str | None``. Defaults to ``None``.
    """

foreground property writable

foreground: ColorValue | Expression[ColorValue] | None

The text color, or None to leave the foreground unchanged.

duration_milliseconds property writable

duration_milliseconds: int | Expression[int | float]

The timer length in milliseconds, or None for an effect without its own timer.

kind property

kind: str | Expression[str]

The constructor name describing what this effect does.

interpolation property writable

interpolation: str | Expression[str]

The easing curve of this effect, or None when it has no timer of its own.

key property writable

key: str | Expression[str] | None

The optional name under which a running effect can be replaced or cancelled.

background property writable

background: ColorValue | Expression[ColorValue] | None

The background color, or None to leave the background unchanged.

children property

children: Sequence[Effect]

The effects combined or wrapped by this effect, in execution order.

evaluate

evaluate(context: EvaluationContext) -> ValueType_co

Compute the expression's value.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
context = EvaluationContext(buffer=Buffer(width=5, height=1))
assert (width * 2).evaluate(context) == 10
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def evaluate(self, context: EvaluationContext) -> ValueType_co:
    """
    Compute the expression's value.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        context = EvaluationContext(buffer=Buffer(width=5, height=1))
        assert (width * 2).evaluate(context) == 10
        ```
    """

then

then(other: Operation) -> Operation

An operation that applies this operation, then other.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab').then(Write('c', x=2)))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def then(self, other: Operation) -> Operation:
    """
    An operation that applies this operation, then ``other``.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab').then(Write('c', x=2)))
        assert buffer.text.startswith('abc')
        ```
    """

when

when(condition: Predicate) -> Operation

An operation that applies only while condition is true.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
buffer = Buffer(width=6, height=1)
buffer.update(Write('wide').when(width > 4))
assert buffer.text.startswith('wide')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def when(self, condition: Predicate) -> Operation:
    """
    An operation that applies only while ``condition`` is true.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('wide').when(width > 4))
        assert buffer.text.startswith('wide')
        ```
    """

__or__

__or__(other: Operation) -> Operation

Combine this operation with other so both run in sequence.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab') | Write('c', x=2))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __or__(self, other: Operation) -> Operation:
    """
    Combine this operation with ``other`` so both run in sequence.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab') | Write('c', x=2))
        assert buffer.text.startswith('abc')
        ```
    """

evolve staticmethod

evolve(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step every cell through a set of symbols, from empty to full.

Maps to tachyonfx::fx::evolve.

Parameters:

Examples:

effect = Effect.evolve('shaded', duration_milliseconds=200)
assert effect.kind == 'evolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step every cell through a set of symbols, from empty to full.

    Maps to [`tachyonfx::fx::evolve`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve.html).

    Args:
        symbols: The symbol set; ``'circles'`` by default.
        style: A style applied to the symbols.
        duration_milliseconds: How long the effect lasts.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.evolve('shaded', duration_milliseconds=200)
        assert effect.kind == 'evolve'
        ```
    """

evolve_into staticmethod

evolve_into(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols until the content underneath shows.

Maps to tachyonfx::fx::evolve_into. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_into(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols until the content underneath shows.

    Maps to [`tachyonfx::fx::evolve_into`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_into.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

evolve_from staticmethod

evolve_from(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols, starting from the content underneath.

Maps to tachyonfx::fx::evolve_from. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_from(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols, starting from the content underneath.

    Maps to [`tachyonfx::fx::evolve_from`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_from.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

expand staticmethod

expand(direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Grow a style outward from the center, horizontally or vertically.

Maps to tachyonfx::fx::expand.

Examples:

effect = Effect.expand('vertical', duration_milliseconds=200)
assert effect.kind == 'expand'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def expand(
    direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Grow a style outward from the center, horizontally or vertically.

    Maps to [`tachyonfx::fx::expand`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.expand.html).

    Examples:
        ```python
        effect = Effect.expand('vertical', duration_milliseconds=200)
        assert effect.kind == 'expand'
        ```
    """

stretch staticmethod

stretch(direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Stretch a style across the area in a direction.

Maps to tachyonfx::fx::stretch.

Examples:

effect = Effect.stretch('up_to_down', duration_milliseconds=200)
assert effect.kind == 'stretch'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def stretch(
    direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up']
    | Expression[str]
    | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Stretch a style across the area in a direction.

    Maps to [`tachyonfx::fx::stretch`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.stretch.html).

    Examples:
        ```python
        effect = Effect.stretch('up_to_down', duration_milliseconds=200)
        assert effect.kind == 'stretch'
        ```
    """

explode staticmethod

explode(*, force: float | Expression[int | float] | None = None, randomness: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Blow the cells outward and away.

Maps to tachyonfx::fx::explode.

Parameters:

  • force (float | Expression[int | float] | None, default: None ) –

    How hard the cells are thrown; 10 by default.

  • randomness (float | Expression[int | float] | None, default: None ) –

    How much the force varies from cell to cell; 3 by default.

  • duration_milliseconds (int | Expression[int | float] | None, default: None ) –

    How long the effect lasts; 800 by default.

  • interpolation (str | Expression[str] | None, default: None ) –

    The easing curve.

Examples:

effect = Effect.explode(force=5.0)
assert effect.kind == 'explode'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def explode(
    *,
    force: float | Expression[int | float] | None = None,
    randomness: float | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Blow the cells outward and away.

    Maps to [`tachyonfx::fx::explode`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.explode.html).

    Args:
        force: How hard the cells are thrown; 10 by default.
        randomness: How much the force varies from cell to cell; 3 by default.
        duration_milliseconds: How long the effect lasts; 800 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.explode(force=5.0)
        assert effect.kind == 'explode'
        ```
    """

translated

translated(*, x: int | Expression[int | float] | None = None, y: int | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Move everything this effect draws by an offset over time.

Maps to tachyonfx::fx::translate.

Parameters:

Examples:

effect = Effect.dissolve().translated(y=-2)
assert effect.kind == 'translate'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def translated(
    self,
    /,
    *,
    x: int | Expression[int | float] | None = None,
    y: int | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Move everything this effect draws by an offset over time.

    Maps to [`tachyonfx::fx::translate`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.translate.html).

    Args:
        x: Columns to move by.
        y: Rows to move by.
        duration_milliseconds: How long the move lasts; 500 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.dissolve().translated(y=-2)
        assert effect.kind == 'translate'
        ```
    """

with_area

with_area(area: Rectangle | Expression[Rectangle]) -> Effect

Limit the effect to a rectangle relative to its target.

An expression is evaluated each frame. Moving or resizing its rectangle preserves the effect's elapsed time.

Maps to tachyonfx::fx::dynamic_area.

Parameters:

Returns:

  • Effect –

    A copy of the effect restricted to area.

Examples:

>>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
>>> effect.kind
'dissolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def with_area(self, /, area: Rectangle | Expression[Rectangle]) -> Effect:
    """
    Limit the effect to a rectangle relative to its target.

    An expression is evaluated each frame. Moving or resizing its rectangle
    preserves the effect's elapsed time.

    Maps to [`tachyonfx::fx::dynamic_area`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.dynamic_area.html).

    Args:
        area: Fixed rectangle or expression giving the affected cells.

    Returns:
        A copy of the effect restricted to ``area``.

    Examples:
        >>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
        >>> effect.kind
        'dissolve'
    """

Effect

Effect(*, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: Operation

A composable animation with editable and bindable settings.

Attributes:

Examples:

effect = Effect.fade_to('red', duration_milliseconds=100)
effect.foreground = 'blue'
assert effect.foreground == Color('blue')
assert isinstance(effect.then(Effect.dissolve()), Effect)

Create a Effect.

Parameters:

  • duration_milliseconds (int | Expression[int | float] | None, default: None ) –

    int | Expression[int | float] | None. Defaults to None.

  • interpolation (str | Expression[str] | None, default: None ) –

    str | Expression[str] | None. Defaults to None.

  • key (str | Expression[str] | None, default: None ) –

    str | Expression[str] | None. Defaults to None.

Methods:

  • evaluate –

    Compute the expression's value.

  • then –

    An operation that applies this operation, then other.

  • when –

    An operation that applies only while condition is true.

  • __or__ –

    Combine this operation with other so both run in sequence.

  • evolve –

    Step every cell through a set of symbols, from empty to full.

  • evolve_into –

    Step cells through a set of symbols until the content underneath shows.

  • evolve_from –

    Step cells through a set of symbols, starting from the content underneath.

  • expand –

    Grow a style outward from the center, horizontally or vertically.

  • stretch –

    Stretch a style across the area in a direction.

  • explode –

    Blow the cells outward and away.

  • translated –

    Move everything this effect draws by an offset over time.

  • with_area –

    Limit the effect to a rectangle relative to its target.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(
    self,
    /,
    *,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
    key: str | Expression[str] | None = None,
) -> None:
    """
    Create a Effect.

    Args:
        duration_milliseconds: ``int | Expression[int | float] | None``. Defaults to ``None``.
        interpolation: ``str | Expression[str] | None``. Defaults to ``None``.
        key: ``str | Expression[str] | None``. Defaults to ``None``.
    """

foreground property writable

foreground: ColorValue | Expression[ColorValue] | None

The text color, or None to leave the foreground unchanged.

duration_milliseconds property writable

duration_milliseconds: int | Expression[int | float]

The timer length in milliseconds, or None for an effect without its own timer.

kind property

kind: str | Expression[str]

The constructor name describing what this effect does.

interpolation property writable

interpolation: str | Expression[str]

The easing curve of this effect, or None when it has no timer of its own.

key property writable

key: str | Expression[str] | None

The optional name under which a running effect can be replaced or cancelled.

background property writable

background: ColorValue | Expression[ColorValue] | None

The background color, or None to leave the background unchanged.

children property

children: Sequence[Effect]

The effects combined or wrapped by this effect, in execution order.

evaluate

evaluate(context: EvaluationContext) -> ValueType_co

Compute the expression's value.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
context = EvaluationContext(buffer=Buffer(width=5, height=1))
assert (width * 2).evaluate(context) == 10
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def evaluate(self, context: EvaluationContext) -> ValueType_co:
    """
    Compute the expression's value.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        context = EvaluationContext(buffer=Buffer(width=5, height=1))
        assert (width * 2).evaluate(context) == 10
        ```
    """

then

then(other: Operation) -> Operation

An operation that applies this operation, then other.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab').then(Write('c', x=2)))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def then(self, other: Operation) -> Operation:
    """
    An operation that applies this operation, then ``other``.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab').then(Write('c', x=2)))
        assert buffer.text.startswith('abc')
        ```
    """

when

when(condition: Predicate) -> Operation

An operation that applies only while condition is true.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
buffer = Buffer(width=6, height=1)
buffer.update(Write('wide').when(width > 4))
assert buffer.text.startswith('wide')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def when(self, condition: Predicate) -> Operation:
    """
    An operation that applies only while ``condition`` is true.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('wide').when(width > 4))
        assert buffer.text.startswith('wide')
        ```
    """

__or__

__or__(other: Operation) -> Operation

Combine this operation with other so both run in sequence.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab') | Write('c', x=2))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __or__(self, other: Operation) -> Operation:
    """
    Combine this operation with ``other`` so both run in sequence.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab') | Write('c', x=2))
        assert buffer.text.startswith('abc')
        ```
    """

evolve staticmethod

evolve(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step every cell through a set of symbols, from empty to full.

Maps to tachyonfx::fx::evolve.

Parameters:

Examples:

effect = Effect.evolve('shaded', duration_milliseconds=200)
assert effect.kind == 'evolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step every cell through a set of symbols, from empty to full.

    Maps to [`tachyonfx::fx::evolve`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve.html).

    Args:
        symbols: The symbol set; ``'circles'`` by default.
        style: A style applied to the symbols.
        duration_milliseconds: How long the effect lasts.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.evolve('shaded', duration_milliseconds=200)
        assert effect.kind == 'evolve'
        ```
    """

evolve_into staticmethod

evolve_into(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols until the content underneath shows.

Maps to tachyonfx::fx::evolve_into. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_into(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols until the content underneath shows.

    Maps to [`tachyonfx::fx::evolve_into`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_into.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

evolve_from staticmethod

evolve_from(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols, starting from the content underneath.

Maps to tachyonfx::fx::evolve_from. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_from(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols, starting from the content underneath.

    Maps to [`tachyonfx::fx::evolve_from`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_from.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

expand staticmethod

expand(direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Grow a style outward from the center, horizontally or vertically.

Maps to tachyonfx::fx::expand.

Examples:

effect = Effect.expand('vertical', duration_milliseconds=200)
assert effect.kind == 'expand'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def expand(
    direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Grow a style outward from the center, horizontally or vertically.

    Maps to [`tachyonfx::fx::expand`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.expand.html).

    Examples:
        ```python
        effect = Effect.expand('vertical', duration_milliseconds=200)
        assert effect.kind == 'expand'
        ```
    """

stretch staticmethod

stretch(direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Stretch a style across the area in a direction.

Maps to tachyonfx::fx::stretch.

Examples:

effect = Effect.stretch('up_to_down', duration_milliseconds=200)
assert effect.kind == 'stretch'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def stretch(
    direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up']
    | Expression[str]
    | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Stretch a style across the area in a direction.

    Maps to [`tachyonfx::fx::stretch`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.stretch.html).

    Examples:
        ```python
        effect = Effect.stretch('up_to_down', duration_milliseconds=200)
        assert effect.kind == 'stretch'
        ```
    """

explode staticmethod

explode(*, force: float | Expression[int | float] | None = None, randomness: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Blow the cells outward and away.

Maps to tachyonfx::fx::explode.

Parameters:

  • force (float | Expression[int | float] | None, default: None ) –

    How hard the cells are thrown; 10 by default.

  • randomness (float | Expression[int | float] | None, default: None ) –

    How much the force varies from cell to cell; 3 by default.

  • duration_milliseconds (int | Expression[int | float] | None, default: None ) –

    How long the effect lasts; 800 by default.

  • interpolation (str | Expression[str] | None, default: None ) –

    The easing curve.

Examples:

effect = Effect.explode(force=5.0)
assert effect.kind == 'explode'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def explode(
    *,
    force: float | Expression[int | float] | None = None,
    randomness: float | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Blow the cells outward and away.

    Maps to [`tachyonfx::fx::explode`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.explode.html).

    Args:
        force: How hard the cells are thrown; 10 by default.
        randomness: How much the force varies from cell to cell; 3 by default.
        duration_milliseconds: How long the effect lasts; 800 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.explode(force=5.0)
        assert effect.kind == 'explode'
        ```
    """

translated

translated(*, x: int | Expression[int | float] | None = None, y: int | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Move everything this effect draws by an offset over time.

Maps to tachyonfx::fx::translate.

Parameters:

Examples:

effect = Effect.dissolve().translated(y=-2)
assert effect.kind == 'translate'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def translated(
    self,
    /,
    *,
    x: int | Expression[int | float] | None = None,
    y: int | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Move everything this effect draws by an offset over time.

    Maps to [`tachyonfx::fx::translate`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.translate.html).

    Args:
        x: Columns to move by.
        y: Rows to move by.
        duration_milliseconds: How long the move lasts; 500 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.dissolve().translated(y=-2)
        assert effect.kind == 'translate'
        ```
    """

with_area

with_area(area: Rectangle | Expression[Rectangle]) -> Effect

Limit the effect to a rectangle relative to its target.

An expression is evaluated each frame. Moving or resizing its rectangle preserves the effect's elapsed time.

Maps to tachyonfx::fx::dynamic_area.

Parameters:

Returns:

  • Effect –

    A copy of the effect restricted to area.

Examples:

>>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
>>> effect.kind
'dissolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def with_area(self, /, area: Rectangle | Expression[Rectangle]) -> Effect:
    """
    Limit the effect to a rectangle relative to its target.

    An expression is evaluated each frame. Moving or resizing its rectangle
    preserves the effect's elapsed time.

    Maps to [`tachyonfx::fx::dynamic_area`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.dynamic_area.html).

    Args:
        area: Fixed rectangle or expression giving the affected cells.

    Returns:
        A copy of the effect restricted to ``area``.

    Examples:
        >>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
        >>> effect.kind
        'dissolve'
    """

Fade

Fade(*, foreground: ColorValue | None = None, background: ColorValue | None = None, duration_milliseconds: int = 500, interpolation: Interpolation = 'linear', key: str | None = None)

Bases: Effect

Fade the colors of the target toward a foreground and background color.

Maps to tachyonfx::fx::fade_to.

Parameters:

  • foreground (ColorValue | None, default: None ) –

    The color the foreground fades to, or None to leave it.

  • background (ColorValue | None, default: None ) –

    The color the background fades to, or None to leave it.

  • duration_milliseconds (int, default: 500 ) –

    How long the fade plays.

  • interpolation (Interpolation, default: 'linear' ) –

    How progress eases over the duration.

  • key (str | None, default: None ) –

    A name that CancelEffect can target.

Examples:

runtime = Runtime.offscreen(width=10, height=1)
buffer = Buffer(width=10, height=1)
buffer.update(Write('hello', style=Style('white', 'black')))
runtime.mount(buffer, geometry='inherit')
runtime.step()

buffer.update(Fade(foreground='red', duration_milliseconds=100))
runtime.step()
runtime.advance_clock(100)
runtime.step()
assert '31' in runtime.snapshot().ansi

Create a Fade.

Parameters:

  • foreground (ColorValue | None, default: None ) –

    ColorValue | None. Defaults to None.

  • background (ColorValue | None, default: None ) –

    ColorValue | None. Defaults to None.

  • duration_milliseconds (int, default: 500 ) –

    int. Defaults to 500.

  • interpolation (Interpolation, default: 'linear' ) –

    Interpolation. Defaults to 'linear'.

  • key (str | None, default: None ) –

    str | None. Defaults to None.

Methods:

  • evaluate –

    Compute the expression's value.

  • then –

    An operation that applies this operation, then other.

  • when –

    An operation that applies only while condition is true.

  • __or__ –

    Combine this operation with other so both run in sequence.

  • evolve –

    Step every cell through a set of symbols, from empty to full.

  • evolve_into –

    Step cells through a set of symbols until the content underneath shows.

  • evolve_from –

    Step cells through a set of symbols, starting from the content underneath.

  • expand –

    Grow a style outward from the center, horizontally or vertically.

  • stretch –

    Stretch a style across the area in a direction.

  • explode –

    Blow the cells outward and away.

  • translated –

    Move everything this effect draws by an offset over time.

  • with_area –

    Limit the effect to a rectangle relative to its target.

Attributes:

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(
    self,
    *,
    foreground: ColorValue | None = None,
    background: ColorValue | None = None,
    duration_milliseconds: int = 500,
    interpolation: Interpolation = 'linear',
    key: str | None = None,
) -> None:
    """
    Create a Fade.

    Args:
        foreground: ``ColorValue | None``. Defaults to ``None``.
        background: ``ColorValue | None``. Defaults to ``None``.
        duration_milliseconds: ``int``. Defaults to ``500``.
        interpolation: ``Interpolation``. Defaults to ``'linear'``.
        key: ``str | None``. Defaults to ``None``.
    """

foreground property writable

foreground: ColorValue | Expression[ColorValue] | None

The text color, or None to leave the foreground unchanged.

duration_milliseconds property writable

duration_milliseconds: int | Expression[int | float]

The timer length in milliseconds, or None for an effect without its own timer.

kind property

kind: str | Expression[str]

The constructor name describing what this effect does.

interpolation property writable

interpolation: str | Expression[str]

The easing curve of this effect, or None when it has no timer of its own.

key property writable

key: str | Expression[str] | None

The optional name under which a running effect can be replaced or cancelled.

background property writable

background: ColorValue | Expression[ColorValue] | None

The background color, or None to leave the background unchanged.

children property

children: Sequence[Effect]

The effects combined or wrapped by this effect, in execution order.

evaluate

evaluate(context: EvaluationContext) -> ValueType_co

Compute the expression's value.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
context = EvaluationContext(buffer=Buffer(width=5, height=1))
assert (width * 2).evaluate(context) == 10
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def evaluate(self, context: EvaluationContext) -> ValueType_co:
    """
    Compute the expression's value.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        context = EvaluationContext(buffer=Buffer(width=5, height=1))
        assert (width * 2).evaluate(context) == 10
        ```
    """

then

then(other: Operation) -> Operation

An operation that applies this operation, then other.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab').then(Write('c', x=2)))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def then(self, other: Operation) -> Operation:
    """
    An operation that applies this operation, then ``other``.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab').then(Write('c', x=2)))
        assert buffer.text.startswith('abc')
        ```
    """

when

when(condition: Predicate) -> Operation

An operation that applies only while condition is true.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
buffer = Buffer(width=6, height=1)
buffer.update(Write('wide').when(width > 4))
assert buffer.text.startswith('wide')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def when(self, condition: Predicate) -> Operation:
    """
    An operation that applies only while ``condition`` is true.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('wide').when(width > 4))
        assert buffer.text.startswith('wide')
        ```
    """

__or__

__or__(other: Operation) -> Operation

Combine this operation with other so both run in sequence.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab') | Write('c', x=2))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __or__(self, other: Operation) -> Operation:
    """
    Combine this operation with ``other`` so both run in sequence.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab') | Write('c', x=2))
        assert buffer.text.startswith('abc')
        ```
    """

evolve staticmethod

evolve(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step every cell through a set of symbols, from empty to full.

Maps to tachyonfx::fx::evolve.

Parameters:

Examples:

effect = Effect.evolve('shaded', duration_milliseconds=200)
assert effect.kind == 'evolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step every cell through a set of symbols, from empty to full.

    Maps to [`tachyonfx::fx::evolve`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve.html).

    Args:
        symbols: The symbol set; ``'circles'`` by default.
        style: A style applied to the symbols.
        duration_milliseconds: How long the effect lasts.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.evolve('shaded', duration_milliseconds=200)
        assert effect.kind == 'evolve'
        ```
    """

evolve_into staticmethod

evolve_into(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols until the content underneath shows.

Maps to tachyonfx::fx::evolve_into. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_into(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols until the content underneath shows.

    Maps to [`tachyonfx::fx::evolve_into`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_into.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

evolve_from staticmethod

evolve_from(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols, starting from the content underneath.

Maps to tachyonfx::fx::evolve_from. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_from(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols, starting from the content underneath.

    Maps to [`tachyonfx::fx::evolve_from`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_from.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

expand staticmethod

expand(direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Grow a style outward from the center, horizontally or vertically.

Maps to tachyonfx::fx::expand.

Examples:

effect = Effect.expand('vertical', duration_milliseconds=200)
assert effect.kind == 'expand'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def expand(
    direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Grow a style outward from the center, horizontally or vertically.

    Maps to [`tachyonfx::fx::expand`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.expand.html).

    Examples:
        ```python
        effect = Effect.expand('vertical', duration_milliseconds=200)
        assert effect.kind == 'expand'
        ```
    """

stretch staticmethod

stretch(direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Stretch a style across the area in a direction.

Maps to tachyonfx::fx::stretch.

Examples:

effect = Effect.stretch('up_to_down', duration_milliseconds=200)
assert effect.kind == 'stretch'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def stretch(
    direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up']
    | Expression[str]
    | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Stretch a style across the area in a direction.

    Maps to [`tachyonfx::fx::stretch`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.stretch.html).

    Examples:
        ```python
        effect = Effect.stretch('up_to_down', duration_milliseconds=200)
        assert effect.kind == 'stretch'
        ```
    """

explode staticmethod

explode(*, force: float | Expression[int | float] | None = None, randomness: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Blow the cells outward and away.

Maps to tachyonfx::fx::explode.

Parameters:

  • force (float | Expression[int | float] | None, default: None ) –

    How hard the cells are thrown; 10 by default.

  • randomness (float | Expression[int | float] | None, default: None ) –

    How much the force varies from cell to cell; 3 by default.

  • duration_milliseconds (int | Expression[int | float] | None, default: None ) –

    How long the effect lasts; 800 by default.

  • interpolation (str | Expression[str] | None, default: None ) –

    The easing curve.

Examples:

effect = Effect.explode(force=5.0)
assert effect.kind == 'explode'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def explode(
    *,
    force: float | Expression[int | float] | None = None,
    randomness: float | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Blow the cells outward and away.

    Maps to [`tachyonfx::fx::explode`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.explode.html).

    Args:
        force: How hard the cells are thrown; 10 by default.
        randomness: How much the force varies from cell to cell; 3 by default.
        duration_milliseconds: How long the effect lasts; 800 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.explode(force=5.0)
        assert effect.kind == 'explode'
        ```
    """

translated

translated(*, x: int | Expression[int | float] | None = None, y: int | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Move everything this effect draws by an offset over time.

Maps to tachyonfx::fx::translate.

Parameters:

Examples:

effect = Effect.dissolve().translated(y=-2)
assert effect.kind == 'translate'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def translated(
    self,
    /,
    *,
    x: int | Expression[int | float] | None = None,
    y: int | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Move everything this effect draws by an offset over time.

    Maps to [`tachyonfx::fx::translate`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.translate.html).

    Args:
        x: Columns to move by.
        y: Rows to move by.
        duration_milliseconds: How long the move lasts; 500 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.dissolve().translated(y=-2)
        assert effect.kind == 'translate'
        ```
    """

with_area

with_area(area: Rectangle | Expression[Rectangle]) -> Effect

Limit the effect to a rectangle relative to its target.

An expression is evaluated each frame. Moving or resizing its rectangle preserves the effect's elapsed time.

Maps to tachyonfx::fx::dynamic_area.

Parameters:

Returns:

  • Effect –

    A copy of the effect restricted to area.

Examples:

>>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
>>> effect.kind
'dissolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def with_area(self, /, area: Rectangle | Expression[Rectangle]) -> Effect:
    """
    Limit the effect to a rectangle relative to its target.

    An expression is evaluated each frame. Moving or resizing its rectangle
    preserves the effect's elapsed time.

    Maps to [`tachyonfx::fx::dynamic_area`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.dynamic_area.html).

    Args:
        area: Fixed rectangle or expression giving the affected cells.

    Returns:
        A copy of the effect restricted to ``area``.

    Examples:
        >>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
        >>> effect.kind
        'dissolve'
    """

Fuzz

Fuzz(intensity: int, *, seed: int | None = None)

Bases: Operation

Replace a percentage of the visible glyphs of the target with noise glyphs, once.

Unlike an Effect it changes the cells immediately and does not need a runtime. Blank and wide cells are left alone.

Parameters:

  • intensity (int) –

    Percentage of glyphs to replace, from 0 to 100.

  • seed (int | None, default: None ) –

    Seed for a repeatable result; None is random.

Examples:

buffer = Buffer(width=5, height=1)
buffer.update(Write('hello'), Fuzz(100, seed=1))
assert buffer.text != 'hello' and len(buffer.text) == 5

Create a Fuzz.

Parameters:

  • intensity (int) –

    int.

  • seed (int | None, default: None ) –

    int | None. Defaults to None.

Methods:

  • evaluate –

    Compute the expression's value.

  • then –

    An operation that applies this operation, then other.

  • when –

    An operation that applies only while condition is true.

  • __or__ –

    Combine this operation with other so both run in sequence.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(self, intensity: int, *, seed: int | None = None) -> None:
    """
    Create a Fuzz.

    Args:
        intensity: ``int``.
        seed: ``int | None``. Defaults to ``None``.
    """

evaluate

evaluate(context: EvaluationContext) -> ValueType_co

Compute the expression's value.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
context = EvaluationContext(buffer=Buffer(width=5, height=1))
assert (width * 2).evaluate(context) == 10
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def evaluate(self, context: EvaluationContext) -> ValueType_co:
    """
    Compute the expression's value.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        context = EvaluationContext(buffer=Buffer(width=5, height=1))
        assert (width * 2).evaluate(context) == 10
        ```
    """

then

then(other: Operation) -> Operation

An operation that applies this operation, then other.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab').then(Write('c', x=2)))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def then(self, other: Operation) -> Operation:
    """
    An operation that applies this operation, then ``other``.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab').then(Write('c', x=2)))
        assert buffer.text.startswith('abc')
        ```
    """

when

when(condition: Predicate) -> Operation

An operation that applies only while condition is true.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
buffer = Buffer(width=6, height=1)
buffer.update(Write('wide').when(width > 4))
assert buffer.text.startswith('wide')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def when(self, condition: Predicate) -> Operation:
    """
    An operation that applies only while ``condition`` is true.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('wide').when(width > 4))
        assert buffer.text.startswith('wide')
        ```
    """

__or__

__or__(other: Operation) -> Operation

Combine this operation with other so both run in sequence.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab') | Write('c', x=2))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __or__(self, other: Operation) -> Operation:
    """
    Combine this operation with ``other`` so both run in sequence.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab') | Write('c', x=2))
        assert buffer.text.startswith('abc')
        ```
    """

Glitch

Glitch(*, intensity: float = 0.1, duration_milliseconds: int = 500, seed: int | None = None, key: str | None = None)

Bases: Effect

Randomly corrupt and displace glyphs of the target.

Maps to tachyonfx::fx::Glitch.

Parameters:

  • intensity (float, default: 0.1 ) –

    Fraction of cells affected, from 0.0 to 1.0.

  • duration_milliseconds (int, default: 500 ) –

    How long the effect plays.

  • seed (int | None, default: None ) –

    Seed for a repeatable result; None is random.

  • key (str | None, default: None ) –

    A name that CancelEffect can target.

Examples:

runtime = Runtime.offscreen(width=10, height=1)
buffer = Buffer(width=10, height=1)
buffer.update(Write('hello'))
runtime.mount(buffer, geometry='inherit')
runtime.step()

buffer.update(Glitch(intensity=1.0, duration_milliseconds=100, seed=1))
runtime.step()
runtime.advance_clock(50)
runtime.step()
assert runtime.snapshot().lines()[0] != 'hello'

Create a Glitch.

Parameters:

  • intensity (float, default: 0.1 ) –

    float. Defaults to 0.1.

  • duration_milliseconds (int, default: 500 ) –

    int. Defaults to 500.

  • seed (int | None, default: None ) –

    int | None. Defaults to None.

  • key (str | None, default: None ) –

    str | None. Defaults to None.

Methods:

  • evaluate –

    Compute the expression's value.

  • then –

    An operation that applies this operation, then other.

  • when –

    An operation that applies only while condition is true.

  • __or__ –

    Combine this operation with other so both run in sequence.

  • evolve –

    Step every cell through a set of symbols, from empty to full.

  • evolve_into –

    Step cells through a set of symbols until the content underneath shows.

  • evolve_from –

    Step cells through a set of symbols, starting from the content underneath.

  • expand –

    Grow a style outward from the center, horizontally or vertically.

  • stretch –

    Stretch a style across the area in a direction.

  • explode –

    Blow the cells outward and away.

  • translated –

    Move everything this effect draws by an offset over time.

  • with_area –

    Limit the effect to a rectangle relative to its target.

Attributes:

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(
    self,
    *,
    intensity: float = 0.1,
    duration_milliseconds: int = 500,
    seed: int | None = None,
    key: str | None = None,
) -> None:
    """
    Create a Glitch.

    Args:
        intensity: ``float``. Defaults to ``0.1``.
        duration_milliseconds: ``int``. Defaults to ``500``.
        seed: ``int | None``. Defaults to ``None``.
        key: ``str | None``. Defaults to ``None``.
    """

foreground property writable

foreground: ColorValue | Expression[ColorValue] | None

The text color, or None to leave the foreground unchanged.

duration_milliseconds property writable

duration_milliseconds: int | Expression[int | float]

The timer length in milliseconds, or None for an effect without its own timer.

kind property

kind: str | Expression[str]

The constructor name describing what this effect does.

interpolation property writable

interpolation: str | Expression[str]

The easing curve of this effect, or None when it has no timer of its own.

key property writable

key: str | Expression[str] | None

The optional name under which a running effect can be replaced or cancelled.

background property writable

background: ColorValue | Expression[ColorValue] | None

The background color, or None to leave the background unchanged.

children property

children: Sequence[Effect]

The effects combined or wrapped by this effect, in execution order.

evaluate

evaluate(context: EvaluationContext) -> ValueType_co

Compute the expression's value.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
context = EvaluationContext(buffer=Buffer(width=5, height=1))
assert (width * 2).evaluate(context) == 10
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def evaluate(self, context: EvaluationContext) -> ValueType_co:
    """
    Compute the expression's value.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        context = EvaluationContext(buffer=Buffer(width=5, height=1))
        assert (width * 2).evaluate(context) == 10
        ```
    """

then

then(other: Operation) -> Operation

An operation that applies this operation, then other.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab').then(Write('c', x=2)))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def then(self, other: Operation) -> Operation:
    """
    An operation that applies this operation, then ``other``.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab').then(Write('c', x=2)))
        assert buffer.text.startswith('abc')
        ```
    """

when

when(condition: Predicate) -> Operation

An operation that applies only while condition is true.

Examples:

from xnano_core._xnano_core import _reference

width = _reference('Width', 'numeric_property')
buffer = Buffer(width=6, height=1)
buffer.update(Write('wide').when(width > 4))
assert buffer.text.startswith('wide')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def when(self, condition: Predicate) -> Operation:
    """
    An operation that applies only while ``condition`` is true.

    Examples:
        ```python
        from xnano_core._xnano_core import _reference

        width = _reference('Width', 'numeric_property')
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('wide').when(width > 4))
        assert buffer.text.startswith('wide')
        ```
    """

__or__

__or__(other: Operation) -> Operation

Combine this operation with other so both run in sequence.

Examples:

buffer = Buffer(width=6, height=1)
buffer.update(Write('ab') | Write('c', x=2))
assert buffer.text.startswith('abc')
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __or__(self, other: Operation) -> Operation:
    """
    Combine this operation with ``other`` so both run in sequence.

    Examples:
        ```python
        buffer = Buffer(width=6, height=1)
        buffer.update(Write('ab') | Write('c', x=2))
        assert buffer.text.startswith('abc')
        ```
    """

evolve staticmethod

evolve(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step every cell through a set of symbols, from empty to full.

Maps to tachyonfx::fx::evolve.

Parameters:

Examples:

effect = Effect.evolve('shaded', duration_milliseconds=200)
assert effect.kind == 'evolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step every cell through a set of symbols, from empty to full.

    Maps to [`tachyonfx::fx::evolve`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve.html).

    Args:
        symbols: The symbol set; ``'circles'`` by default.
        style: A style applied to the symbols.
        duration_milliseconds: How long the effect lasts.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.evolve('shaded', duration_milliseconds=200)
        assert effect.kind == 'evolve'
        ```
    """

evolve_into staticmethod

evolve_into(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols until the content underneath shows.

Maps to tachyonfx::fx::evolve_into. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_into(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols until the content underneath shows.

    Maps to [`tachyonfx::fx::evolve_into`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_into.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

evolve_from staticmethod

evolve_from(symbols: EvolveSymbolSet | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Step cells through a set of symbols, starting from the content underneath.

Maps to tachyonfx::fx::evolve_from. Takes the same arguments as evolve.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def evolve_from(
    symbols: EvolveSymbolSet | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Step cells through a set of symbols, starting from the content underneath.

    Maps to [`tachyonfx::fx::evolve_from`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.evolve_from.html).
    Takes the same arguments as [`evolve`][xnano_core._xnano_core.Effect.evolve].
    """

expand staticmethod

expand(direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Grow a style outward from the center, horizontally or vertically.

Maps to tachyonfx::fx::expand.

Examples:

effect = Effect.expand('vertical', duration_milliseconds=200)
assert effect.kind == 'expand'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def expand(
    direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Grow a style outward from the center, horizontally or vertically.

    Maps to [`tachyonfx::fx::expand`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.expand.html).

    Examples:
        ```python
        effect = Effect.expand('vertical', duration_milliseconds=200)
        assert effect.kind == 'expand'
        ```
    """

stretch staticmethod

stretch(direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up'] | Expression[str] | None = None, *, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Stretch a style across the area in a direction.

Maps to tachyonfx::fx::stretch.

Examples:

effect = Effect.stretch('up_to_down', duration_milliseconds=200)
assert effect.kind == 'stretch'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def stretch(
    direction: Literal['left_to_right', 'right_to_left', 'up_to_down', 'down_to_up']
    | Expression[str]
    | None = None,
    *,
    style: Style | DynamicStyle | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Stretch a style across the area in a direction.

    Maps to [`tachyonfx::fx::stretch`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.stretch.html).

    Examples:
        ```python
        effect = Effect.stretch('up_to_down', duration_milliseconds=200)
        assert effect.kind == 'stretch'
        ```
    """

explode staticmethod

explode(*, force: float | Expression[int | float] | None = None, randomness: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Blow the cells outward and away.

Maps to tachyonfx::fx::explode.

Parameters:

  • force (float | Expression[int | float] | None, default: None ) –

    How hard the cells are thrown; 10 by default.

  • randomness (float | Expression[int | float] | None, default: None ) –

    How much the force varies from cell to cell; 3 by default.

  • duration_milliseconds (int | Expression[int | float] | None, default: None ) –

    How long the effect lasts; 800 by default.

  • interpolation (str | Expression[str] | None, default: None ) –

    The easing curve.

Examples:

effect = Effect.explode(force=5.0)
assert effect.kind == 'explode'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def explode(
    *,
    force: float | Expression[int | float] | None = None,
    randomness: float | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Blow the cells outward and away.

    Maps to [`tachyonfx::fx::explode`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.explode.html).

    Args:
        force: How hard the cells are thrown; 10 by default.
        randomness: How much the force varies from cell to cell; 3 by default.
        duration_milliseconds: How long the effect lasts; 800 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.explode(force=5.0)
        assert effect.kind == 'explode'
        ```
    """

translated

translated(*, x: int | Expression[int | float] | None = None, y: int | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: str | Expression[str] | None = None) -> Effect

Move everything this effect draws by an offset over time.

Maps to tachyonfx::fx::translate.

Parameters:

Examples:

effect = Effect.dissolve().translated(y=-2)
assert effect.kind == 'translate'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def translated(
    self,
    /,
    *,
    x: int | Expression[int | float] | None = None,
    y: int | Expression[int | float] | None = None,
    duration_milliseconds: int | Expression[int | float] | None = None,
    interpolation: str | Expression[str] | None = None,
) -> Effect:
    """
    Move everything this effect draws by an offset over time.

    Maps to [`tachyonfx::fx::translate`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.translate.html).

    Args:
        x: Columns to move by.
        y: Rows to move by.
        duration_milliseconds: How long the move lasts; 500 by default.
        interpolation: The easing curve.

    Examples:
        ```python
        effect = Effect.dissolve().translated(y=-2)
        assert effect.kind == 'translate'
        ```
    """

with_area

with_area(area: Rectangle | Expression[Rectangle]) -> Effect

Limit the effect to a rectangle relative to its target.

An expression is evaluated each frame. Moving or resizing its rectangle preserves the effect's elapsed time.

Maps to tachyonfx::fx::dynamic_area.

Parameters:

Returns:

  • Effect –

    A copy of the effect restricted to area.

Examples:

>>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
>>> effect.kind
'dissolve'
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def with_area(self, /, area: Rectangle | Expression[Rectangle]) -> Effect:
    """
    Limit the effect to a rectangle relative to its target.

    An expression is evaluated each frame. Moving or resizing its rectangle
    preserves the effect's elapsed time.

    Maps to [`tachyonfx::fx::dynamic_area`](https://docs.rs/tachyonfx/0.25.2/tachyonfx/fx/fn.dynamic_area.html).

    Args:
        area: Fixed rectangle or expression giving the affected cells.

    Returns:
        A copy of the effect restricted to ``area``.

    Examples:
        >>> effect = Effect.dissolve().with_area(Rectangle(0, 0, 3, 1))
        >>> effect.kind
        'dissolve'
    """