Plasma Effect

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)[source]

Bases: BaseEffect

Class to generate an animated plasma effect.

__init__(buffer: Buffer, background: str, settings: PlasmaSettings = 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.

shuffle_plasma_values()[source]

Randomizes the four plasma frequency values.

render_frame(frame_number: int)[source]

Renders a single frame of the plasma effect.

Parameters:

frame_number (int) – The current frame number.

_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