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
keythe 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
conditionis true. -
__or__–Combine this operation with
otherso both run in sequence.
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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
then
¶
when
¶
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
__or__
¶
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;
Noneis random. -
key(str | None, default:None) –A name that
CancelEffectcan 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 to500. -
should_reverse(bool, default:False) –bool. Defaults toFalse. -
seed(int | None, default:None) –int | None. Defaults toNone. -
key(str | None, default:None) –str | None. Defaults toNone.
Methods:
-
evaluate–Compute the expression's value.
-
then–An operation that applies this operation, then
other. -
when–An operation that applies only while
conditionis true. -
__or__–Combine this operation with
otherso 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:
-
foreground(ColorValue | Expression[ColorValue] | None) –The text color, or
Noneto leave the foreground unchanged. -
duration_milliseconds(int | Expression[int | float]) –The timer length in milliseconds, or
Nonefor an effect without its own timer. -
kind(str | Expression[str]) –The constructor name describing what this effect does.
-
interpolation(str | Expression[str]) –The easing curve of this effect, or
Nonewhen it has no timer of its own. -
key(str | Expression[str] | None) –The optional name under which a running effect can be replaced or cancelled.
-
background(ColorValue | Expression[ColorValue] | None) –The background color, or
Noneto leave the background unchanged. -
children(Sequence[Effect]) –The effects combined or wrapped by this effect, in execution order.
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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.
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
¶
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
then
¶
when
¶
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
__or__
¶
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:
-
symbols(EvolveSymbolSet | Expression[str] | None, default:None) –The symbol set;
'circles'by default. -
style(Style | DynamicStyle | None, default:None) –A style applied to the symbols.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the effect lasts.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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
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
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
x(int | Expression[int | float] | None, default:None) –Columns to move by.
-
y(int | Expression[int | float] | None, default:None) –Rows to move by.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the move lasts; 500 by default.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
area(Rectangle | Expression[Rectangle]) –Fixed rectangle or expression giving the affected cells.
Returns:
-
Effect–A copy of the effect restricted to
area.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
foreground(ColorValue | Expression[ColorValue] | None) –The text color, or
Noneto leave the foreground unchanged. -
duration_milliseconds(int | Expression[int | float]) –The timer length in milliseconds, or
Nonefor an effect without its own timer. -
kind(str | Expression[str]) –The constructor name describing what this effect does.
-
interpolation(str | Expression[str]) –The easing curve of this effect, or
Nonewhen it has no timer of its own. -
key(str | Expression[str] | None) –The optional name under which a running effect can be replaced or cancelled.
-
background(ColorValue | Expression[ColorValue] | None) –The background color, or
Noneto leave the background unchanged. -
children(Sequence[Effect]) –The effects combined or wrapped by this effect, in execution order.
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 toNone. -
interpolation(str | Expression[str] | None, default:None) –str | Expression[str] | None. Defaults toNone. -
key(str | Expression[str] | None, default:None) –str | Expression[str] | None. Defaults toNone.
Methods:
-
evaluate–Compute the expression's value.
-
then–An operation that applies this operation, then
other. -
when–An operation that applies only while
conditionis true. -
__or__–Combine this operation with
otherso 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
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.
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
¶
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
then
¶
when
¶
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
__or__
¶
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:
-
symbols(EvolveSymbolSet | Expression[str] | None, default:None) –The symbol set;
'circles'by default. -
style(Style | DynamicStyle | None, default:None) –A style applied to the symbols.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the effect lasts.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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
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
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
x(int | Expression[int | float] | None, default:None) –Columns to move by.
-
y(int | Expression[int | float] | None, default:None) –Rows to move by.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the move lasts; 500 by default.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
area(Rectangle | Expression[Rectangle]) –Fixed rectangle or expression giving the affected cells.
Returns:
-
Effect–A copy of the effect restricted to
area.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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
Noneto leave it. -
background(ColorValue | None, default:None) –The color the background fades to, or
Noneto 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
CancelEffectcan 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 toNone. -
background(ColorValue | None, default:None) –ColorValue | None. Defaults toNone. -
duration_milliseconds(int, default:500) –int. Defaults to500. -
interpolation(Interpolation, default:'linear') –Interpolation. Defaults to'linear'. -
key(str | None, default:None) –str | None. Defaults toNone.
Methods:
-
evaluate–Compute the expression's value.
-
then–An operation that applies this operation, then
other. -
when–An operation that applies only while
conditionis true. -
__or__–Combine this operation with
otherso 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:
-
foreground(ColorValue | Expression[ColorValue] | None) –The text color, or
Noneto leave the foreground unchanged. -
duration_milliseconds(int | Expression[int | float]) –The timer length in milliseconds, or
Nonefor an effect without its own timer. -
kind(str | Expression[str]) –The constructor name describing what this effect does.
-
interpolation(str | Expression[str]) –The easing curve of this effect, or
Nonewhen it has no timer of its own. -
key(str | Expression[str] | None) –The optional name under which a running effect can be replaced or cancelled.
-
background(ColorValue | Expression[ColorValue] | None) –The background color, or
Noneto leave the background unchanged. -
children(Sequence[Effect]) –The effects combined or wrapped by this effect, in execution order.
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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.
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
¶
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
then
¶
when
¶
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
__or__
¶
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:
-
symbols(EvolveSymbolSet | Expression[str] | None, default:None) –The symbol set;
'circles'by default. -
style(Style | DynamicStyle | None, default:None) –A style applied to the symbols.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the effect lasts.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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
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
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
x(int | Expression[int | float] | None, default:None) –Columns to move by.
-
y(int | Expression[int | float] | None, default:None) –Rows to move by.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the move lasts; 500 by default.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
area(Rectangle | Expression[Rectangle]) –Fixed rectangle or expression giving the affected cells.
Returns:
-
Effect–A copy of the effect restricted to
area.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
Fuzz
¶
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
0to100. -
seed(int | None, default:None) –Seed for a repeatable result;
Noneis 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:
Methods:
-
evaluate–Compute the expression's value.
-
then–An operation that applies this operation, then
other. -
when–An operation that applies only while
conditionis true. -
__or__–Combine this operation with
otherso both run in sequence.
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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
then
¶
when
¶
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
__or__
¶
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.0to1.0. -
duration_milliseconds(int, default:500) –How long the effect plays.
-
seed(int | None, default:None) –Seed for a repeatable result;
Noneis random. -
key(str | None, default:None) –A name that
CancelEffectcan 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 to0.1. -
duration_milliseconds(int, default:500) –int. Defaults to500. -
seed(int | None, default:None) –int | None. Defaults toNone. -
key(str | None, default:None) –str | None. Defaults toNone.
Methods:
-
evaluate–Compute the expression's value.
-
then–An operation that applies this operation, then
other. -
when–An operation that applies only while
conditionis true. -
__or__–Combine this operation with
otherso 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:
-
foreground(ColorValue | Expression[ColorValue] | None) –The text color, or
Noneto leave the foreground unchanged. -
duration_milliseconds(int | Expression[int | float]) –The timer length in milliseconds, or
Nonefor an effect without its own timer. -
kind(str | Expression[str]) –The constructor name describing what this effect does.
-
interpolation(str | Expression[str]) –The easing curve of this effect, or
Nonewhen it has no timer of its own. -
key(str | Expression[str] | None) –The optional name under which a running effect can be replaced or cancelled.
-
background(ColorValue | Expression[ColorValue] | None) –The background color, or
Noneto leave the background unchanged. -
children(Sequence[Effect]) –The effects combined or wrapped by this effect, in execution order.
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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.
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
¶
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
then
¶
when
¶
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
__or__
¶
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:
-
symbols(EvolveSymbolSet | Expression[str] | None, default:None) –The symbol set;
'circles'by default. -
style(Style | DynamicStyle | None, default:None) –A style applied to the symbols.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the effect lasts.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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
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
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
x(int | Expression[int | float] | None, default:None) –Columns to move by.
-
y(int | Expression[int | float] | None, default:None) –Rows to move by.
-
duration_milliseconds(int | Expression[int | float] | None, default:None) –How long the move lasts; 500 by default.
-
interpolation(str | Expression[str] | None, default:None) –The easing curve.
Examples:
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
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:
-
area(Rectangle | Expression[Rectangle]) –Fixed rectangle or expression giving the affected cells.
Returns:
-
Effect–A copy of the effect restricted to
area.
Examples: