Name | phanim JSON |
Version |
1.0.0
JSON |
| download |
home_page | |
Summary | A physics rendering engine |
upload_time | 2023-12-11 10:34:25 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.9 |
license | |
keywords |
render
physics
simulation
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
![phanim logo](https://github.com/quirijndaboyy/phanim/blob/main/phanim/icon.png)
PHysics ANIMations:
a (quite bad) Physics render library
The project is still in the early stages of development, so larger simulation will be slow and features are very limited. Look at the example files to see what cool things you can already do!
## Examples
A simple visualisation of the electric field can be found in examples/vectorField.py
![vector field](https://github.com/quirijndaboyy/phanim/blob/main/gifs/vectorFIeld.gif)
A simulation of a triple pendulum with the use of stiff springs can be found in examples/triplePendulum.py. The graphs on the right show the energy that each of the masses has. The yellow graph shows the total energy in the system.
![triple pendulum](https://github.com/quirijndaboyy/phanim/blob/main/gifs/pendulum.gif)
Or just a simple double pendulum(looks better imo):
![double pendulum](https://github.com/quirijndaboyy/phanim/blob/main/gifs/double_pendulum.gif)
## Requirements
To install the requirements run the following command:
```
pip install -r requirements.txt
```
## Installation
Clone the repository and put your own files in the base folder. Now simply:
```python
from phanim import *
```
## Usage
After importing you can create a phanim screen as follows:
```python
myScreen = phanim.Screen()
```
This will use the device screen resolution. We can also change some of the screen parameters.
```python
myScreen = phanim.Screen(fullscreen=False,resolution=(1920,1080))
```
Now we can create something to render on the screen. In this example we will create a simple grid, but the possibilities are endless.
```python
grid = phanim.Grid(1,1,10,10) #This creates a grid with each line seperated by 1, and 10 lines to each side of the origin.
```
Now we can add some wait time and animate the grid being added to the screen by:
```python
myScreen.wait(60) #This will add an empty animation for 60 frames or 1 seconds.
myScreen.play(Create(grid))
```
Now we can run the script and a window with a simple grid should show up.
```python
myScreen.run()
```
We can also create different object. For example, a blue arrow, which points to the position of the cursor at all times.
We can create the arrow by defining it like this:
```python
arrow = phanim.Arrow(color=color.blue)
```
Now we will create an update function that will be called each frame and move the end of the arrow to the cursor.
```python
def setArrow(screen):
arrow.setDirection([0,0],screen.mousePos)
```
Then add this function to the updater list and run the script:
```python
myScreen.addUpdater(setArrow)
myScreen.play(Create(arrow))
myScreen.run()
```
Make sure you only add the .run() command once at the very end of your script. We can also add some dotted lines to track the mouse position like this:
```python
lines = DottedLine(),DottedLine()
def setLines(screen):
lines[0].setEnds([screen.mousePos[0],0],screen.mousePos)
lines[1].setEnds([0,screen.mousePos[1]],screen.mousePos)
myScreen.play(Create(lines[0]),Create(lines[1]))
myScreen.addUpdater(setLines)
```
After combining the update functions the final script will look like this:
```python
from phanim import *
myScreen = Screen(fullscreen=True)
grid = Grid(1,1,10,10)
arrow =Arrow(color=color.blue)
lines = DottedLine(),DottedLine()
def update(screen):
arrow.setDirection([0,0],screen.mousePos)
lines[0].setEnds([screen.mousePos[0],0],screen.mousePos)
lines[1].setEnds([0,screen.mousePos[1]],screen.mousePos)
myScreen.addUpdater(update)
myScreen.wait(60)
myScreen.play(Create(grid))
myScreen.play(Create(arrow))
myScreen.play(Create(lines[0]),Create(lines[1]))
myScreen.run()
```
Raw data
{
"_id": null,
"home_page": "",
"name": "phanim",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "render,physics,simulation",
"author": "",
"author_email": "Quirijn du Bois <quirijndubois@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8f/80/67f73eb18106f413254646a7334b5432c2f54c496f43706b4b61b3aba615/phanim-1.0.0.tar.gz",
"platform": null,
"description": "![phanim logo](https://github.com/quirijndaboyy/phanim/blob/main/phanim/icon.png)\r\n\r\nPHysics ANIMations: \r\na (quite bad) Physics render library\r\n\r\nThe project is still in the early stages of development, so larger simulation will be slow and features are very limited. Look at the example files to see what cool things you can already do!\r\n\r\n## Examples\r\n\r\nA simple visualisation of the electric field can be found in examples/vectorField.py\r\n![vector field](https://github.com/quirijndaboyy/phanim/blob/main/gifs/vectorFIeld.gif)\r\n\r\nA simulation of a triple pendulum with the use of stiff springs can be found in examples/triplePendulum.py. The graphs on the right show the energy that each of the masses has. The yellow graph shows the total energy in the system.\r\n![triple pendulum](https://github.com/quirijndaboyy/phanim/blob/main/gifs/pendulum.gif)\r\n\r\nOr just a simple double pendulum(looks better imo):\r\n![double pendulum](https://github.com/quirijndaboyy/phanim/blob/main/gifs/double_pendulum.gif)\r\n\r\n## Requirements\r\nTo install the requirements run the following command:\r\n```\r\npip install -r requirements.txt\r\n```\r\n\r\n## Installation\r\nClone the repository and put your own files in the base folder. Now simply:\r\n\r\n```python\r\nfrom phanim import *\r\n```\r\n\r\n## Usage\r\n\r\nAfter importing you can create a phanim screen as follows:\r\n\r\n```python\r\nmyScreen = phanim.Screen()\r\n```\r\nThis will use the device screen resolution. We can also change some of the screen parameters.\r\n```python\r\nmyScreen = phanim.Screen(fullscreen=False,resolution=(1920,1080))\r\n```\r\n\r\nNow we can create something to render on the screen. In this example we will create a simple grid, but the possibilities are endless.\r\n\r\n```python\r\ngrid = phanim.Grid(1,1,10,10) #This creates a grid with each line seperated by 1, and 10 lines to each side of the origin.\r\n```\r\n\r\nNow we can add some wait time and animate the grid being added to the screen by:\r\n\r\n```python\r\nmyScreen.wait(60) #This will add an empty animation for 60 frames or 1 seconds.\r\nmyScreen.play(Create(grid))\r\n```\r\nNow we can run the script and a window with a simple grid should show up.\r\n\r\n```python\r\nmyScreen.run()\r\n```\r\nWe can also create different object. For example, a blue arrow, which points to the position of the cursor at all times.\r\nWe can create the arrow by defining it like this:\r\n\r\n```python\r\narrow = phanim.Arrow(color=color.blue)\r\n```\r\nNow we will create an update function that will be called each frame and move the end of the arrow to the cursor.\r\n\r\n```python\r\ndef setArrow(screen):\r\n arrow.setDirection([0,0],screen.mousePos)\r\n```\r\n\r\nThen add this function to the updater list and run the script:\r\n\r\n```python\r\nmyScreen.addUpdater(setArrow)\r\nmyScreen.play(Create(arrow))\r\nmyScreen.run()\r\n```\r\nMake sure you only add the .run() command once at the very end of your script. We can also add some dotted lines to track the mouse position like this:\r\n\r\n```python\r\nlines = DottedLine(),DottedLine()\r\n\r\ndef setLines(screen):\r\n lines[0].setEnds([screen.mousePos[0],0],screen.mousePos)\r\n lines[1].setEnds([0,screen.mousePos[1]],screen.mousePos)\r\n\r\nmyScreen.play(Create(lines[0]),Create(lines[1]))\r\nmyScreen.addUpdater(setLines)\r\n```\r\n\r\nAfter combining the update functions the final script will look like this:\r\n\r\n```python\r\nfrom phanim import *\r\n\r\nmyScreen = Screen(fullscreen=True)\r\n\r\ngrid = Grid(1,1,10,10)\r\narrow =Arrow(color=color.blue)\r\nlines = DottedLine(),DottedLine()\r\n\r\ndef update(screen):\r\n arrow.setDirection([0,0],screen.mousePos)\r\n lines[0].setEnds([screen.mousePos[0],0],screen.mousePos)\r\n lines[1].setEnds([0,screen.mousePos[1]],screen.mousePos)\r\n\r\nmyScreen.addUpdater(update)\r\n\r\nmyScreen.wait(60)\r\nmyScreen.play(Create(grid))\r\nmyScreen.play(Create(arrow))\r\nmyScreen.play(Create(lines[0]),Create(lines[1]))\r\n\r\nmyScreen.run()\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "",
"summary": "A physics rendering engine",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/quirijndubois/phanim"
},
"split_keywords": [
"render",
"physics",
"simulation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "38f127eb7c0b052129500bf4b24807d97ebd3210d77d89ac7502a8d31debe628",
"md5": "c9d2e72fd75c4dfebf9d75a0d3083463",
"sha256": "6f81cee33d0ab6c7b2f71dc40253acb25f24865265cb70bad6e8de366e71ed57"
},
"downloads": -1,
"filename": "phanim-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c9d2e72fd75c4dfebf9d75a0d3083463",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 22285,
"upload_time": "2023-12-11T10:34:23",
"upload_time_iso_8601": "2023-12-11T10:34:23.878073Z",
"url": "https://files.pythonhosted.org/packages/38/f1/27eb7c0b052129500bf4b24807d97ebd3210d77d89ac7502a8d31debe628/phanim-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8f8067f73eb18106f413254646a7334b5432c2f54c496f43706b4b61b3aba615",
"md5": "029ad3d8e636948ab77f083867fbe818",
"sha256": "5ea456d96a7d7c836e6520fab226f0744dfdcac48d5bb882277b0f7664dcc5b0"
},
"downloads": -1,
"filename": "phanim-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "029ad3d8e636948ab77f083867fbe818",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 19881,
"upload_time": "2023-12-11T10:34:25",
"upload_time_iso_8601": "2023-12-11T10:34:25.733382Z",
"url": "https://files.pythonhosted.org/packages/8f/80/67f73eb18106f413254646a7334b5432c2f54c496f43706b4b61b3aba615/phanim-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-11 10:34:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "quirijndubois",
"github_project": "phanim",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "phanim"
}