Skip to content

Feat/snake - #73

Open
tusharmalpani20 wants to merge 3 commits into
ChrisBuilds:mainfrom
tusharmalpani20:feat/snake
Open

Feat/snake#73
tusharmalpani20 wants to merge 3 commits into
ChrisBuilds:mainfrom
tusharmalpani20:feat/snake

Conversation

@tusharmalpani20

Copy link
Copy Markdown

Summary

Adds a new snake effect inspired by classic grid-based snake movement.
Multiple snakes enter from different canvas edges, carry input characters as body segments, follow orthogonal paths, and
deposit those characters into their final text positions. Each snake visibly shrinks as it assembles the input, leaving no auxiliary
artifacts in the completed frame.

Highlights

  • Adds the public Snake, SnakeConfig, and SnakeIterator API
  • Registers the snake CLI command
  • Supports multiple concurrently active snakes
  • Uses orthogonal routing with body trails that follow around turns
  • Assigns targets using coherent row-serpentine groups
  • Clamps the effective snake count to available input characters
  • Preserves ANSI foreground and background colors where configured
  • Handles empty, whitespace-only, multiline, single-character, and tiny-canvas inputs
  • Guarantees iterator termination and hides all auxiliary heads
  • Adds final gradient, movement speed, spawn delay, snake color, count, and head symbol options
  • Adds reference documentation, showroom content, navigation, README, and changelog entries

Engine change

Adds a small guard to Canvas._anchor_text() so whitespace-only input with no retained characters is handled without raising
an exception.

Testing

  • Snake, CLI, and whitespace regression tests: 35 passed
  • Generic effect contracts filtered to Snake: 20 passed, 162 skipped
  • Ruff lint checks on changed production and Snake test code: passed
  • Ruff formatting check: passed
  • mkdocs build --strict: passed
  • Python compilation and git diff --check: passed
  • Representative multiline CLI animation: completed successfully with exact final text and no visible snake artifacts

The full repository suite was intentionally not completed; verification was limited to Snake and directly affected components.

Demo

printf 'TERMINAL\nTEXT\nEFFECTS' | uv run tte \
  --frame-rate 30 \
  --canvas-width 60 \
  --canvas-height 16 \
  --anchor-text c \
  snake \
  --snake-count 4 \
  --spawn-delay 3 \
  --movement-speed 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant