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

Bases: BaseEffect

Function to generate a plasma like effect

__init__(buffer: Buffer, background: str)[source]

Initializes the plasma effect class.

Parameters:
  • buffer (Buffer) – Effect buffer to push updates to.

  • background (str) – Character or string to use as the background.

update_info_visibility(visible: bool)[source]

Function to toggle visibility of info text.

Parameters:

visible (bool) – Toggle visibility.

update_grey_scale_size(size: int)[source]

Function to change the size of the grey scale.

Parameters:

size (int) – Size of the grey scale to use.

Raises:

Exception – If the requested grey scale size is not available.

update_color_properties(color: bool, characters: bool = True, random_color: bool = False)[source]

Function to update the color properties. random_color overrules other functions.

Parameters:
  • color (bool) – Toggle the use of colors.

  • characters (bool, optional) – Toggle the use of characters. Defaults to True.

  • random_color (bool, optional) – Toggle the use of random colors. Defaults to False.

update_color(colors: list[int])[source]

Function to update the color palette.

Parameters:

colors (list[int]) – List of RGB values for the color palette.

Raises:

Exception – If the number of colors does not match the length of the scale.

update_background(background: str)[source]

Function to update the background color or character.

Parameters:

background (str) – Character or string to set the background to.

update_plasma_values(a: int = 50, b: int = 28, c: int = 30, d: int = 29)[source]

Function to set the plasma values.

Parameters:
  • a (int, optional) – Value a. Defaults to random.randint(1, 50).

  • b (int, optional) – Value b. Defaults to random.randint(1, 50).

  • c (int, optional) – Value c. Defaults to random.randint(1, 50).

  • d (int, optional) – Value d. Defaults to random.randint(1, 50).

shuffle_plasma_values()[source]

Function to shuffle the plasma values randomly.

render_frame(frame_number: int)[source]

Function to render the plasma effect frame by frame.

Parameters:

frame_number (int) – The current frame number.

func(x: int, y: int, a: int, b: int, n: int)[source]

Generates a plasma effect using the Perlin noise algorithm.

Parameters:
Returns:

value of the Perlin noise at (x, y)

Return type:

float