Python library for the bouncing and growing object animations you see on social media.
Every frame is rendered offline, so the exported video never stutters or drops frames.
What it does
- Balls, polygons, stars and rects bouncing inside rings and arenas
- Rings with spinning gaps that objects escape through, plus stacked concentric rings
- Objects that grow, speed up, change color, clone themselves or vanish on any event
- Trails, glow, motion blur and gradient or image backgrounds
- Styled text with fonts, weights, italics, underline, strikethrough, gradients and backgrounds
- Shapes defined by math expressions, parametric and implicit
- Sound: synthesized tones, sample files and melodies that play the next note on every bounce
- MP4 and MKV export at any resolution and framerate, plus a live preview window
- Debug overlay with fps, frametime, object count, collisions and timings, all readable from code
- Third party addons through the
physim.pluginsentry point
Install
pip install physim[all]
Core stays lean if you would rather opt in:
| Install | Pulls in | Gives you |
|---|---|---|
physim |
numpy, skia-python, av, coloraide, alive-progress, yaspin | rendering and MP4/MKV export |
physim[cli] |
typer, rich | the physim command |
physim[preview] |
opencv-python, sounddevice | live preview window with audio |
physim[audio] |
mido | melodies from MIDI files |
physim[expr] |
sympy | shapes defined by math expressions |
physim[presets] |
physim-presets | color palettes and physics presets |
physim[examples] |
physim-examples | runnable example scenes |
physim[gpu] |
glfw | GPU rasterization via an offscreen GL context |
physim[all] |
everything above |
Run it
# scene.py
from physim import Circle, HollowCircle, RGBCycle, Scene
from physim.actions import Grow, SpeedUp
from physim.effects import Glow, Trail
from physim.events import Bounce
class Bouncy(Scene):
"""A ball that grows and speeds up on every bounce."""
def construct(self):
self.add(HollowCircle(radius=420, stroke="#ffffff"))
ball = Circle(radius=16, fill=RGBCycle(), velocity=(280, 60))
ball.add_effect(Trail(length=28), Glow(strength=0.6))
ball.on(Bounce, Grow(3, max_size=380))
ball.on(Bounce, SpeedUp(1.02, max_speed=2200))
self.add(ball)
self.run(seconds=15)
physim render scene.py Bouncy --debug
Or skip the CLI entirely:
python -c "from scene import Bouncy; Bouncy().render()"
Examples
pip install physim[examples]
python -m physim_examples # list them all
python -m physim_examples.bouncing_ball
python -m physim_examples.escape_ring --debug
python -m physim_examples.ring_stack --seconds 5 -o out.mp4
CLI
physim render scene.py [Scene] # render to video
physim list scene.py # show the scenes in a file
physim preview scene.py # live window
physim info # version, installed features, presets
| Flag | Does |
|---|---|
-o, --output |
output file path |
-f, --format |
mp4 or mkv |
-r, --resolution |
square, vertical, landscape, hd, fhd, 4k or 1080x1920 |
--fps |
frames per second |
-s, --seconds |
override the scene length |
-p, --physics |
physics preset name |
--seed |
random seed, for reproducible renders |
--motion-blur N |
sub-frame samples per frame |
-b, --backend |
auto, cpu or gpu |
--hardware-encode |
use a hardware video encoder when available |
-d, --debug |
overlay fps, frametime, objects, collisions and timings |
--audio-file |
also write the audio to a separate file |
--audio-only |
write only the audio track |
--no-audio |
skip audio entirely |
-q, --quiet |
hide the progress bar |
For AI agents
ai-tutorial.md is a complete reference written for coding agents: the API surface, the coordinate system, the common mistakes, and a worked example.
Development
poetry install --all-extras
poetry run pytest
poetry run ruff check .
poetry run ruff format .
This repo also holds packages/physim-presets and packages/physim-examples.
License
MIT
Release files for physim 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| physim-0.1.5.tar.gz | 65.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| physim-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 156.2 kB
Release files / physim-0.1.5.tar.gz
| Download URL | physim-0.1.5.tar.gz |
|---|---|
| Size | 65.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26b6614df76442c4ee2e4190c81e52fb45d08953bae6429b08cfd5547f4f9d4c
|
|
BLAKE2b-256 checksum How to use checksums |
553b29f48a851d54e2b8da975e3e853ecbc4d8206d464ac709132b1ea5b7b341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logRelease files / physim-0.1.5-py3-none-any.whl
| Download URL | physim-0.1.5-py3-none-any.whl |
|---|---|
| Size | 90.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24fa3c680a8273ec19769525a5fa6aed0a97d7b00177fe57a0b1ddd7f852f26c
|
|
BLAKE2b-256 checksum How to use checksums |
ce8e02e39cacd958d9aac7854f26471fe8946c1174d14371b9af177087304527
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency log