Raxol. Effects. CursorTrail
(Raxol v2.6.0)
View Source
Visual cursor trail for terminal interfaces.
Tracks recent cursor positions and renders a fading trail behind the current cursor. Useful for drawing attention to cursor movement, visualising input, or just adding aesthetic weight to a TUI cockpit.
Example
trail = CursorTrail.new(max_length: 10)
trail = CursorTrail.update(trail, {5, 10})
trail = CursorTrail.update(trail, {6, 10})
trail = CursorTrail.update(trail, {7, 10})
buffer = CursorTrail.apply(trail, buffer)Configuration
config = %{
max_length: 20, # Maximum trail positions to track
decay_rate: 0.15, # Exponential opacity decay per tick
colors: [:cyan, :blue, :magenta],
chars: ["*", "+", "."], # Characters cycled along the trail
min_opacity: 0.1, # Drop points below this opacity
overwrite_text: false, # Paint over non-space cells if true
enabled: true
}
trail = CursorTrail.new(config)Presets
rainbow/1-- 6-color rainbow cycle, length 24comet/1-- long fading white-to-blue tailminimal/1-- 5-cell single-color trailelectric/1/neon/1/matrix/1-- presets aligned with theRaxol.Effects.BorderBeampalette family
Summary
Functions
Apply the trail's current points to a buffer.
Apply a fixed glow halo around a single position. Independent of trail state -- useful for highlighting an active cursor without history.
Drop all points (preserves config).
Long white-to-blue fading tail with tapered chars.
Bright yellow/cyan crackle, matches BorderBeam :electric.
Append the points along the line from -> to to the trail. Uses
Bresenham's algorithm to fill in intermediate cells so a single jump
produces a smooth trail.
Number of currently visible points.
Green-on-green digital rain, matches BorderBeam :matrix.
Subtle five-cell white trail with quick decay.
Build a trail seeded with multiple positions.
Magenta/cyan vapor, matches BorderBeam :neon.
Create a new cursor trail.
Six-color rainbow cycle, length 24.
Enable or disable the effect.
Trail statistics: point_count, max_length, enabled, tick, average_opacity.
Append a position to the trail (or age existing points if unchanged).
Merge new config keys into the existing config.
Types
@type t() :: %Raxol.Effects.CursorTrail{ config: config(), points: [trail_point()], tick: non_neg_integer() }
@type trail_point() :: %{ position: position(), age: non_neg_integer(), opacity: float() }
Functions
@spec apply(t(), Raxol.Core.Buffer.t()) :: Raxol.Core.Buffer.t()
Apply the trail's current points to a buffer.
@spec apply_glow(Raxol.Core.Buffer.t(), position(), atom()) :: Raxol.Core.Buffer.t()
Apply a fixed glow halo around a single position. Independent of trail state -- useful for highlighting an active cursor without history.
Drop all points (preserves config).
Long white-to-blue fading tail with tapered chars.
Bright yellow/cyan crackle, matches BorderBeam :electric.
Append the points along the line from -> to to the trail. Uses
Bresenham's algorithm to fill in intermediate cells so a single jump
produces a smooth trail.
@spec length(t()) :: non_neg_integer()
Number of currently visible points.
Green-on-green digital rain, matches BorderBeam :matrix.
Subtle five-cell white trail with quick decay.
Build a trail seeded with multiple positions.
Magenta/cyan vapor, matches BorderBeam :neon.
Create a new cursor trail.
Six-color rainbow cycle, length 24.
Enable or disable the effect.
Trail statistics: point_count, max_length, enabled, tick, average_opacity.
Append a position to the trail (or age existing points if unchanged).
Merge new config keys into the existing config.