Skip to main content

Load and play ASCII Motion animations in your terminal

Project description

PyAsciiMotion

Play ASCII Motion animations in your Python terminal.

Parses session files (.json, .asciimtn), JSON exports, and plain-text frame files from ascii-motion.app — then renders them with full ANSI color support, frame-by-frame playback, and interactive controls.

Install

pip install pyasciimotion

Quick start

from pyasciimotion import AsciiMotion

anim = AsciiMotion.load("demo.json")
anim.play()

Python API

Loading

from pyasciimotion import AsciiMotion

# From a file
anim = AsciiMotion.load("path/to/file.json")
anim = AsciiMotion.load("path/to/file.asciimtn")
anim = AsciiMotion.load("path/to/file.txt")

# From a string
anim = AsciiMotion.from_string(json_text, name="my animation")

Inspecting

print(anim.frame_count)      # number of frames
print(anim.width, anim.height)
print(anim.meta.frame_rate)
print(anim.meta.name)

# Iterate frames
for frame in anim:
    print(frame.to_plain_text())

# Access a single frame
frame = anim[3]
text = anim.frame_text(3)

Playing

# Interactive playback (blocking, keyboard controls)
anim.play(fps=10, loop=True, color=True)

# Render a single frame to stdout
anim.render(index=0, color=True)

Keyboard controls during playback

Key Action
Space Pause / Resume
q Quit
. or ] Step forward
, or [ Step backward
0 Jump to first frame
+ Increase FPS
- Decrease FPS

Advanced player

player = anim.player(fps=12, loop=True, color=True)
player.play(blocking=False)   # runs in background thread

player.pause()
player.resume()
player.seek(10)
player.step(1)
player.fps = 24
player.stop()

print(player.state)           # State.PLAYING, State.PAUSED, etc.
print(player.current_frame)

Low-level access

from pyasciimotion import load, render_frame, Cell, Frame

animation = load("demo.json")
frame = animation.get_frame(0)

cell = frame.cell_at(5, 3)
print(cell.char, cell.fg, cell.bg)

for cell in frame.row(0):
    print(cell.char, end="")

CLI

pyasciimotion play demo.json
pyasciimotion play demo.json --fps 24 --no-loop --no-color
pyasciimotion info demo.json
pyasciimotion frame demo.json --index 3
pyasciimotion frame demo.json --index 0 --plain

Also works via module:

python -m pyasciimotion play demo.json

Supported formats

Format Extension Description
Session v1/v2 .json, .asciimtn Full project state from ascii-motion.app
JSON export .json Compact frame data with color dictionaries
Plain text .txt Character-only frames separated by ---

Architecture

pyasciimotion/
├── __init__.py    # Public API (AsciiMotion class)
├── models.py      # Cell, Frame, Animation, AnimationMeta
├── parser.py      # File format detection and parsing
├── renderer.py    # ANSI terminal rendering
├── player.py      # Threaded playback with controls
├── cli.py         # Command-line interface
└── utils.py       # Terminal detection, formatting

The parser auto-detects format from file extension and content structure. The renderer uses 24-bit ANSI color sequences (truecolor). The player runs playback on a background thread with pause/resume/seek via threading primitives.

Requirements

  • Python 3.10+
  • No external dependencies

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyasciimotion-0.1.1.tar.gz (853.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyasciimotion-0.1.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file pyasciimotion-0.1.1.tar.gz.

File metadata

  • Download URL: pyasciimotion-0.1.1.tar.gz
  • Upload date:
  • Size: 853.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyasciimotion-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eda69aa3f43f56d2e5e78631cb46727bd7aedfda038b2fd565088ab4d55ffbd3
MD5 74933fd5be51ea061d9aba4a68ed410c
BLAKE2b-256 f6da323605d5b9e6a2e1ded13ef31acfbe86ba6ab9f80f6d7deb57e6fd94b8d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyasciimotion-0.1.1.tar.gz:

Publisher: python-publish.yml on Web3-Serializer/PyAsciiMotion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyasciimotion-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyasciimotion-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyasciimotion-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ba4e11a0a1e60d1a71d2e1a1593b167fe055f97b265e00ca6debca3a98eaa5b
MD5 4daa878cbd6f15187fc921a67e3d7526
BLAKE2b-256 a27a77d5ceac0349db99e12357a83665aa42e7fa1f1aa3c0cf871e58c463d871

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyasciimotion-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on Web3-Serializer/PyAsciiMotion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page