Skip to main content

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 a FuncAnimation
  • .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

pydamicsvisual-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

pydamicsvisual-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

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

Hashes for pydamicsvisual-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c137276e2c67f734f09fcec913701ba922e05c4c71d62bc3500f2b82af252c2d
MD5 e356c8f877bcbd0840a6b894e1952f61
BLAKE2b-256 cb9a7d96d589d07046f31db660de12e8cec2b63c912bc573baba5259c967d76b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydamicsvisual-0.1.0.tar.gz:

Publisher: publish.yml on Reeed-cell/PydamicsVisual

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

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

Hashes for pydamicsvisual-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ea66ac49b1c87a0cc331aed137669f846366c3bd070d8816d6bb2f86b1d3ce7
MD5 a79a5b284bf400ec2beafa944f4d8bf4
BLAKE2b-256 0acaa63adaed8ab76e532c1d8872b79bf6e05f8c9077bc04fae5f359358d214b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydamicsvisual-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Reeed-cell/PydamicsVisual

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 Sentry Error logging StatusPage Status page