Skip to main content

Pure-Python, GPU-accelerated particle morphing library

Project description

Particle Field

A pure-Python, GPU-accelerated particle morphing library using VisPy and NumPy. Inspired by a Three.js reference implementation, it supports dynamic shape morphing, noise-driven effects, and flexible color schemes.

Features

  • Multiple built-in shape generators: sphere, cube, pyramid, torus, galaxy, wave
  • Smooth morphing with swarm, swirl, and noise effects
  • HSL-based color schemes with noise perturbation: fire, neon, nature, rainbow
  • Live interactive demo via VisPy SceneCanvas
  • Python API: set_shape(), set_color(), trigger_morph(), load_custom_points()

Installation

  1. Create a virtual environment (recommended):
    python3 -m venv venv
    source venv/bin/activate
    
  2. Install core dependencies:
    pip install -r requirements.txt
    
  3. Install the package in editable mode:
    pip install -e .
    
  4. Install a GUI backend for VisPy (required to open the canvas). We recommend PyQt6:
    pip install PyQt6
    

Usage

Run the interactive demo:

python3 examples/demo.py

Remote Control Demo

You can also start a TCP JSON controller:

python3 examples/controller_demo.py

Then connect via netcat:

nc localhost 8765
{"command":"set_shape","args":["cube"]}
{"command":"trigger_morph","args":[1500]}
{"command":"express","args":["joy",1.0,2000]}

Jupyter Notebook Demo

Open examples/demo_notebook.ipynb in Jupyter (uses VisPy external window):

jupyter notebook examples/demo_notebook.ipynb
jupyter notebook examples/demo_notebook.ipynb

Controls

  • Space or Right Arrow: cycle to next shape and morph
  • C: cycle to next color scheme
  • Q or Esc: quit

Examples

Embed ParticleField in your own scripts:

from particle_field import ParticleField
field = ParticleField(count=20000, size=15.0)
field.set_shape('galaxy')
field.set_color('rainbow')
field.trigger_morph(3000)
# The VisPy canvas runs its own event loop

Continuous Deployment to PyPI

We use GitHub Actions to automatically publish new versions to PyPI upon creating a Git tag of the form vX.Y.Z.

  1. Generate a PyPI API token:
    • Login to PyPI, go to Account settings → API tokens → Add Token → give it a name and expire policy.
    • Copy the token.
  2. Add the token to your GitHub repository as a secret:
    • In GitHub, go to Settings → Secrets and variables → Actions → New repository secret.
    • Name: PYPI_API_TOKEN
    • Value: paste the token here
  3. Tag a new release and push the tag:
    git tag v0.1.0
    git push origin v0.1.0
    
  4. GitHub Actions will build the package and publish to PyPI.

GitHub Actions Workflow

See .github/workflows/publish.yml for the deployment configuration.

License

This project is MIT licensed. See LICENSE.txt in the reference folder for details.

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

particle_field-0.1.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

particle_field-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file particle_field-0.1.0.tar.gz.

File metadata

  • Download URL: particle_field-0.1.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for particle_field-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99a9ef8592ebdc40673eb8c302ebbb556cdc4c400d3a6fa2cfe241bdef0f9e21
MD5 be3348ca72bdd2768dbe10107da1a03c
BLAKE2b-256 9719f820a199a500bcf62d437efbd3e235cf95a3731b9fe5bc9b569f159c7117

See more details on using hashes here.

File details

Details for the file particle_field-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: particle_field-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for particle_field-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b32e1a4fd67a475bda20667abc56325e26fd0fb9713ee830068e1300d1761205
MD5 698d4618258a6f83cbc3a06fe2759a85
BLAKE2b-256 936d86986d41fafeb83428618a35adc6eebebefd5831c742c7ae5117b366d8e5

See more details on using hashes here.

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