Skip to content

xnano.effects

xnano.effects

xnano.effects

Effects: how content changes over time, in how it looks or how it sounds.

effect builds the parameters of a visual effect (a kind that starts with 'effect.', such as 'effect.fade_to') or a sound effect (a kind that starts with 'audio.', such as 'audio.reverb'). The result is applied with |, update, a hook that returns it, or an effects=[...] list, and assigning one of its fields changes the effect while it runs.

The .fx properties of placements, canvases, canvas.speaker and context start an effect by name instead: placement.fx.fade_to(...), canvas.speaker.fx.reverb(...) and context.fx.fade_to(...). An effects=[...] list takes each effect as a dictionary with its kind, such as {'kind': 'effect.fade_to', 'foreground': 'red'}.

Effect.fade_to(...) in xnano.operations is the operation form of effect('effect.fade_to', ...).

Classes:

Functions:

  • effect –

    Create the parameters of a visual or sound effect.

Attributes:

EffectKind module-attribute

Every kind of effect that effect(kind, ...) accepts: the visual kinds and the sound kinds.

EffectSpecification module-attribute

EffectSpecification: TypeAlias = WritableEffect | PlayableEffect

Any visual or sound effect, as effect returns it.

This is not Effect, the class whose methods build a visual effect for update, and it is not the dictionary form that effects=[...] takes.

PlayableEffectKind module-attribute

PlayableEffectKind: TypeAlias = Literal['audio.bit_crush', 'audio.distortion', 'audio.low_pass', 'audio.high_pass', 'audio.delay', 'audio.reverb', 'audio.tremolo']

The kinds of effect that change how a sound plays.

They are the kinds of effect that start with 'audio.', such as 'audio.reverb'.

WritableEffectKind module-attribute

WritableEffectKind: TypeAlias = Literal['effect.fade_to', 'effect.fade_from', 'effect.paint', 'effect.saturate', 'effect.lighten', 'effect.darken', 'effect.sweep_in', 'effect.sweep_out', 'effect.slide_in', 'effect.slide_out', 'effect.hsl_shift', 'effect.dissolve', 'effect.coalesce', 'effect.glitch', 'effect.sleep', 'effect.evolve', 'effect.evolve_into', 'effect.evolve_from', 'effect.expand', 'effect.stretch', 'effect.explode']

The kinds of effect that change how a buffer looks.

They are the kinds of effect that start with 'effect.', such as 'effect.fade_to'.

Interpolation module-attribute

Interpolation: TypeAlias = Literal['linear', 'back_in', 'back_out', 'back_in_out', 'bounce_in', 'bounce_out', 'bounce_in_out', 'circ_in', 'circ_out', 'circ_in_out', 'cubic_in', 'cubic_out', 'cubic_in_out', 'elastic_in', 'elastic_out', 'elastic_in_out', 'expo_in', 'expo_out', 'expo_in_out', 'quad_in', 'quad_out', 'quad_in_out', 'quart_in', 'quart_out', 'quart_in_out', 'quint_in', 'quint_out', 'quint_in_out', 'sine_in', 'sine_out', 'sine_in_out', 'smooth_step', 'spring', 'reverse', 'ease_in']

How an effect eases between its start and end: 'linear', or a curve such as 'quad_in_out' or 'bounce_out'. 'ease_in' is 'quad_in'.

BitCrushAudioEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('audio.bit_crush', ...).

Attributes:

  • bits (int) –

    Quantization resolution in bits (1 to 16).

  • downsample (int) –

    Sample-hold factor (1 to 256).

bits instance-attribute

bits: int

Quantization resolution in bits (1 to 16).

downsample instance-attribute

downsample: int

Sample-hold factor (1 to 256).

BitCrushAudioEffectSpecification

Bases: BitCrushAudioEffectParametersSchema

The dictionary form of the 'audio.bit_crush' sound effect in effects=[...].

Attributes:

  • kind (Required[Literal['audio.bit_crush']]) –

    Always 'audio.bit_crush'.

bits instance-attribute

bits: int

Quantization resolution in bits (1 to 16).

downsample instance-attribute

downsample: int

Sample-hold factor (1 to 256).

kind instance-attribute

kind: Required[Literal['audio.bit_crush']]

Always 'audio.bit_crush'.

CoalesceEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.coalesce', ...).

Attributes:

style instance-attribute

style: Style | DynamicStyle | None

Style coalesced from.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

CoalesceEffectSpecification

Bases: CoalesceEffectParametersSchema

The dictionary form of the 'effect.coalesce' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.coalesce']]) –

    Always 'effect.coalesce'.

style instance-attribute

style: Style | DynamicStyle | None

Style coalesced from.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.coalesce']]

Always 'effect.coalesce'.

DarkenEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.darken', ...).

Attributes:

foreground instance-attribute

foreground: float | Expression[int | float] | None

Foreground darkness increase, or None.

background instance-attribute

background: float | Expression[int | float] | None

Background darkness increase, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

DarkenEffectSpecification

Bases: DarkenEffectParametersSchema

The dictionary form of the 'effect.darken' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.darken']]) –

    Always 'effect.darken'.

foreground instance-attribute

foreground: float | Expression[int | float] | None

Foreground darkness increase, or None.

background instance-attribute

background: float | Expression[int | float] | None

Background darkness increase, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.darken']]

Always 'effect.darken'.

DelayAudioEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('audio.delay', ...).

Attributes:

time_milliseconds instance-attribute

time_milliseconds: float

Delay time between echoes in milliseconds (1.0 to 2000.0).

feedback instance-attribute

feedback: float

Echo feedback ratio (0.0 to 0.95).

mix instance-attribute

mix: float

Wet/dry mix ratio (0.0 to 1.0).

DelayAudioEffectSpecification

Bases: DelayAudioEffectParametersSchema

The dictionary form of the 'audio.delay' sound effect in effects=[...].

Attributes:

  • kind (Required[Literal['audio.delay']]) –

    Always 'audio.delay'.

time_milliseconds instance-attribute

time_milliseconds: float

Delay time between echoes in milliseconds (1.0 to 2000.0).

feedback instance-attribute

feedback: float

Echo feedback ratio (0.0 to 0.95).

mix instance-attribute

mix: float

Wet/dry mix ratio (0.0 to 1.0).

kind instance-attribute

kind: Required[Literal['audio.delay']]

Always 'audio.delay'.

DissolveEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.dissolve', ...).

Attributes:

style instance-attribute

style: Style | DynamicStyle | None

Style dissolved into.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

DissolveEffectSpecification

Bases: DissolveEffectParametersSchema

The dictionary form of the 'effect.dissolve' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.dissolve']]) –

    Always 'effect.dissolve'.

style instance-attribute

style: Style | DynamicStyle | None

Style dissolved into.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.dissolve']]

Always 'effect.dissolve'.

DistortionAudioEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('audio.distortion', ...).

Attributes:

  • drive (float) –

    Input gain before soft-clipping (0.1 to 100.0).

drive instance-attribute

drive: float

Input gain before soft-clipping (0.1 to 100.0).

DistortionAudioEffectSpecification

Bases: DistortionAudioEffectParametersSchema

The dictionary form of the 'audio.distortion' sound effect in effects=[...].

Attributes:

  • kind (Required[Literal['audio.distortion']]) –

    Always 'audio.distortion'.

drive instance-attribute

drive: float

Input gain before soft-clipping (0.1 to 100.0).

kind instance-attribute

kind: Required[Literal['audio.distortion']]

Always 'audio.distortion'.

EvolveEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.evolve', ...).

Attributes:

symbols instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style instance-attribute

style: Style | DynamicStyle | None

Optional style applied to the evolving symbols.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

EvolveEffectSpecification

Bases: EvolveEffectParametersSchema

The dictionary form of the 'effect.evolve' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.evolve']]) –

    Always 'effect.evolve'.

symbols instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style instance-attribute

style: Style | DynamicStyle | None

Optional style applied to the evolving symbols.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.evolve']]

Always 'effect.evolve'.

EvolveFromEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.evolve_from', ...).

Attributes:

symbols instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style instance-attribute

style: Style | DynamicStyle | None

Optional style applied to the evolving symbols.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

EvolveFromEffectSpecification

Bases: EvolveFromEffectParametersSchema

The dictionary form of the 'effect.evolve_from' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.evolve_from']]) –

    Always 'effect.evolve_from'.

symbols instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style instance-attribute

style: Style | DynamicStyle | None

Optional style applied to the evolving symbols.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.evolve_from']]

Always 'effect.evolve_from'.

EvolveIntoEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.evolve_into', ...).

Attributes:

symbols instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style instance-attribute

style: Style | DynamicStyle | None

Optional style applied to the evolving symbols.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

EvolveIntoEffectSpecification

Bases: EvolveIntoEffectParametersSchema

The dictionary form of the 'effect.evolve_into' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.evolve_into']]) –

    Always 'effect.evolve_into'.

symbols instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style instance-attribute

style: Style | DynamicStyle | None

Optional style applied to the evolving symbols.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.evolve_into']]

Always 'effect.evolve_into'.

ExpandEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.expand', ...).

Attributes:

direction instance-attribute

direction: Literal['horizontal', 'vertical'] | Expression[str] | None

'horizontal' or 'vertical'.

style instance-attribute

style: Style | DynamicStyle | None

Style expanded outward from the center.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

ExpandEffectSpecification

Bases: ExpandEffectParametersSchema

The dictionary form of the 'effect.expand' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.expand']]) –

    Always 'effect.expand'.

direction instance-attribute

direction: Literal['horizontal', 'vertical'] | Expression[str] | None

'horizontal' or 'vertical'.

style instance-attribute

style: Style | DynamicStyle | None

Style expanded outward from the center.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.expand']]

Always 'effect.expand'.

ExplodeEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.explode', ...).

Attributes:

force instance-attribute

force: float | Expression[int | float] | None

Outward force throwing the cells.

randomness instance-attribute

randomness: float | Expression[int | float] | None

Variation in force from cell to cell.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

ExplodeEffectSpecification

Bases: ExplodeEffectParametersSchema

The dictionary form of the 'effect.explode' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.explode']]) –

    Always 'effect.explode'.

force instance-attribute

force: float | Expression[int | float] | None

Outward force throwing the cells.

randomness instance-attribute

randomness: float | Expression[int | float] | None

Variation in force from cell to cell.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.explode']]

Always 'effect.explode'.

FadeFromEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.fade_from', ...).

Attributes:

foreground instance-attribute

foreground: ColorValue | Expression[ColorValue] | None

Starting foreground color, or None.

background instance-attribute

background: ColorValue | Expression[ColorValue] | None

Starting background color, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration of the fade in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

FadeFromEffectSpecification

Bases: FadeFromEffectParametersSchema

The dictionary form of the 'effect.fade_from' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.fade_from']]) –

    Always 'effect.fade_from'.

foreground instance-attribute

foreground: ColorValue | Expression[ColorValue] | None

Starting foreground color, or None.

background instance-attribute

background: ColorValue | Expression[ColorValue] | None

Starting background color, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration of the fade in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.fade_from']]

Always 'effect.fade_from'.

FadeToEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.fade_to', ...).

Attributes:

foreground instance-attribute

foreground: ColorValue | Expression[ColorValue] | None

Target foreground color, or None.

background instance-attribute

background: ColorValue | Expression[ColorValue] | None

Target background color, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration of the fade in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

FadeToEffectSpecification

Bases: FadeToEffectParametersSchema

The dictionary form of the 'effect.fade_to' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.fade_to']]) –

    Always 'effect.fade_to'.

foreground instance-attribute

foreground: ColorValue | Expression[ColorValue] | None

Target foreground color, or None.

background instance-attribute

background: ColorValue | Expression[ColorValue] | None

Target background color, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration of the fade in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.fade_to']]

Always 'effect.fade_to'.

GlitchEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.glitch', ...).

Attributes:

ratio instance-attribute

ratio: float | Expression[int | float] | None

Fraction of cells affected by the glitch.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

start_delay_milliseconds instance-attribute

start_delay_milliseconds: tuple[int, int]

(minimum, maximum) delay before a cell glitches.

action_milliseconds instance-attribute

action_milliseconds: tuple[int, int]

(minimum, maximum) duration of each cell glitch.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

GlitchEffectSpecification

Bases: GlitchEffectParametersSchema

The dictionary form of the 'effect.glitch' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.glitch']]) –

    Always 'effect.glitch'.

ratio instance-attribute

ratio: float | Expression[int | float] | None

Fraction of cells affected by the glitch.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

start_delay_milliseconds instance-attribute

start_delay_milliseconds: tuple[int, int]

(minimum, maximum) delay before a cell glitches.

action_milliseconds instance-attribute

action_milliseconds: tuple[int, int]

(minimum, maximum) duration of each cell glitch.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.glitch']]

Always 'effect.glitch'.

HighPassAudioEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('audio.high_pass', ...).

Attributes:

cutoff instance-attribute

cutoff: float

Corner frequency in hertz (20.0 to 20000.0).

resonance instance-attribute

resonance: float

Filter resonance Q (0.1 to 20.0).

HighPassAudioEffectSpecification

Bases: HighPassAudioEffectParametersSchema

The dictionary form of the 'audio.high_pass' sound effect in effects=[...].

Attributes:

  • kind (Required[Literal['audio.high_pass']]) –

    Always 'audio.high_pass'.

cutoff instance-attribute

cutoff: float

Corner frequency in hertz (20.0 to 20000.0).

resonance instance-attribute

resonance: float

Filter resonance Q (0.1 to 20.0).

kind instance-attribute

kind: Required[Literal['audio.high_pass']]

Always 'audio.high_pass'.

HslShiftEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.hsl_shift', ...).

Attributes:

foreground instance-attribute

foreground: HslShiftTuple | None

(hue, saturation, lightness) shift for foreground colors.

background instance-attribute

background: HslShiftTuple | None

(hue, saturation, lightness) shift for background colors.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

HslShiftEffectSpecification

Bases: HslShiftEffectParametersSchema

The dictionary form of the 'effect.hsl_shift' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.hsl_shift']]) –

    Always 'effect.hsl_shift'.

foreground instance-attribute

foreground: HslShiftTuple | None

(hue, saturation, lightness) shift for foreground colors.

background instance-attribute

background: HslShiftTuple | None

(hue, saturation, lightness) shift for background colors.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.hsl_shift']]

Always 'effect.hsl_shift'.

LightenEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.lighten', ...).

Attributes:

foreground instance-attribute

foreground: float | Expression[int | float] | None

Foreground lightness increase, or None.

background instance-attribute

background: float | Expression[int | float] | None

Background lightness increase, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

LightenEffectSpecification

Bases: LightenEffectParametersSchema

The dictionary form of the 'effect.lighten' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.lighten']]) –

    Always 'effect.lighten'.

foreground instance-attribute

foreground: float | Expression[int | float] | None

Foreground lightness increase, or None.

background instance-attribute

background: float | Expression[int | float] | None

Background lightness increase, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.lighten']]

Always 'effect.lighten'.

LowPassAudioEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('audio.low_pass', ...).

Attributes:

cutoff instance-attribute

cutoff: float

Corner frequency in hertz (20.0 to 20000.0).

resonance instance-attribute

resonance: float

Filter resonance Q (0.1 to 20.0).

LowPassAudioEffectSpecification

Bases: LowPassAudioEffectParametersSchema

The dictionary form of the 'audio.low_pass' sound effect in effects=[...].

Attributes:

  • kind (Required[Literal['audio.low_pass']]) –

    Always 'audio.low_pass'.

cutoff instance-attribute

cutoff: float

Corner frequency in hertz (20.0 to 20000.0).

resonance instance-attribute

resonance: float

Filter resonance Q (0.1 to 20.0).

kind instance-attribute

kind: Required[Literal['audio.low_pass']]

Always 'audio.low_pass'.

PaintEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.paint', ...).

Attributes:

foreground instance-attribute

foreground: ColorValue | Expression[ColorValue] | None

Foreground color to paint, or None.

background instance-attribute

background: ColorValue | Expression[ColorValue] | None

Background color to paint, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

PaintEffectSpecification

Bases: PaintEffectParametersSchema

The dictionary form of the 'effect.paint' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.paint']]) –

    Always 'effect.paint'.

foreground instance-attribute

foreground: ColorValue | Expression[ColorValue] | None

Foreground color to paint, or None.

background instance-attribute

background: ColorValue | Expression[ColorValue] | None

Background color to paint, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.paint']]

Always 'effect.paint'.

ReverbAudioEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('audio.reverb', ...).

Attributes:

  • room (float) –

    Room size (0.0 to 1.0).

  • damping (float) –

    High-frequency damping (0.0 to 1.0).

  • mix (float) –

    Wet/dry mix ratio (0.0 to 1.0).

room instance-attribute

room: float

Room size (0.0 to 1.0).

damping instance-attribute

damping: float

High-frequency damping (0.0 to 1.0).

mix instance-attribute

mix: float

Wet/dry mix ratio (0.0 to 1.0).

ReverbAudioEffectSpecification

Bases: ReverbAudioEffectParametersSchema

The dictionary form of the 'audio.reverb' sound effect in effects=[...].

Attributes:

  • kind (Required[Literal['audio.reverb']]) –

    Always 'audio.reverb'.

room instance-attribute

room: float

Room size (0.0 to 1.0).

damping instance-attribute

damping: float

High-frequency damping (0.0 to 1.0).

mix instance-attribute

mix: float

Wet/dry mix ratio (0.0 to 1.0).

kind instance-attribute

kind: Required[Literal['audio.reverb']]

Always 'audio.reverb'.

SaturateEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.saturate', ...).

Attributes:

foreground instance-attribute

foreground: float | Expression[int | float] | None

Foreground saturation change, or None.

background instance-attribute

background: float | Expression[int | float] | None

Background saturation change, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

SaturateEffectSpecification

Bases: SaturateEffectParametersSchema

The dictionary form of the 'effect.saturate' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.saturate']]) –

    Always 'effect.saturate'.

foreground instance-attribute

foreground: float | Expression[int | float] | None

Foreground saturation change, or None.

background instance-attribute

background: float | Expression[int | float] | None

Background saturation change, or None.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.saturate']]

Always 'effect.saturate'.

SleepEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.sleep', ...).

Attributes:

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float]

Pause duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

SleepEffectSpecification

Bases: SleepEffectParametersSchema

The dictionary form of the 'effect.sleep' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.sleep']]) –

    Always 'effect.sleep'.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float]

Pause duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.sleep']]

Always 'effect.sleep'.

SlideInEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.slide_in', ...).

Attributes:

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Slide direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the gradient trail in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Color behind the sliding cells.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

SlideInEffectSpecification

Bases: SlideInEffectParametersSchema

The dictionary form of the 'effect.slide_in' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.slide_in']]) –

    Always 'effect.slide_in'.

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Slide direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the gradient trail in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Color behind the sliding cells.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.slide_in']]

Always 'effect.slide_in'.

SlideOutEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.slide_out', ...).

Attributes:

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Slide direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the gradient trail in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Color left behind the sliding cells.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

SlideOutEffectSpecification

Bases: SlideOutEffectParametersSchema

The dictionary form of the 'effect.slide_out' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.slide_out']]) –

    Always 'effect.slide_out'.

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Slide direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the gradient trail in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Color left behind the sliding cells.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.slide_out']]

Always 'effect.slide_out'.

StretchEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.stretch', ...).

Attributes:

direction instance-attribute

direction: MotionDirection | Expression[str] | None

'left_to_right', 'right_to_left', 'up_to_down' or 'down_to_up'.

style instance-attribute

style: Style | DynamicStyle | None

Style stretched across the area.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

StretchEffectSpecification

Bases: StretchEffectParametersSchema

The dictionary form of the 'effect.stretch' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.stretch']]) –

    Always 'effect.stretch'.

direction instance-attribute

direction: MotionDirection | Expression[str] | None

'left_to_right', 'right_to_left', 'up_to_down' or 'down_to_up'.

style instance-attribute

style: Style | DynamicStyle | None

Style stretched across the area.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.stretch']]

Always 'effect.stretch'.

SweepInEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.sweep_in', ...).

Attributes:

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Sweep direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the sweep gradient in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Starting sweep color.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

SweepInEffectSpecification

Bases: SweepInEffectParametersSchema

The dictionary form of the 'effect.sweep_in' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.sweep_in']]) –

    Always 'effect.sweep_in'.

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Sweep direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the sweep gradient in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Starting sweep color.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.sweep_in']]

Always 'effect.sweep_in'.

SweepOutEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('effect.sweep_out', ...).

Attributes:

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Sweep direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the sweep gradient in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Ending sweep color.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

SweepOutEffectSpecification

Bases: SweepOutEffectParametersSchema

The dictionary form of the 'effect.sweep_out' visual effect in effects=[...].

Attributes:

  • kind (Required[Literal['effect.sweep_out']]) –

    Always 'effect.sweep_out'.

direction instance-attribute

direction: MotionDirection | Expression[str] | None

Sweep direction (such as 'left_to_right').

gradient_length instance-attribute

gradient_length: int | Expression[int | float] | None

Length of the sweep gradient in cells.

randomness instance-attribute

randomness: int | Expression[int | float] | None

Random offset across rows or columns.

color instance-attribute

color: ColorValue | Expression[ColorValue] | None

Ending sweep color.

duration_milliseconds instance-attribute

duration_milliseconds: int | Expression[int | float] | None

Duration in milliseconds.

interpolation instance-attribute

interpolation: Interpolation | Expression[str] | None

The easing curve, such as 'linear' or 'quad_in_out'.

key instance-attribute

key: str | Expression[str] | None

Optional effect key for replacement or cancellation.

kind instance-attribute

kind: Required[Literal['effect.sweep_out']]

Always 'effect.sweep_out'.

TremoloAudioEffectParametersSchema

Bases: TypedDict

The keyword arguments of effect('audio.tremolo', ...).

Attributes:

rate_hertz instance-attribute

rate_hertz: float

Modulation rate in hertz (0.1 to 40.0).

depth instance-attribute

depth: float

Modulation depth (0.0 to 1.0).

TremoloAudioEffectSpecification

Bases: TremoloAudioEffectParametersSchema

The dictionary form of the 'audio.tremolo' sound effect in effects=[...].

Attributes:

  • kind (Required[Literal['audio.tremolo']]) –

    Always 'audio.tremolo'.

rate_hertz instance-attribute

rate_hertz: float

Modulation rate in hertz (0.1 to 40.0).

depth instance-attribute

depth: float

Modulation depth (0.0 to 1.0).

kind instance-attribute

kind: Required[Literal['audio.tremolo']]

Always 'audio.tremolo'.

EffectController

EffectController(context: Context[object, object])

Bases: _WritableEffectMethods, _PlayableEffectMethods

The effects of the hook that is running, one method for each effect.

Get it from context.fx. A visual effect (context.fx.fade_to(...)) starts on the hook's target, and a sound effect (context.fx.reverb(...)) is added to every sound the hook plays. The effects last while the hook does; clear() ends them sooner, and removing the hook or its placement ends them too. Starting an effect of a kind that is already set replaces the earlier one.

Attributes:

Examples:

import xnano

with xnano.new(width=8, height=1) as canvas:
    label = canvas.screen.write('hi')
    counts = []

    @label.hook(on='frame')
    def tint(context: xnano.Context) -> None:
        if not context.fx.active:
            context.fx.fade_to(foreground='red', duration_milliseconds=100)
        counts.append(len(context.fx.active))

    canvas.clock.step(delta_seconds=0.05)
    assert counts and set(counts) == {1}

Create the controller of a context. Use context.fx instead of calling this.

Parameters:

Methods:

  • bit_crush –

    Lower the resolution of the sound, for a gritty, retro tone.

  • distortion –

    Distort the sound by driving it into soft clipping.

  • low_pass –

    Keep the frequencies below cutoff and soften those above it.

  • high_pass –

    Keep the frequencies above cutoff and soften those below it.

  • delay –

    Repeat the sound as fading echoes.

  • reverb –

    Add the reverberation of a room.

  • tremolo –

    Pulse the volume up and down.

  • fade_to –

    Fade the colors to foreground and background.

  • fade_from –

    Fade the colors in from foreground and background.

  • paint –

    Paint foreground and background over the colors.

  • saturate –

    Make the colors more or less saturated.

  • lighten –

    Lighten the colors.

  • darken –

    Darken the colors.

  • sweep_in –

    Reveal the content behind a sweep of color in direction.

  • sweep_out –

    Hide the content behind a sweep of color in direction.

  • slide_in –

    Slide the content in, in direction.

  • slide_out –

    Slide the content out, in direction.

  • hsl_shift –

    Shift the hue, saturation and lightness of the colors.

  • dissolve –

    Dissolve the content into style, cell by cell.

  • coalesce –

    Bring the content together out of style, cell by cell.

  • glitch –

    Make a share of the cells glitch for a moment.

  • sleep –

    Wait for duration_milliseconds without changing anything.

  • evolve –

    Cycle the cells through a progression of symbols.

  • evolve_into –

    Turn the content into a progression of symbols.

  • evolve_from –

    Grow the content out of a progression of symbols.

  • expand –

    Expand style outward from the center.

  • stretch –

    Stretch style across the area in direction.

  • explode –

    Throw the cells outward.

  • clear –

    End the effects this hook has set.

Source code in xnano/effects/_controller.py
def __init__(self, context: Context[object, object]) -> None:
    """
    Create the controller of a context. Use ``context.fx`` instead of calling this.

    Args:
        context: The context of the hook that applies the effects.
    """
    self._context = context

context property

context: Context[object, object]

The context of the hook that applies the effects.

active property

active: tuple[EffectSpecification, ...]

The effects the hook has set and not cleared or replaced.

bit_crush

Lower the resolution of the sound, for a gritty, retro tone.

Other Parameters:

  • bits (int) –

    Quantization resolution in bits (1 to 16).

  • downsample (int) –

    Sample-hold factor (1 to 256).

Returns:

Source code in xnano/effects/_properties.py
def bit_crush(
    self, **parameters: Unpack[BitCrushAudioEffectParametersSchema]
) -> BitCrushAudioEffectParameters:
    """
    Lower the resolution of the sound, for a gritty, retro tone.

    Keyword Args:
        bits (int): Quantization resolution in bits (``1`` to ``16``).
        downsample (int): Sample-hold factor (``1`` to ``256``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'BitCrushAudioEffectParameters', self._start('audio.bit_crush', parameters)
    )

distortion

Distort the sound by driving it into soft clipping.

Other Parameters:

  • drive (float) –

    Input gain before soft-clipping (0.1 to 100.0).

Returns:

Source code in xnano/effects/_properties.py
def distortion(
    self, **parameters: Unpack[DistortionAudioEffectParametersSchema]
) -> DistortionAudioEffectParameters:
    """
    Distort the sound by driving it into soft clipping.

    Keyword Args:
        drive (float): Input gain before soft-clipping (``0.1`` to ``100.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'DistortionAudioEffectParameters', self._start('audio.distortion', parameters)
    )

low_pass

Keep the frequencies below cutoff and soften those above it.

Other Parameters:

  • cutoff (float) –

    Corner frequency in hertz (20.0 to 20000.0).

  • resonance (float) –

    Filter resonance Q (0.1 to 20.0).

Returns:

Source code in xnano/effects/_properties.py
def low_pass(
    self, **parameters: Unpack[LowPassAudioEffectParametersSchema]
) -> LowPassAudioEffectParameters:
    """
    Keep the frequencies below ``cutoff`` and soften those above it.

    Keyword Args:
        cutoff (float): Corner frequency in hertz (``20.0`` to ``20000.0``).
        resonance (float): Filter resonance Q (``0.1`` to ``20.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'LowPassAudioEffectParameters', self._start('audio.low_pass', parameters)
    )

high_pass

Keep the frequencies above cutoff and soften those below it.

Other Parameters:

  • cutoff (float) –

    Corner frequency in hertz (20.0 to 20000.0).

  • resonance (float) –

    Filter resonance Q (0.1 to 20.0).

Returns:

Source code in xnano/effects/_properties.py
def high_pass(
    self, **parameters: Unpack[HighPassAudioEffectParametersSchema]
) -> HighPassAudioEffectParameters:
    """
    Keep the frequencies above ``cutoff`` and soften those below it.

    Keyword Args:
        cutoff (float): Corner frequency in hertz (``20.0`` to ``20000.0``).
        resonance (float): Filter resonance Q (``0.1`` to ``20.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'HighPassAudioEffectParameters', self._start('audio.high_pass', parameters)
    )

delay

Repeat the sound as fading echoes.

Other Parameters:

  • time_milliseconds (float) –

    Delay time between echoes in milliseconds (1.0 to 2000.0).

  • feedback (float) –

    Echo feedback ratio (0.0 to 0.95).

  • mix (float) –

    Wet/dry mix ratio (0.0 to 1.0).

Returns:

Source code in xnano/effects/_properties.py
def delay(
    self, **parameters: Unpack[DelayAudioEffectParametersSchema]
) -> DelayAudioEffectParameters:
    """
    Repeat the sound as fading echoes.

    Keyword Args:
        time_milliseconds (float): Delay time between echoes in milliseconds (``1.0`` to ``2000.0``).
        feedback (float): Echo feedback ratio (``0.0`` to ``0.95``).
        mix (float): Wet/dry mix ratio (``0.0`` to ``1.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast('DelayAudioEffectParameters', self._start('audio.delay', parameters))

reverb

Add the reverberation of a room.

Other Parameters:

  • room (float) –

    Room size (0.0 to 1.0).

  • damping (float) –

    High-frequency damping (0.0 to 1.0).

  • mix (float) –

    Wet/dry mix ratio (0.0 to 1.0).

Returns:

Source code in xnano/effects/_properties.py
def reverb(
    self, **parameters: Unpack[ReverbAudioEffectParametersSchema]
) -> ReverbAudioEffectParameters:
    """
    Add the reverberation of a room.

    Keyword Args:
        room (float): Room size (``0.0`` to ``1.0``).
        damping (float): High-frequency damping (``0.0`` to ``1.0``).
        mix (float): Wet/dry mix ratio (``0.0`` to ``1.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'ReverbAudioEffectParameters', self._start('audio.reverb', parameters)
    )

tremolo

Pulse the volume up and down.

Other Parameters:

  • rate_hertz (float) –

    Modulation rate in hertz (0.1 to 40.0).

  • depth (float) –

    Modulation depth (0.0 to 1.0).

Returns:

Source code in xnano/effects/_properties.py
def tremolo(
    self, **parameters: Unpack[TremoloAudioEffectParametersSchema]
) -> TremoloAudioEffectParameters:
    """
    Pulse the volume up and down.

    Keyword Args:
        rate_hertz (float): Modulation rate in hertz (``0.1`` to ``40.0``).
        depth (float): Modulation depth (``0.0`` to ``1.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'TremoloAudioEffectParameters', self._start('audio.tremolo', parameters)
    )

fade_to

fade_to(**parameters: Unpack[FadeToEffectParametersSchema]) -> FadeToEffectParameters

Fade the colors to foreground and background.

Other Parameters:

  • foreground (ColorValue | Expression[ColorValue] | None) –

    Target foreground color, or None.

  • background (ColorValue | Expression[ColorValue] | None) –

    Target background color, or None.

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

    Duration of the fade in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def fade_to(
    self, **parameters: Unpack[FadeToEffectParametersSchema]
) -> FadeToEffectParameters:
    """
    Fade the colors to ``foreground`` and ``background``.

    Keyword Args:
        foreground (ColorValue | Expression[ColorValue] | None): Target foreground color, or ``None``.
        background (ColorValue | Expression[ColorValue] | None): Target background color, or ``None``.
        duration_milliseconds (int | Expression[int | float] | None): Duration of the fade in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('FadeToEffectParameters', self._start('effect.fade_to', parameters))

fade_from

fade_from(**parameters: Unpack[FadeFromEffectParametersSchema]) -> FadeFromEffectParameters

Fade the colors in from foreground and background.

Other Parameters:

  • foreground (ColorValue | Expression[ColorValue] | None) –

    Starting foreground color, or None.

  • background (ColorValue | Expression[ColorValue] | None) –

    Starting background color, or None.

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

    Duration of the fade in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def fade_from(
    self, **parameters: Unpack[FadeFromEffectParametersSchema]
) -> FadeFromEffectParameters:
    """
    Fade the colors in from ``foreground`` and ``background``.

    Keyword Args:
        foreground (ColorValue | Expression[ColorValue] | None): Starting foreground color, or ``None``.
        background (ColorValue | Expression[ColorValue] | None): Starting background color, or ``None``.
        duration_milliseconds (int | Expression[int | float] | None): Duration of the fade in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'FadeFromEffectParameters', self._start('effect.fade_from', parameters)
    )

paint

paint(**parameters: Unpack[PaintEffectParametersSchema]) -> PaintEffectParameters

Paint foreground and background over the colors.

Other Parameters:

  • foreground (ColorValue | Expression[ColorValue] | None) –

    Foreground color to paint, or None.

  • background (ColorValue | Expression[ColorValue] | None) –

    Background color to paint, or None.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def paint(
    self, **parameters: Unpack[PaintEffectParametersSchema]
) -> PaintEffectParameters:
    """
    Paint ``foreground`` and ``background`` over the colors.

    Keyword Args:
        foreground (ColorValue | Expression[ColorValue] | None): Foreground color to paint, or ``None``.
        background (ColorValue | Expression[ColorValue] | None): Background color to paint, or ``None``.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('PaintEffectParameters', self._start('effect.paint', parameters))

saturate

saturate(**parameters: Unpack[SaturateEffectParametersSchema]) -> SaturateEffectParameters

Make the colors more or less saturated.

Other Parameters:

  • foreground (float | Expression[int | float] | None) –

    Foreground saturation change, or None.

  • background (float | Expression[int | float] | None) –

    Background saturation change, or None.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def saturate(
    self, **parameters: Unpack[SaturateEffectParametersSchema]
) -> SaturateEffectParameters:
    """
    Make the colors more or less saturated.

    Keyword Args:
        foreground (float | Expression[int | float] | None): Foreground saturation change, or ``None``.
        background (float | Expression[int | float] | None): Background saturation change, or ``None``.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'SaturateEffectParameters', self._start('effect.saturate', parameters)
    )

lighten

lighten(**parameters: Unpack[LightenEffectParametersSchema]) -> LightenEffectParameters

Lighten the colors.

Other Parameters:

  • foreground (float | Expression[int | float] | None) –

    Foreground lightness increase, or None.

  • background (float | Expression[int | float] | None) –

    Background lightness increase, or None.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def lighten(
    self, **parameters: Unpack[LightenEffectParametersSchema]
) -> LightenEffectParameters:
    """
    Lighten the colors.

    Keyword Args:
        foreground (float | Expression[int | float] | None): Foreground lightness increase, or ``None``.
        background (float | Expression[int | float] | None): Background lightness increase, or ``None``.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('LightenEffectParameters', self._start('effect.lighten', parameters))

darken

darken(**parameters: Unpack[DarkenEffectParametersSchema]) -> DarkenEffectParameters

Darken the colors.

Other Parameters:

  • foreground (float | Expression[int | float] | None) –

    Foreground darkness increase, or None.

  • background (float | Expression[int | float] | None) –

    Background darkness increase, or None.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def darken(
    self, **parameters: Unpack[DarkenEffectParametersSchema]
) -> DarkenEffectParameters:
    """
    Darken the colors.

    Keyword Args:
        foreground (float | Expression[int | float] | None): Foreground darkness increase, or ``None``.
        background (float | Expression[int | float] | None): Background darkness increase, or ``None``.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('DarkenEffectParameters', self._start('effect.darken', parameters))

sweep_in

sweep_in(**parameters: Unpack[SweepInEffectParametersSchema]) -> SweepInEffectParameters

Reveal the content behind a sweep of color in direction.

Other Parameters:

  • direction (MotionDirection | Expression[str] | None) –

    Sweep direction (such as 'left_to_right').

  • gradient_length (int | Expression[int | float] | None) –

    Length of the sweep gradient in cells.

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

    Random offset across rows or columns.

  • color (ColorValue | Expression[ColorValue] | None) –

    Starting sweep color.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def sweep_in(
    self, **parameters: Unpack[SweepInEffectParametersSchema]
) -> SweepInEffectParameters:
    """
    Reveal the content behind a sweep of ``color`` in ``direction``.

    Keyword Args:
        direction (MotionDirection | Expression[str] | None): Sweep direction (such as ``'left_to_right'``).
        gradient_length (int | Expression[int | float] | None): Length of the sweep gradient in cells.
        randomness (int | Expression[int | float] | None): Random offset across rows or columns.
        color (ColorValue | Expression[ColorValue] | None): Starting sweep color.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('SweepInEffectParameters', self._start('effect.sweep_in', parameters))

sweep_out

sweep_out(**parameters: Unpack[SweepOutEffectParametersSchema]) -> SweepOutEffectParameters

Hide the content behind a sweep of color in direction.

Other Parameters:

  • direction (MotionDirection | Expression[str] | None) –

    Sweep direction (such as 'left_to_right').

  • gradient_length (int | Expression[int | float] | None) –

    Length of the sweep gradient in cells.

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

    Random offset across rows or columns.

  • color (ColorValue | Expression[ColorValue] | None) –

    Ending sweep color.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def sweep_out(
    self, **parameters: Unpack[SweepOutEffectParametersSchema]
) -> SweepOutEffectParameters:
    """
    Hide the content behind a sweep of ``color`` in ``direction``.

    Keyword Args:
        direction (MotionDirection | Expression[str] | None): Sweep direction (such as ``'left_to_right'``).
        gradient_length (int | Expression[int | float] | None): Length of the sweep gradient in cells.
        randomness (int | Expression[int | float] | None): Random offset across rows or columns.
        color (ColorValue | Expression[ColorValue] | None): Ending sweep color.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'SweepOutEffectParameters', self._start('effect.sweep_out', parameters)
    )

slide_in

slide_in(**parameters: Unpack[SlideInEffectParametersSchema]) -> SlideInEffectParameters

Slide the content in, in direction.

Other Parameters:

  • direction (MotionDirection | Expression[str] | None) –

    Slide direction (such as 'left_to_right').

  • gradient_length (int | Expression[int | float] | None) –

    Length of the gradient trail in cells.

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

    Random offset across rows or columns.

  • color (ColorValue | Expression[ColorValue] | None) –

    Color behind the sliding cells.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def slide_in(
    self, **parameters: Unpack[SlideInEffectParametersSchema]
) -> SlideInEffectParameters:
    """
    Slide the content in, in ``direction``.

    Keyword Args:
        direction (MotionDirection | Expression[str] | None): Slide direction (such as ``'left_to_right'``).
        gradient_length (int | Expression[int | float] | None): Length of the gradient trail in cells.
        randomness (int | Expression[int | float] | None): Random offset across rows or columns.
        color (ColorValue | Expression[ColorValue] | None): Color behind the sliding cells.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('SlideInEffectParameters', self._start('effect.slide_in', parameters))

slide_out

slide_out(**parameters: Unpack[SlideOutEffectParametersSchema]) -> SlideOutEffectParameters

Slide the content out, in direction.

Other Parameters:

  • direction (MotionDirection | Expression[str] | None) –

    Slide direction (such as 'left_to_right').

  • gradient_length (int | Expression[int | float] | None) –

    Length of the gradient trail in cells.

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

    Random offset across rows or columns.

  • color (ColorValue | Expression[ColorValue] | None) –

    Color left behind the sliding cells.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def slide_out(
    self, **parameters: Unpack[SlideOutEffectParametersSchema]
) -> SlideOutEffectParameters:
    """
    Slide the content out, in ``direction``.

    Keyword Args:
        direction (MotionDirection | Expression[str] | None): Slide direction (such as ``'left_to_right'``).
        gradient_length (int | Expression[int | float] | None): Length of the gradient trail in cells.
        randomness (int | Expression[int | float] | None): Random offset across rows or columns.
        color (ColorValue | Expression[ColorValue] | None): Color left behind the sliding cells.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'SlideOutEffectParameters', self._start('effect.slide_out', parameters)
    )

hsl_shift

hsl_shift(**parameters: Unpack[HslShiftEffectParametersSchema]) -> HslShiftEffectParameters

Shift the hue, saturation and lightness of the colors.

Other Parameters:

  • foreground (HslShiftTuple | None) –

    (hue, saturation, lightness) shift for foreground colors.

  • background (HslShiftTuple | None) –

    (hue, saturation, lightness) shift for background colors.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def hsl_shift(
    self, **parameters: Unpack[HslShiftEffectParametersSchema]
) -> HslShiftEffectParameters:
    """
    Shift the hue, saturation and lightness of the colors.

    Keyword Args:
        foreground (HslShiftTuple | None): ``(hue, saturation, lightness)`` shift for foreground colors.
        background (HslShiftTuple | None): ``(hue, saturation, lightness)`` shift for background colors.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'HslShiftEffectParameters', self._start('effect.hsl_shift', parameters)
    )

dissolve

dissolve(**parameters: Unpack[DissolveEffectParametersSchema]) -> DissolveEffectParameters

Dissolve the content into style, cell by cell.

Other Parameters:

  • style (Style | DynamicStyle | None) –

    Style dissolved into.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def dissolve(
    self, **parameters: Unpack[DissolveEffectParametersSchema]
) -> DissolveEffectParameters:
    """
    Dissolve the content into ``style``, cell by cell.

    Keyword Args:
        style (Style | DynamicStyle | None): Style dissolved into.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'DissolveEffectParameters', self._start('effect.dissolve', parameters)
    )

coalesce

coalesce(**parameters: Unpack[CoalesceEffectParametersSchema]) -> CoalesceEffectParameters

Bring the content together out of style, cell by cell.

Other Parameters:

  • style (Style | DynamicStyle | None) –

    Style coalesced from.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def coalesce(
    self, **parameters: Unpack[CoalesceEffectParametersSchema]
) -> CoalesceEffectParameters:
    """
    Bring the content together out of ``style``, cell by cell.

    Keyword Args:
        style (Style | DynamicStyle | None): Style coalesced from.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'CoalesceEffectParameters', self._start('effect.coalesce', parameters)
    )

glitch

glitch(**parameters: Unpack[GlitchEffectParametersSchema]) -> GlitchEffectParameters

Make a share of the cells glitch for a moment.

Other Parameters:

  • ratio (float | Expression[int | float] | None) –

    Fraction of cells affected by the glitch.

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

    Duration in milliseconds.

  • start_delay_milliseconds (tuple[int, int]) –

    (minimum, maximum) delay before a cell glitches.

  • action_milliseconds (tuple[int, int]) –

    (minimum, maximum) duration of each cell glitch.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def glitch(
    self, **parameters: Unpack[GlitchEffectParametersSchema]
) -> GlitchEffectParameters:
    """
    Make a share of the cells glitch for a moment.

    Keyword Args:
        ratio (float | Expression[int | float] | None): Fraction of cells affected by the glitch.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        start_delay_milliseconds (tuple[int, int]): ``(minimum, maximum)`` delay before a cell glitches.
        action_milliseconds (tuple[int, int]): ``(minimum, maximum)`` duration of each cell glitch.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('GlitchEffectParameters', self._start('effect.glitch', parameters))

sleep

sleep(**parameters: Unpack[SleepEffectParametersSchema]) -> SleepEffectParameters

Wait for duration_milliseconds without changing anything.

Other Parameters:

  • duration_milliseconds (int | Expression[int | float]) –

    Pause duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def sleep(
    self, **parameters: Unpack[SleepEffectParametersSchema]
) -> SleepEffectParameters:
    """
    Wait for ``duration_milliseconds`` without changing anything.

    Keyword Args:
        duration_milliseconds (int | Expression[int | float]): Pause duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('SleepEffectParameters', self._start('effect.sleep', parameters))

evolve

evolve(**parameters: Unpack[EvolveEffectParametersSchema]) -> EvolveEffectParameters

Cycle the cells through a progression of symbols.

Other Parameters:

  • symbols (EvolveSymbolSet | Expression[str] | None) –

    The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

  • style (Style | DynamicStyle | None) –

    Optional style applied to the evolving symbols.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def evolve(
    self, **parameters: Unpack[EvolveEffectParametersSchema]
) -> EvolveEffectParameters:
    """
    Cycle the cells through a progression of ``symbols``.

    Keyword Args:
        symbols (EvolveSymbolSet | Expression[str] | None): The symbols stepped through, such as ``'circles'``, ``'squares'`` or ``'shaded'``.
        style (Style | DynamicStyle | None): Optional style applied to the evolving symbols.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('EvolveEffectParameters', self._start('effect.evolve', parameters))

evolve_into

evolve_into(**parameters: Unpack[EvolveIntoEffectParametersSchema]) -> EvolveIntoEffectParameters

Turn the content into a progression of symbols.

Other Parameters:

  • symbols (EvolveSymbolSet | Expression[str] | None) –

    The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

  • style (Style | DynamicStyle | None) –

    Optional style applied to the evolving symbols.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def evolve_into(
    self, **parameters: Unpack[EvolveIntoEffectParametersSchema]
) -> EvolveIntoEffectParameters:
    """
    Turn the content into a progression of ``symbols``.

    Keyword Args:
        symbols (EvolveSymbolSet | Expression[str] | None): The symbols stepped through, such as ``'circles'``, ``'squares'`` or ``'shaded'``.
        style (Style | DynamicStyle | None): Optional style applied to the evolving symbols.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'EvolveIntoEffectParameters', self._start('effect.evolve_into', parameters)
    )

evolve_from

evolve_from(**parameters: Unpack[EvolveFromEffectParametersSchema]) -> EvolveFromEffectParameters

Grow the content out of a progression of symbols.

Other Parameters:

  • symbols (EvolveSymbolSet | Expression[str] | None) –

    The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

  • style (Style | DynamicStyle | None) –

    Optional style applied to the evolving symbols.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def evolve_from(
    self, **parameters: Unpack[EvolveFromEffectParametersSchema]
) -> EvolveFromEffectParameters:
    """
    Grow the content out of a progression of ``symbols``.

    Keyword Args:
        symbols (EvolveSymbolSet | Expression[str] | None): The symbols stepped through, such as ``'circles'``, ``'squares'`` or ``'shaded'``.
        style (Style | DynamicStyle | None): Optional style applied to the evolving symbols.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast(
        'EvolveFromEffectParameters', self._start('effect.evolve_from', parameters)
    )

expand

expand(**parameters: Unpack[ExpandEffectParametersSchema]) -> ExpandEffectParameters

Expand style outward from the center.

Other Parameters:

  • direction (Literal['horizontal', 'vertical'] | Expression[str] | None) –

    'horizontal' or 'vertical'.

  • style (Style | DynamicStyle | None) –

    Style expanded outward from the center.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def expand(
    self, **parameters: Unpack[ExpandEffectParametersSchema]
) -> ExpandEffectParameters:
    """
    Expand ``style`` outward from the center.

    Keyword Args:
        direction (Literal['horizontal', 'vertical'] | Expression[str] | None): ``'horizontal'`` or ``'vertical'``.
        style (Style | DynamicStyle | None): Style expanded outward from the center.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('ExpandEffectParameters', self._start('effect.expand', parameters))

stretch

stretch(**parameters: Unpack[StretchEffectParametersSchema]) -> StretchEffectParameters

Stretch style across the area in direction.

Other Parameters:

  • direction (MotionDirection | Expression[str] | None) –

    'left_to_right', 'right_to_left', 'up_to_down' or 'down_to_up'.

  • style (Style | DynamicStyle | None) –

    Style stretched across the area.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def stretch(
    self, **parameters: Unpack[StretchEffectParametersSchema]
) -> StretchEffectParameters:
    """
    Stretch ``style`` across the area in ``direction``.

    Keyword Args:
        direction (MotionDirection | Expression[str] | None): ``'left_to_right'``, ``'right_to_left'``, ``'up_to_down'`` or ``'down_to_up'``.
        style (Style | DynamicStyle | None): Style stretched across the area.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('StretchEffectParameters', self._start('effect.stretch', parameters))

explode

explode(**parameters: Unpack[ExplodeEffectParametersSchema]) -> ExplodeEffectParameters

Throw the cells outward.

Other Parameters:

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

    Outward force throwing the cells.

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

    Variation in force from cell to cell.

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

    Duration in milliseconds.

  • interpolation (Interpolation | Expression[str] | None) –

    The easing curve, such as 'linear' or 'quad_in_out'.

  • key (str | Expression[str] | None) –

    Optional effect key for replacement or cancellation.

Returns:

Source code in xnano/effects/_properties.py
def explode(
    self, **parameters: Unpack[ExplodeEffectParametersSchema]
) -> ExplodeEffectParameters:
    """
    Throw the cells outward.

    Keyword Args:
        force (float | Expression[int | float] | None): Outward force throwing the cells.
        randomness (float | Expression[int | float] | None): Variation in force from cell to cell.
        duration_milliseconds (int | Expression[int | float] | None): Duration in milliseconds.
        interpolation (Interpolation | Expression[str] | None): The easing curve, such as ``'linear'`` or ``'quad_in_out'``.
        key (str | Expression[str] | None): Optional effect key for replacement or cancellation.

    Returns:
        The running effect. Assigning one of its fields starts it again with the new
        values, and ``cancel()`` stops it.
    """
    return cast('ExplodeEffectParameters', self._start('effect.explode', parameters))

clear

clear() -> None

End the effects this hook has set.

Visual effects stop on the buffer, and the hook's sound effects are not applied to what it plays. Does nothing when the hook has set none.

Source code in xnano/effects/_controller.py
def clear(self) -> None:
    """
    End the effects this hook has set.

    Visual effects stop on the buffer, and the hook's sound effects are not applied to what
    it plays. Does nothing when the hook has set none.
    """
    state = self._context.hook._effect_state
    if state is not None:
        state.clear()

AudioEffectParameters

AudioEffectParameters(kind: str, /, **parameters: object)

Bases: EffectParameters

The base of the parameters of every sound effect ('audio.<name>').

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

  • to_audio_effect –

    The TerminalAudioEffect this effect builds.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(self, kind: str, /, **parameters: object) -> None: ...

customization_kind instance-attribute

customization_kind: str

The kind, such as 'style' or 'effect.fade_to'.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

to_audio_effect

to_audio_effect() -> TerminalAudioEffect

The TerminalAudioEffect this effect builds.

Source code in xnano/effects/_properties.py
def to_audio_effect(self) -> TerminalAudioEffect:
    """The [`TerminalAudioEffect`][xnano_audio.TerminalAudioEffect] this effect builds."""
    ...

BitCrushAudioEffectParameters dataclass

BitCrushAudioEffectParameters(bits: int = 8, downsample: int = 4)

Bases: AudioEffectParameters

The parameters of the 'audio.bit_crush' sound effect.

Attributes:

  • bits (int) –

    Quantization resolution in bits (1 to 16).

  • downsample (int) –

    Sample-hold factor (1 to 256).

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The TerminalAudioEffect this effect builds.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

bits class-attribute instance-attribute

bits: int = 8

Quantization resolution in bits (1 to 16).

downsample class-attribute instance-attribute

downsample: int = 4

Sample-hold factor (1 to 256).

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> TerminalAudioEffect

The TerminalAudioEffect this effect builds.

Source code in xnano/effects/_properties.py
def to_audio_effect(self) -> TerminalAudioEffect:
    """The [`TerminalAudioEffect`][xnano_audio.TerminalAudioEffect] this effect builds."""
    ...

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

CoalesceEffectParameters dataclass

CoalesceEffectParameters(style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.coalesce' visual effect (Effect.coalesce).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

style class-attribute instance-attribute

style: Style | DynamicStyle | None = None

Style coalesced from.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

DarkenEffectParameters dataclass

DarkenEffectParameters(foreground: float | Expression[int | float] | None = None, background: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.darken' visual effect (Effect.darken).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

foreground class-attribute instance-attribute

foreground: float | Expression[int | float] | None = None

Foreground darkness increase, or None.

background class-attribute instance-attribute

background: float | Expression[int | float] | None = None

Background darkness increase, or None.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

DelayAudioEffectParameters dataclass

DelayAudioEffectParameters(time_milliseconds: float = 250.0, feedback: float = 0.4, mix: float = 0.35)

Bases: AudioEffectParameters

The parameters of the 'audio.delay' sound effect.

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The TerminalAudioEffect this effect builds.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

time_milliseconds class-attribute instance-attribute

time_milliseconds: float = 250.0

Delay time between echoes in milliseconds (1.0 to 2000.0).

feedback class-attribute instance-attribute

feedback: float = 0.4

Echo feedback ratio (0.0 to 0.95).

mix class-attribute instance-attribute

mix: float = 0.35

Wet/dry mix ratio (0.0 to 1.0).

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> TerminalAudioEffect

The TerminalAudioEffect this effect builds.

Source code in xnano/effects/_properties.py
def to_audio_effect(self) -> TerminalAudioEffect:
    """The [`TerminalAudioEffect`][xnano_audio.TerminalAudioEffect] this effect builds."""
    ...

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

DissolveEffectParameters dataclass

DissolveEffectParameters(style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.dissolve' visual effect (Effect.dissolve).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

style class-attribute instance-attribute

style: Style | DynamicStyle | None = None

Style dissolved into.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

DistortionAudioEffectParameters dataclass

DistortionAudioEffectParameters(drive: float = 4.0)

Bases: AudioEffectParameters

The parameters of the 'audio.distortion' sound effect.

Attributes:

  • drive (float) –

    Input gain before soft-clipping (0.1 to 100.0).

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The TerminalAudioEffect this effect builds.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

drive class-attribute instance-attribute

drive: float = 4.0

Input gain before soft-clipping (0.1 to 100.0).

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> TerminalAudioEffect

The TerminalAudioEffect this effect builds.

Source code in xnano/effects/_properties.py
def to_audio_effect(self) -> TerminalAudioEffect:
    """The [`TerminalAudioEffect`][xnano_audio.TerminalAudioEffect] this effect builds."""
    ...

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

EffectParameters

EffectParameters(kind: str, /, **parameters: object)

Bases: DynamicOperation

The base of the parameters of every effect that effect returns.

An effect is both a dataclass holding its typed parameters and a native Customization operation. It can be applied with |, passed to add and update, returned from a hook or listed in effects=. The parameters are read when it is applied, so editing a field changes what it does.

Attributes:

  • customization_kind (str) –

    Identifier of the effect kind, such as 'effect.dissolve' or 'audio.reverb'.

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def __init__(self, kind: str, /, **parameters: object) -> None: ...

customization_kind instance-attribute

customization_kind: str

The kind, such as 'style' or 'effect.fade_to'.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

EvolveEffectParameters dataclass

EvolveEffectParameters(symbols: EvolveSymbolSet | Expression[str] | None = None, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.evolve' visual effect (Effect.evolve).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

symbols class-attribute instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None = None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style class-attribute instance-attribute

style: Style | DynamicStyle | None = None

Optional style applied to the evolving symbols.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

EvolveFromEffectParameters dataclass

EvolveFromEffectParameters(symbols: EvolveSymbolSet | Expression[str] | None = None, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.evolve_from' visual effect (Effect.evolve_from).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

symbols class-attribute instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None = None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style class-attribute instance-attribute

style: Style | DynamicStyle | None = None

Optional style applied to the evolving symbols.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

EvolveIntoEffectParameters dataclass

EvolveIntoEffectParameters(symbols: EvolveSymbolSet | Expression[str] | None = None, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.evolve_into' visual effect (Effect.evolve_into).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

symbols class-attribute instance-attribute

symbols: EvolveSymbolSet | Expression[str] | None = None

The symbols stepped through, such as 'circles', 'squares' or 'shaded'.

style class-attribute instance-attribute

style: Style | DynamicStyle | None = None

Optional style applied to the evolving symbols.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

ExpandEffectParameters dataclass

ExpandEffectParameters(direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.expand' visual effect (Effect.expand).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

direction class-attribute instance-attribute

direction: Literal['horizontal', 'vertical'] | Expression[str] | None = None

'horizontal' or 'vertical'.

style class-attribute instance-attribute

style: Style | DynamicStyle | None = None

Style expanded outward from the center.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

ExplodeEffectParameters dataclass

ExplodeEffectParameters(force: float | Expression[int | float] | None = None, randomness: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.explode' visual effect (Effect.explode).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

force class-attribute instance-attribute

force: float | Expression[int | float] | None = None

Outward force throwing the cells.

randomness class-attribute instance-attribute

randomness: float | Expression[int | float] | None = None

Variation in force from cell to cell.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

FadeFromEffectParameters dataclass

FadeFromEffectParameters(foreground: ColorValue | Expression[ColorValue] | None = None, background: ColorValue | Expression[ColorValue] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.fade_from' visual effect (Effect.fade_from).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

foreground class-attribute instance-attribute

foreground: ColorValue | Expression[ColorValue] | None = None

Starting foreground color, or None.

background class-attribute instance-attribute

background: ColorValue | Expression[ColorValue] | None = None

Starting background color, or None.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration of the fade in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

FadeToEffectParameters dataclass

FadeToEffectParameters(foreground: ColorValue | Expression[ColorValue] | None = None, background: ColorValue | Expression[ColorValue] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.fade_to' visual effect (Effect.fade_to).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

foreground class-attribute instance-attribute

foreground: ColorValue | Expression[ColorValue] | None = None

Target foreground color, or None.

background class-attribute instance-attribute

background: ColorValue | Expression[ColorValue] | None = None

Target background color, or None.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration of the fade in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

GlitchEffectParameters dataclass

GlitchEffectParameters(ratio: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, start_delay_milliseconds: tuple[int, int] = (0, 0), action_milliseconds: tuple[int, int] = (50, 150), key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.glitch' visual effect (Effect.glitch).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

ratio class-attribute instance-attribute

ratio: float | Expression[int | float] | None = None

Fraction of cells affected by the glitch.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

start_delay_milliseconds class-attribute instance-attribute

start_delay_milliseconds: tuple[int, int] = (0, 0)

(minimum, maximum) delay before a cell glitches.

action_milliseconds class-attribute instance-attribute

action_milliseconds: tuple[int, int] = (50, 150)

(minimum, maximum) duration of each cell glitch.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

HighPassAudioEffectParameters dataclass

HighPassAudioEffectParameters(cutoff: float = 400.0, resonance: float = 0.707)

Bases: AudioEffectParameters

The parameters of the 'audio.high_pass' sound effect.

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The TerminalAudioEffect this effect builds.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

cutoff class-attribute instance-attribute

cutoff: float = 400.0

Corner frequency in hertz (20.0 to 20000.0).

resonance class-attribute instance-attribute

resonance: float = 0.707

Filter resonance Q (0.1 to 20.0).

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> TerminalAudioEffect

The TerminalAudioEffect this effect builds.

Source code in xnano/effects/_properties.py
def to_audio_effect(self) -> TerminalAudioEffect:
    """The [`TerminalAudioEffect`][xnano_audio.TerminalAudioEffect] this effect builds."""
    ...

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

HslShiftEffectParameters dataclass

HslShiftEffectParameters(foreground: HslShiftTuple | None = None, background: HslShiftTuple | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.hsl_shift' visual effect (Effect.hsl_shift).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

foreground class-attribute instance-attribute

foreground: HslShiftTuple | None = None

(hue, saturation, lightness) shift for foreground colors.

background class-attribute instance-attribute

background: HslShiftTuple | None = None

(hue, saturation, lightness) shift for background colors.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

LightenEffectParameters dataclass

LightenEffectParameters(foreground: float | Expression[int | float] | None = None, background: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.lighten' visual effect (Effect.lighten).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

foreground class-attribute instance-attribute

foreground: float | Expression[int | float] | None = None

Foreground lightness increase, or None.

background class-attribute instance-attribute

background: float | Expression[int | float] | None = None

Background lightness increase, or None.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

LowPassAudioEffectParameters dataclass

LowPassAudioEffectParameters(cutoff: float = 1200.0, resonance: float = 0.707)

Bases: AudioEffectParameters

The parameters of the 'audio.low_pass' sound effect.

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The TerminalAudioEffect this effect builds.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

cutoff class-attribute instance-attribute

cutoff: float = 1200.0

Corner frequency in hertz (20.0 to 20000.0).

resonance class-attribute instance-attribute

resonance: float = 0.707

Filter resonance Q (0.1 to 20.0).

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> TerminalAudioEffect

The TerminalAudioEffect this effect builds.

Source code in xnano/effects/_properties.py
def to_audio_effect(self) -> TerminalAudioEffect:
    """The [`TerminalAudioEffect`][xnano_audio.TerminalAudioEffect] this effect builds."""
    ...

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

PaintEffectParameters dataclass

PaintEffectParameters(foreground: ColorValue | Expression[ColorValue] | None = None, background: ColorValue | Expression[ColorValue] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.paint' visual effect (Effect.paint).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

foreground class-attribute instance-attribute

foreground: ColorValue | Expression[ColorValue] | None = None

Foreground color to paint, or None.

background class-attribute instance-attribute

background: ColorValue | Expression[ColorValue] | None = None

Background color to paint, or None.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

PlayableEffectProperties

PlayableEffectProperties(device: AudioDevice)

Bases: _PlayableEffectMethods

The sound effects of a canvas's audio, one method for each effect.

Get it from Speaker.fx. Each method adds its effect to every sound the canvas plays from then on, after the sound's own effects. A sound that is already playing keeps the effects it started with. Adding an effect of a kind that is already there replaces the earlier one, and clear() removes them all.

Attributes:

Examples:

import xnano

with xnano.new(width=8, height=1) as canvas:
    echo = canvas.speaker.fx.delay(time_milliseconds=120.0, feedback=0.4)
    assert canvas.speaker.fx.active == (echo,)
    canvas.speaker.play('C4')
    canvas.speaker.fx.clear()
    assert canvas.speaker.fx.active == ()

Create the sound effects of a canvas's audio. Use canvas.speaker.fx instead.

Parameters:

  • device (AudioDevice) –

    The audio the effects are added to.

Methods:

  • bit_crush –

    Lower the resolution of the sound, for a gritty, retro tone.

  • distortion –

    Distort the sound by driving it into soft clipping.

  • low_pass –

    Keep the frequencies below cutoff and soften those above it.

  • high_pass –

    Keep the frequencies above cutoff and soften those below it.

  • delay –

    Repeat the sound as fading echoes.

  • reverb –

    Add the reverberation of a room.

  • tremolo –

    Pulse the volume up and down.

  • clear –

    Remove every effect added here, for the sounds played after this.

Source code in xnano/effects/_properties.py
def __init__(self, device: AudioDevice) -> None:
    """
    Create the sound effects of a canvas's audio. Use ``canvas.speaker.fx`` instead.

    Args:
        device: The audio the effects are added to.
    """
    self._device = device
    self._running: dict[str, AudioEffectParameters] = {}

active property

active: tuple[PlayableEffect, ...]

The effects added here and not cleared or replaced.

bit_crush

Lower the resolution of the sound, for a gritty, retro tone.

Other Parameters:

  • bits (int) –

    Quantization resolution in bits (1 to 16).

  • downsample (int) –

    Sample-hold factor (1 to 256).

Returns:

Source code in xnano/effects/_properties.py
def bit_crush(
    self, **parameters: Unpack[BitCrushAudioEffectParametersSchema]
) -> BitCrushAudioEffectParameters:
    """
    Lower the resolution of the sound, for a gritty, retro tone.

    Keyword Args:
        bits (int): Quantization resolution in bits (``1`` to ``16``).
        downsample (int): Sample-hold factor (``1`` to ``256``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'BitCrushAudioEffectParameters', self._start('audio.bit_crush', parameters)
    )

distortion

Distort the sound by driving it into soft clipping.

Other Parameters:

  • drive (float) –

    Input gain before soft-clipping (0.1 to 100.0).

Returns:

Source code in xnano/effects/_properties.py
def distortion(
    self, **parameters: Unpack[DistortionAudioEffectParametersSchema]
) -> DistortionAudioEffectParameters:
    """
    Distort the sound by driving it into soft clipping.

    Keyword Args:
        drive (float): Input gain before soft-clipping (``0.1`` to ``100.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'DistortionAudioEffectParameters', self._start('audio.distortion', parameters)
    )

low_pass

Keep the frequencies below cutoff and soften those above it.

Other Parameters:

  • cutoff (float) –

    Corner frequency in hertz (20.0 to 20000.0).

  • resonance (float) –

    Filter resonance Q (0.1 to 20.0).

Returns:

Source code in xnano/effects/_properties.py
def low_pass(
    self, **parameters: Unpack[LowPassAudioEffectParametersSchema]
) -> LowPassAudioEffectParameters:
    """
    Keep the frequencies below ``cutoff`` and soften those above it.

    Keyword Args:
        cutoff (float): Corner frequency in hertz (``20.0`` to ``20000.0``).
        resonance (float): Filter resonance Q (``0.1`` to ``20.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'LowPassAudioEffectParameters', self._start('audio.low_pass', parameters)
    )

high_pass

Keep the frequencies above cutoff and soften those below it.

Other Parameters:

  • cutoff (float) –

    Corner frequency in hertz (20.0 to 20000.0).

  • resonance (float) –

    Filter resonance Q (0.1 to 20.0).

Returns:

Source code in xnano/effects/_properties.py
def high_pass(
    self, **parameters: Unpack[HighPassAudioEffectParametersSchema]
) -> HighPassAudioEffectParameters:
    """
    Keep the frequencies above ``cutoff`` and soften those below it.

    Keyword Args:
        cutoff (float): Corner frequency in hertz (``20.0`` to ``20000.0``).
        resonance (float): Filter resonance Q (``0.1`` to ``20.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'HighPassAudioEffectParameters', self._start('audio.high_pass', parameters)
    )

delay

Repeat the sound as fading echoes.

Other Parameters:

  • time_milliseconds (float) –

    Delay time between echoes in milliseconds (1.0 to 2000.0).

  • feedback (float) –

    Echo feedback ratio (0.0 to 0.95).

  • mix (float) –

    Wet/dry mix ratio (0.0 to 1.0).

Returns:

Source code in xnano/effects/_properties.py
def delay(
    self, **parameters: Unpack[DelayAudioEffectParametersSchema]
) -> DelayAudioEffectParameters:
    """
    Repeat the sound as fading echoes.

    Keyword Args:
        time_milliseconds (float): Delay time between echoes in milliseconds (``1.0`` to ``2000.0``).
        feedback (float): Echo feedback ratio (``0.0`` to ``0.95``).
        mix (float): Wet/dry mix ratio (``0.0`` to ``1.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast('DelayAudioEffectParameters', self._start('audio.delay', parameters))

reverb

Add the reverberation of a room.

Other Parameters:

  • room (float) –

    Room size (0.0 to 1.0).

  • damping (float) –

    High-frequency damping (0.0 to 1.0).

  • mix (float) –

    Wet/dry mix ratio (0.0 to 1.0).

Returns:

Source code in xnano/effects/_properties.py
def reverb(
    self, **parameters: Unpack[ReverbAudioEffectParametersSchema]
) -> ReverbAudioEffectParameters:
    """
    Add the reverberation of a room.

    Keyword Args:
        room (float): Room size (``0.0`` to ``1.0``).
        damping (float): High-frequency damping (``0.0`` to ``1.0``).
        mix (float): Wet/dry mix ratio (``0.0`` to ``1.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'ReverbAudioEffectParameters', self._start('audio.reverb', parameters)
    )

tremolo

Pulse the volume up and down.

Other Parameters:

  • rate_hertz (float) –

    Modulation rate in hertz (0.1 to 40.0).

  • depth (float) –

    Modulation depth (0.0 to 1.0).

Returns:

Source code in xnano/effects/_properties.py
def tremolo(
    self, **parameters: Unpack[TremoloAudioEffectParametersSchema]
) -> TremoloAudioEffectParameters:
    """
    Pulse the volume up and down.

    Keyword Args:
        rate_hertz (float): Modulation rate in hertz (``0.1`` to ``40.0``).
        depth (float): Modulation depth (``0.0`` to ``1.0``).

    Returns:
        The effect. Assigning one of its fields changes the sounds played after that.
    """
    return cast(
        'TremoloAudioEffectParameters', self._start('audio.tremolo', parameters)
    )

clear

clear() -> None

Remove every effect added here, for the sounds played after this.

Source code in xnano/effects/_properties.py
def clear(self) -> None:
    """Remove every effect added here, for the sounds played after this."""
    self._running.clear()

ReverbAudioEffectParameters dataclass

ReverbAudioEffectParameters(room: float = 0.5, damping: float = 0.5, mix: float = 0.25)

Bases: AudioEffectParameters

The parameters of the 'audio.reverb' sound effect.

Attributes:

  • room (float) –

    Room size (0.0 to 1.0).

  • damping (float) –

    High-frequency damping (0.0 to 1.0).

  • mix (float) –

    Wet/dry mix ratio (0.0 to 1.0).

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The TerminalAudioEffect this effect builds.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

room class-attribute instance-attribute

room: float = 0.5

Room size (0.0 to 1.0).

damping class-attribute instance-attribute

damping: float = 0.5

High-frequency damping (0.0 to 1.0).

mix class-attribute instance-attribute

mix: float = 0.25

Wet/dry mix ratio (0.0 to 1.0).

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> TerminalAudioEffect

The TerminalAudioEffect this effect builds.

Source code in xnano/effects/_properties.py
def to_audio_effect(self) -> TerminalAudioEffect:
    """The [`TerminalAudioEffect`][xnano_audio.TerminalAudioEffect] this effect builds."""
    ...

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

SaturateEffectParameters dataclass

SaturateEffectParameters(foreground: float | Expression[int | float] | None = None, background: float | Expression[int | float] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.saturate' visual effect (Effect.saturate).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

foreground class-attribute instance-attribute

foreground: float | Expression[int | float] | None = None

Foreground saturation change, or None.

background class-attribute instance-attribute

background: float | Expression[int | float] | None = None

Background saturation change, or None.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

SleepEffectParameters dataclass

SleepEffectParameters(duration_milliseconds: int | Expression[int | float] = 500, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.sleep' visual effect (Effect.sleep).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] = 500

Pause duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

SlideInEffectParameters dataclass

SlideInEffectParameters(direction: MotionDirection | Expression[str] | None = None, gradient_length: int | Expression[int | float] | None = None, randomness: int | Expression[int | float] | None = None, color: ColorValue | Expression[ColorValue] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.slide_in' visual effect (Effect.slide_in).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

direction class-attribute instance-attribute

direction: MotionDirection | Expression[str] | None = None

Slide direction (such as 'left_to_right').

gradient_length class-attribute instance-attribute

gradient_length: int | Expression[int | float] | None = None

Length of the gradient trail in cells.

randomness class-attribute instance-attribute

randomness: int | Expression[int | float] | None = None

Random offset across rows or columns.

color class-attribute instance-attribute

color: ColorValue | Expression[ColorValue] | None = None

Color behind the sliding cells.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

SlideOutEffectParameters dataclass

SlideOutEffectParameters(direction: MotionDirection | Expression[str] | None = None, gradient_length: int | Expression[int | float] | None = None, randomness: int | Expression[int | float] | None = None, color: ColorValue | Expression[ColorValue] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.slide_out' visual effect (Effect.slide_out).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

direction class-attribute instance-attribute

direction: MotionDirection | Expression[str] | None = None

Slide direction (such as 'left_to_right').

gradient_length class-attribute instance-attribute

gradient_length: int | Expression[int | float] | None = None

Length of the gradient trail in cells.

randomness class-attribute instance-attribute

randomness: int | Expression[int | float] | None = None

Random offset across rows or columns.

color class-attribute instance-attribute

color: ColorValue | Expression[ColorValue] | None = None

Color left behind the sliding cells.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

StretchEffectParameters dataclass

StretchEffectParameters(direction: MotionDirection | Expression[str] | None = None, style: Style | DynamicStyle | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.stretch' visual effect (Effect.stretch).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

direction class-attribute instance-attribute

direction: MotionDirection | Expression[str] | None = None

'left_to_right', 'right_to_left', 'up_to_down' or 'down_to_up'.

style class-attribute instance-attribute

style: Style | DynamicStyle | None = None

Style stretched across the area.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

SweepInEffectParameters dataclass

SweepInEffectParameters(direction: MotionDirection | Expression[str] | None = None, gradient_length: int | Expression[int | float] | None = None, randomness: int | Expression[int | float] | None = None, color: ColorValue | Expression[ColorValue] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.sweep_in' visual effect (Effect.sweep_in).

Attributes:

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.

  • kinds –

    The name of every kind of customization.

  • defaults –

    The parameter names of a kind with their defaults, in order.

  • build –

    The core object this customization stands for: a Style, Border, Effect,

  • to_operation –

    The core operation that applies this customization.

  • to_audio_effect –

    The audio effect behind an 'audio.*' customization.

  • apply_to_surface –

    Apply this customization to a buffer, widget or region.

  • apply_to –

    Apply this operation to a canvas, placement or surface.

  • cancel –

    Stop this effect on the target it was applied to.

parameters property

parameters: dict[str, object]

The parameters by name, with defaults filled in.

direction class-attribute instance-attribute

direction: MotionDirection | Expression[str] | None = None

Sweep direction (such as 'left_to_right').

gradient_length class-attribute instance-attribute

gradient_length: int | Expression[int | float] | None = None

Length of the sweep gradient in cells.

randomness class-attribute instance-attribute

randomness: int | Expression[int | float] | None = None

Random offset across rows or columns.

color class-attribute instance-attribute

color: ColorValue | Expression[ColorValue] | None = None

Starting sweep color.

duration_milliseconds class-attribute instance-attribute

duration_milliseconds: int | Expression[int | float] | None = None

Duration in milliseconds.

interpolation class-attribute instance-attribute

interpolation: Interpolation | Expression[str] | None = None

The easing curve, such as 'linear' or 'quad_in_out'.

key class-attribute instance-attribute

key: str | Expression[str] | None = None

Optional effect key for replacement or cancellation.

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')
        ```
    """

kinds staticmethod

kinds() -> list[str]

The name of every kind of customization.

Examples:

assert 'style' in Customization.kinds()
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def kinds() -> list[str]:
    """
    The name of every kind of customization.

    Examples:
        ```python
        assert 'style' in Customization.kinds()
        ```
    """

defaults staticmethod

defaults(kind: str) -> dict[str, object]

The parameter names of a kind with their defaults, in order.

Raises:

  • ValueError –

    kind is not a customization kind.

Examples:

assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
@staticmethod
def defaults(kind: str) -> dict[str, object]:
    """
    The parameter names of a kind with their defaults, in order.

    Raises:
        ValueError: ``kind`` is not a customization kind.

    Examples:
        ```python
        assert Customization.defaults('margin') == {'horizontal': 0, 'vertical': 0}
        ```
    """

build

build() -> object

The core object this customization stands for: a Style, Border, Effect, Block, Margin, audio effect and so on, with all of its own methods.

Examples:

assert isinstance(Customization('style', bold=True).build(), Style)
Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def build(self) -> object:
    """
    The core object this customization stands for: a ``Style``, ``Border``, ``Effect``,
    ``Block``, ``Margin``, audio effect and so on, with all of its own methods.

    Examples:
        ```python
        assert isinstance(Customization('style', bold=True).build(), Style)
        ```
    """

to_operation

to_operation() -> Operation

The core operation that applies this customization.

Raises:

  • TypeError –

    The kind is not applied as an operation, such as 'block'.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_operation(self) -> Operation:
    """
    The core operation that applies this customization.

    Raises:
        TypeError: The kind is not applied as an operation, such as ``'block'``.
    """

to_audio_effect

to_audio_effect() -> object

The audio effect behind an 'audio.*' customization.

Raises:

  • TypeError –

    The kind is not an audio effect.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def to_audio_effect(self) -> object:
    """
    The audio effect behind an ``'audio.*'`` customization.

    Raises:
        TypeError: The kind is not an audio effect.
    """

apply_to_surface

apply_to_surface(surface: Surface) -> None

Apply this customization to a buffer, widget or region.

Source code in packages/xnano-core/src/xnano_core/_xnano_core/__init__.pyi
def apply_to_surface(self, surface: Surface) -> None:
    """Apply this customization to a buffer, widget or region."""

apply_to

apply_to(target: Canvas[object, object] | Placement[object, object] | Surface) -> None

Apply this operation to a canvas, placement or surface.

It stays attached to the target: after this, assigning one of its fields applies it again, so the operation is a live handle on what it changed. A running effect is stopped and started again with the new values.

Parameters:

Source code in xnano/_internal/_dynamic_operations.py
def apply_to(
    self,
    target: Canvas[object, object] | Placement[object, object] | _core.Surface,
) -> None:
    """
    Apply this operation to a canvas, placement or surface.

    It stays attached to the target: after this, assigning one of its fields applies it
    again, so the operation is a live handle on what it changed. A running effect is
    stopped and started again with the new values.

    Args:
        target: The target to apply the operation to.
    """
    from xnano.canvas import Canvas
    from xnano.layout._placement import Placement

    self._attach(target)
    if isinstance(target, (Placement, Canvas)):
        target._buffer.update(self)
        if self.customization_kind.startswith('effect.'):
            target._canvas._record_effect(cast('EffectParameters', self), target)
    elif isinstance(target, _core.Surface):
        target.update(self)

cancel

cancel() -> None

Stop this effect on the target it was applied to.

Does nothing for an effect that was never applied or has already finished, and for a sound effect.

Examples:

import xnano

with xnano.new('hi', width=4, height=1) as canvas:
    fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
    fade.apply_to(canvas)
    fade.cancel()
    fade.cancel()
Source code in xnano/effects/_properties.py
def cancel(self) -> None:
    """
    Stop this effect on the target it was applied to.

    Does nothing for an effect that was never applied or has already finished, and for a
    sound effect.

    Examples:
        ```python
        import xnano

        with xnano.new('hi', width=4, height=1) as canvas:
            fade = xnano.effect('effect.fade_to', foreground='red', duration_milliseconds=5000)
            fade.apply_to(canvas)
            fade.cancel()
            fade.cancel()
        ```
    """
    target = self.__dict__.get('_target')
    key = getattr(self, 'key', None)
    if target is None or not isinstance(key, str):
        return
    if not self.customization_kind.startswith('effect.'):
        return
    surface = target._buffer if hasattr(target, '_buffer') else target
    surface.update(_core.CancelEffect(key))

SweepOutEffectParameters dataclass

SweepOutEffectParameters(direction: MotionDirection | Expression[str] | None = None, gradient_length: int | Expression[int | float] | None = None, randomness: int | Expression[int | float] | None = None, color: ColorValue | Expression[ColorValue] | None = None, duration_milliseconds: int | Expression[int | float] | None = None, interpolation: Interpolation | Expression[str] | None = None, key: str | Expression[str] | None = None)

Bases: EffectParameters

The parameters of the 'effect.sweep_out' visual effect (Effect.sweep_out).

Attributes: