Raxol.Demo.TextFormation (Raxol v2.6.0)

View Source

ASCII text particle formation for demo effects. Uses 5x7 bitmap font to create particle target positions.

Summary

Functions

Checks if all particles have arrived at their targets.

Creates particles at screen edges with targets for text formation.

Creates explosion particles from formation particles (for dispersal).

Renders formation particles to ANSI escape sequences.

Returns target {x, y} positions for all pixels in the given text. Centered at the given screen coordinates.

Updates particles toward their targets using ease-out approach.

Updates a formation particle with small jitter to create shimmer effect. Only applies to arrived particles.

Types

formation_particle()

@type formation_particle() :: %{
  x: float(),
  y: float(),
  vx: float(),
  vy: float(),
  char: String.t(),
  color: non_neg_integer(),
  life: integer(),
  target_x: float(),
  target_y: float(),
  arrived: boolean()
}

position()

@type position() :: {float(), float()}

Functions

all_arrived?(particles)

@spec all_arrived?([formation_particle()]) :: boolean()

Checks if all particles have arrived at their targets.

create_formation_particles(text, center_x, center_y, screen_width, screen_height)

@spec create_formation_particles(
  String.t(),
  integer(),
  integer(),
  integer(),
  integer()
) :: [formation_particle()]

Creates particles at screen edges with targets for text formation.

explode_formation(particles)

@spec explode_formation([formation_particle()]) :: [Raxol.Demo.Particles.particle()]

Creates explosion particles from formation particles (for dispersal).

render(particles, width, height)

Renders formation particles to ANSI escape sequences.

target_positions(text, center_x, center_y)

@spec target_positions(String.t(), integer(), integer()) :: [position()]

Returns target {x, y} positions for all pixels in the given text. Centered at the given screen coordinates.

update_toward_target(particle)

@spec update_toward_target(formation_particle()) :: formation_particle()

Updates particles toward their targets using ease-out approach.

update_with_jitter(particle)

@spec update_with_jitter(formation_particle()) :: formation_particle()

Updates a formation particle with small jitter to create shimmer effect. Only applies to arrived particles.