Raxol.Effects.CursorTrail (Raxol v2.0.1)
View SourceVisual cursor trail effects for terminal interfaces.
Creates a fading trail behind cursor movements for enhanced visual feedback. Useful for:
- Drawing attention to cursor position
- Visualizing movement patterns
- Improving accessibility
- Creating engaging UIs
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})
# Apply trail to buffer
buffer = CursorTrail.apply(trail, buffer)Configuration
config = %{
max_length: 20, # Maximum trail positions to track
decay_rate: 0.15, # How quickly trail fades (0.0-1.0)
colors: [:cyan, :blue, :magenta],
chars: ["*", "+", "."], # Characters for different trail positions
min_opacity: 0.1 # Minimum opacity before hiding
}
trail = CursorTrail.new(config)
Summary
Functions
Apply trail effect to buffer.
Apply glow effect to current cursor position.
Clear all trail points.
Create comet trail effect (long fading tail).
Interpolate positions for smooth trail.
Get current trail length.
Create minimal trail effect.
Create animated trail with multiple cursors.
Create a new cursor trail effect.
Create rainbow trail effect.
Enable or disable trail effect.
Get trail statistics.
Update trail with new cursor position.
Update trail configuration.
Types
@type position() :: {non_neg_integer(), non_neg_integer()}
@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 trail effect to buffer.
@spec apply_glow(Raxol.Core.Buffer.t(), position(), atom()) :: Raxol.Core.Buffer.t()
Apply glow effect to current cursor position.
Clear all trail points.
Create comet trail effect (long fading tail).
Interpolate positions for smooth trail.
Adds intermediate points between cursor positions for smoother trails.
@spec length(t()) :: non_neg_integer()
Get current trail length.
Create minimal trail effect.
Create animated trail with multiple cursors.
Create a new cursor trail effect.
Create rainbow trail effect.
Enable or disable trail effect.
Get trail statistics.
Update trail with new cursor position.
Update trail configuration.