pydamicsvisual
Matplotlib + pygame rendering extension for pydamics,
a small chainable-syntax 2D physics engine.
pydamics itself stays dependency-free (just the physics). This package
is the opt-in visual layer on top.
Install
pip install pydamicsvisual # once published to PyPI -- also installs pydamics
# or, from source:
pip install -e .
Usage
from pydamics import Entity, World
from pydamicsvisual import MatplotlibRenderer, PygameRenderer, floor_bounce
ball = Entity(mass=1.0, position=(2, 10))
ball.physics2d.gravity(force=9.8)
ball.physics2d.fluid(density=1.0, drag=0.2)
world = World()
world.add(ball)
world.on_step = floor_bounce(floor_y=0.0, radius=0.4, damping=0.65)
Headless GIF (matplotlib)
renderer = MatplotlibRenderer(world, xlim=(-1, 8), ylim=(0, 16))
renderer.track(ball, radius=0.4)
renderer.save_gif("out.gif", frames=180, dt=1/60)
Interactive window (pygame)
renderer = PygameRenderer(world, width=800, height=600, ppu=40, floor_y=0.0)
renderer.track(ball, radius=0.4)
renderer.on_click(lambda x, y: print("clicked at", x, y)) # e.g. spawn a new ball
renderer.run(dt=1/120) # blocks until window closed / ESC
API
floor_bounce(floor_y=0.0, radius=0.4, damping=0.65, x_bounds=None)
Returns a callable for world.on_step that keeps entities above the floor
(and optionally between walls), bouncing with energy loss on contact.
This is demo-level logic, not a real collision system.
MatplotlibRenderer(world, xlim, ylim, floor_y=0.0, title=..., figsize=(6,6))
.track(entity, color=None, radius=0.4)— register an entity to draw (auto color if omitted).animate(frames=180, dt=1/60, steps_per_frame=1, interval=33)— returns aFuncAnimation.save_gif(path, frames=180, dt=1/60, steps_per_frame=1, fps=30)— steps the sim and saves a GIF
PygameRenderer(world, width=800, height=600, ppu=40, floor_y=0.0, title=...)
.track(entity, color=None, radius=0.4).on_click(callback)—callback(x_world, y_world)fires on every mouse click.run(dt=1/120, fps=60)— opens the window, steps physics on a background thread, blocks until closed/ESC
Examples
pip install -e ".[dev]"
python examples/matplotlib_demo.py # -> examples/falling_balls.gif
python examples/pygame_demo.py # interactive window, click to drop balls
Publishing (for maintainers)
Same flow as pydamics itself:
git init
git add .
git commit -m "Initial commit: pydamicsvisual"
git branch -M main
git remote add origin https://github.com/<your-username>/pydamicsvisual.git
git push -u origin main
Then set up a PyPI Trusted Publisher (pypi.org → account → Publishing) with:
- PyPI project name:
pydamicsvisual - Owner:
<your-github-username> - Repository:
pydamicsvisual - Workflow:
publish.yml - Environment:
pypi
Create a matching pypi environment under GitHub repo Settings →
Environments, then ship a release (tag v0.1.0) to trigger the publish
workflow.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydamicsvisual-0.1.0.tar.gz.
File metadata
- Download URL: pydamicsvisual-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c137276e2c67f734f09fcec913701ba922e05c4c71d62bc3500f2b82af252c2d
|
|
| MD5 |
e356c8f877bcbd0840a6b894e1952f61
|
|
| BLAKE2b-256 |
cb9a7d96d589d07046f31db660de12e8cec2b63c912bc573baba5259c967d76b
|
Provenance
The following attestation bundles were made for pydamicsvisual-0.1.0.tar.gz:
Publisher:
publish.yml on Reeed-cell/PydamicsVisual
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydamicsvisual-0.1.0.tar.gz -
Subject digest:
c137276e2c67f734f09fcec913701ba922e05c4c71d62bc3500f2b82af252c2d - Sigstore transparency entry: 2285102618
- Sigstore integration time:
-
Permalink:
Reeed-cell/PydamicsVisual@8c567e65ee7503f058e682f9ed4793a091ebf9ce -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Reeed-cell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8c567e65ee7503f058e682f9ed4793a091ebf9ce -
Trigger Event:
release
-
Statement type:
File details
Details for the file pydamicsvisual-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydamicsvisual-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ea66ac49b1c87a0cc331aed137669f846366c3bd070d8816d6bb2f86b1d3ce7
|
|
| MD5 |
a79a5b284bf400ec2beafa944f4d8bf4
|
|
| BLAKE2b-256 |
0acaa63adaed8ab76e532c1d8872b79bf6e05f8c9077bc04fae5f359358d214b
|
Provenance
The following attestation bundles were made for pydamicsvisual-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Reeed-cell/PydamicsVisual
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydamicsvisual-0.1.0-py3-none-any.whl -
Subject digest:
1ea66ac49b1c87a0cc331aed137669f846366c3bd070d8816d6bb2f86b1d3ce7 - Sigstore transparency entry: 2285102683
- Sigstore integration time:
-
Permalink:
Reeed-cell/PydamicsVisual@8c567e65ee7503f058e682f9ed4793a091ebf9ce -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Reeed-cell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8c567e65ee7503f058e682f9ed4793a091ebf9ce -
Trigger Event:
release
-
Statement type: