Plasma Effect¶
With on_resize="resize", plasma fills the new area at its current animation
phase. Palette, frequencies and random streams are preserved. The resize
notification repaints immediately without advancing a simulation tick.
See Terminal resize for the adapter contract.
Copyright 2023 Ethan Christensen
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class bruhanimate.bruheffect.plasma_effect.PlasmaEffect(buffer: Buffer, background: str, settings: PlasmaSettings | None = None)[source]¶
Bases:
BaseEffectClass to generate an animated plasma effect.
- __init__(buffer: Buffer, background: str, settings: PlasmaSettings | None = None)[source]¶
Initializes the PlasmaEffect class.
- Parameters:
buffer (Buffer) – Effect buffer to push updates to.
background (str) – Character or string to use as the background.
settings (PlasmaSettings, optional) – Configuration for the plasma effect. Defaults to None.
- set_show_info(visible: bool)[source]¶
Toggles visibility of debug info overlay.
- Parameters:
visible (bool) – Whether to show the info overlay.
- set_grey_scale_size(size: int)[source]¶
Sets the grey scale size, which controls detail level.
- Parameters:
size (int) – Must be 8, 10, or 16.
- Raises:
ValueError – If size is not one of the supported values.
- set_color_properties(color: bool, characters: bool = True, random_colors: bool = False)[source]¶
Configures color rendering. random_colors overrides the palette.
- Parameters:
color (bool) – Whether to render with color.
characters (bool, optional) – Whether to render scale characters. Defaults to True.
random_colors (bool, optional) – Whether to use a random color palette. Defaults to False.
- set_colors(colors: list[int])[source]¶
Sets a custom color palette. Has no effect if random_colors is enabled.
- Parameters:
colors (list[int]) – List of 256-color indices, one per scale character.
- Raises:
ValueError – If the number of colors does not match the scale length.
- set_background(background: str)[source]¶
Updates the background character or string.
- Parameters:
background (str) – Character or string to use as background.
- set_plasma_values(a: int, b: int, c: int, d: int)[source]¶
Sets the four plasma frequency values.
- Parameters:
a (int) – First frequency value.
b (int) – Second frequency value.
c (int) – Third frequency value.
d (int) – Fourth frequency value.
- resize(size: tuple[int, int]) None[source]¶
Fill a new (width, height) at the current phase, without random draws.
Frequency values, palette, settings and animation time are retained. Wave anchors follow the new dimensions. No update/start/close is called.
- _paint_frame() None[source]¶
Paint vectorized waves, caching static geometry until size/values change.
Palette boundaries use the scalar formula to preserve visible cells. This runs during update/resize; draw remains a read-only raster copy.
- _wave(x: float, y: float, a: float, b: float, n: float) float[source]¶
Sine wave radially projected from a point on the screen.
- Parameters:
x (float) – Horizontal position.
y (float) – Vertical position.
a (float) – Horizontal anchor fraction of screen width.
b (float) – Vertical anchor fraction of screen height.
n (float) – Frequency divisor.
- Returns:
Sine value at (x, y).
- Return type:
float