Fire Effect

With on_resize="resize", heat fields, heat spots and the last visible flame raster follow the bottom edge. Existing columns retain their fuel variation; new cells start cold and join normal fuel updates. Heat-spot lifetimes, wind, swell phase and random streams are preserved. Cropped heat is discarded. No color flicker is rerolled during resize. 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.fire_effect.FireEffect(buffer: Buffer, background: str, settings: FireSettings | None = None)[source]

Bases: BaseEffect

Class for generating a dynamic fire effect with taller, rounder, and more visible flames using fuller ASCII characters.

__init__(buffer: Buffer, background: str, settings: FireSettings | None = None)[source]

Initializes the fire effect.

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

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

  • settings (FireSettings, optional) – Configuration for the fire effect. Defaults to None.

resize(size: tuple[int, int]) → None[source]

Resize (width, height), keeping heat and visible flames bottom-aligned.

Retain left-hand columns, heat-spot lifetimes, wind, swell phase and both random streams. Cropped heat/spots are discarded; new cells start cold. New columns use neutral fuel variation until its normal random refresh. Copy the last raster instead of rerolling its per-cell color flicker. No simulation tick or lifecycle operation runs during this notification.

set_fire_ascii_chars(ascii_chars: str)[source]

Sets the ASCII characters used for the fire effect.

Parameters:

ascii_chars (str) – Exactly 10 characters to use for the fire gradient.

set_fire_intensity(fire_intensity: float)[source]

Sets the intensity of the fire effect.

Parameters:

fire_intensity (float) – Value between 0 and 1.

set_fire_wind(direction: float, strength: float)[source]

Sets wind parameters for the fire effect.

Parameters:
  • direction (float) – Wind angle in degrees.

  • strength (float) – Wind strength between 0 and 1.

set_fire_use_char_color(use_char_color: bool)[source]

Enables or disables character color rendering.

Parameters:

use_char_color (bool) – Whether to color the ASCII characters.

set_fire_background_color(background_color: bool)[source]

Enables or disables background color rendering.

Parameters:

background_color (bool) – Whether to render as colored background blocks.

set_fire_swell(swell: bool, swell_halt: int = 1)[source]

Controls intensity oscillation (breathing effect).

Parameters:
  • swell (bool) – Whether to enable swelling.

  • swell_halt (int, optional) – Frames between swell updates. Defaults to 1.

set_fire_turbulence(turbulence: float)[source]

Sets how chaotic the fire behaves.

Parameters:

turbulence (float) – Value between 0 and 1.

set_fire_heat_spot_intensity(heat_spot_intensity: float)[source]

Sets the intensity of heat spots.

Parameters:

heat_spot_intensity (float) – Value between 0 and 1.

get_colored_char(intensity: float, max_intensity: float = 255.0) → str[source]

Returns a colored character based on fire intensity.

Parameters:
  • intensity (float) – Current cell intensity.

  • max_intensity (float, optional) – Maximum intensity value. Defaults to 255.0.

Returns:

The character (with optional ANSI color) to render.

Return type:

str

update_data(frame_number: int)[source]

Updates the fire simulation data for one frame.

Parameters:

frame_number (int) – The simulation tick index, independent of draw FPS.

add_new_fire_row(frame_number: int)[source]

Seeds a new row of heat at the bottom of the fire.

Parameters:

frame_number (int) – The simulation tick index, independent of draw FPS.

update(dt: float) → None[source]

Advance one simulation tick; dt is measured in seconds.