Cloth Effect

See Water, smoke, cloth, and procedural worlds for presets, controls, units, and resize behavior.

A pinned, waving flag that can carry text or custom ASCII art.

class bruhanimate.bruheffect.cloth_effect.ClothEffect(buffer: Buffer, background: str, settings: ClothSettings | None = None, *, image: str | Sequence[str] | None = None)[source]

Bases: BaseEffect

Kinematic cloth with an anchored left edge and shaded traveling folds.

image accepts text or rows of printable single-cell glyphs, copied on input. Custom art is centered on the cloth at its original size and clipped to fit. Resize preserves art and wave phase. No physical spring solver is involved.

__init__(buffer: Buffer, background: str, settings: ClothSettings | None = None, *, image: str | Sequence[str] | None = None) → None[source]

Base class for all effects.

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

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

  • seed – Non-negative integer for independent Python and NumPy random streams. None uses fresh entropy. Global RNG state is untouched.

set_image(image: str | Sequence[str] | None) → None[source]

Copy ASCII rows, or use None to restore the configured pattern.

Ragged rows are space-padded. Empty art, ANSI escapes and wide/combining glyphs are rejected. A change appears on the next update or resize.

update(dt: float) → None[source]

Advance simulation by one tick; dt is the tick duration in seconds.

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

Change the drawing viewport, retaining the original simulation raster.

Shrinking clips from the bottom/right; growing reveals the original raster again. Cells beyond it remain transparent to the owner. Random streams, resource handles and simulation coordinates are unchanged. Subclasses can override this typed hook to adapt simulation arrays and repaint the private raster at the current tick, then call super().resize. Built-in adapters use this contract; draw must still never advance time.