Background Color Renderer¶

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.bruhrenderer.background_color_renderer.BackgroundColorRenderer(screen, img: list[str], frames: int = 100, frame_time: float = 0.1, effect_type: Literal['static', 'offset', 'noise', 'stars', 'plasma', 'gol', 'rain', 'matrix', 'drawlines', 'snow', 'twinkle', 'audio', 'firework', 'fire', 'julia', 'water', 'boids', 'sand', 'diffusion', 'automaton', 'voronoi', 'perlin'] = 'static', background: str = ' ', transparent: bool = False, collision: bool = False, on_color_code: int = 27, settings: Any = None, preset: str | None = None)[source]¶

Bases: BaseRenderer

Renders ASCII art centered on screen with a solid ANSI background color.

Parameters:
  • screen – The screen object to render to.

  • img (list[str]) – ASCII art as a list of strings.

  • frames (int) – Number of frames to render. Defaults to 100.

  • frame_time (float) – Seconds between frames. Defaults to 0.1.

  • effect_type (EffectType) – Background effect. Defaults to “static”.

  • background (str) – Background fill character. Defaults to “ “.

  • transparent (bool) – Whether to apply transparency. Defaults to False.

  • collision (bool) – Whether to enable collision detection. Defaults to False.

  • on_color_code (int) – ANSI 256-color code (0–255) for the background. Defaults to 27.

  • settings – Optional settings dataclass to configure the effect.

  • preset – Optional named preset registered for the effect.

__init__(screen, img: list[str], frames: int = 100, frame_time: float = 0.1, effect_type: Literal['static', 'offset', 'noise', 'stars', 'plasma', 'gol', 'rain', 'matrix', 'drawlines', 'snow', 'twinkle', 'audio', 'firework', 'fire', 'julia', 'water', 'boids', 'sand', 'diffusion', 'automaton', 'voronoi', 'perlin'] = 'static', background: str = ' ', transparent: bool = False, collision: bool = False, on_color_code: int = 27, settings: Any = None, preset: str | None = None)[source]¶
render_img_frame(frame_number: int)[source]¶

Applies the background color to each image character on frame 0 only. Subsequent frames reuse the already-colored image buffer unchanged.