Rain 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.rain_effect.RainEffect(buffer: Buffer, background: str, settings: RainSettings = None)[source]¶

Bases: BaseEffect

Effect to simulate the look of rain.

__init__(buffer: Buffer, background: str, settings: RainSettings = None)[source]¶

Initializes the RainEffect.

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

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

  • settings (RainSettings, optional) – Configuration for the rain effect. Defaults to None.

set_multiplier(val: int)[source]¶

Sets the scroll multiplier (controls shift amount per frame).

Parameters:

val (int) – Multiplier value.

set_wind_direction(direction: str)[source]¶

Sets the direction the rain falls.

Parameters:

direction (str) – Wind direction (“none”, “east”, or “west”).

set_intensity(intensity: int)[source]¶

Sets the intensity of the rain.

Parameters:

intensity (int) – Intensity value between 0 and 999.

set_swells(swells: bool)[source]¶

Enables or disables automatic intensity oscillation.

Parameters:

swells (bool) – Whether the rain intensity should oscillate.

set_lightning(lightning: bool, chance: float = None)[source]¶

Enables or disables lightning strikes.

Parameters:
  • lightning (bool) – Whether to show lightning.

  • chance (float, optional) – Per-frame probability of a new bolt (0.0–1.0).

update_collision(img_start_x: int, img_start_y: int, img_width: int, img_height: int, collision: bool, smart_transparent: bool = False, image_buffer: Buffer = None)[source]¶

Configures collision detection with an image.

Parameters:
  • img_start_x (int) – Image x position on screen.

  • img_start_y (int) – Image y position on screen.

  • img_width (int) – Width of the image.

  • img_height (int) – Height of the image.

  • collision (bool) – Whether to enable collision.

  • smart_transparent (bool, optional) – Smart transparency flag. Defaults to False.

  • image_buffer (Buffer, optional) – Buffer containing the image. Defaults to None.

render_frame(frame_number: int)[source]¶

Renders a single frame of the rain effect.

Parameters:

frame_number (int) – The current frame number.