Rain Effect¶
With on_resize="resize", visible rain and lightning retain their coordinates,
and floor splashes follow the new bottom. Bolt lifetimes, intensity, wind and
swell direction are preserved. Cropped cells are discarded and new space starts
empty. Collision masks keep their dimensions and coordinates; cells beyond the
mask are non-colliding. See Terminal resize.
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 = None)[source]¶
Bases:
BaseEffectEffect to simulate the look of rain.
- __init__(buffer: Buffer, background: str, settings: RainSettings | None = 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.
- resize(size: tuple[int, int]) None[source]¶
Adapt to (width, height), preserving visible rain and lightning age.
Drops, image splashes and bolt cells keep absolute coordinates; visible bottom-row splashes move to the new floor. Cropped cells are discarded. New space starts empty and receives rain during normal updates. Explicit collision masks remain at their configured coordinates and dimensions. Intensity, wind, swell direction, tick and random streams are unchanged.
- set_multiplier(val: int)[source]¶
Sets the scroll multiplier (controls shift amount per simulation update).
- 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, threshold: int = None, color: bool = None, color_type: int = None)[source]¶
Enables or disables lightning strikes.
- Parameters:
lightning (bool) – Whether to show lightning.
chance (float, optional) – Per-update probability of a new bolt (0.0–1.0).
threshold (int, optional) – Intensity threshold for lightning.
color (bool, optional) – Whether to color the lightning.
color_type (int, optional) – Color code to use for the lightning.
- 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.