3D ASCII character rendering engine
Project description
torus-engine
Description
Basic ASCII 3D rendering engine on the terminal.
Install
Download using pip
Open your terminal and type:
pip install torus-engine
You can find more information on the package on PyPI by clicking here.
Import to your Python project
In your Python project, add this line at the top of the file you wish to have access to the torus-engine
package:
Tutorial
Let's go through a simple tutorial that showcases the different essential functionalities of the torus-engine
API.
Creating an object, Torus
You can choose which object you want to render. See torusengine/objects
for the different objects available. Alternatively, you can create your own, as long as it satisfies the requirements.
import torusengine.objects.orus import Torus
torus = Torus()
Adding a light source, Light
Then you can add a light source:
import torusengine.light import Light
light_source_position = (2, 1, 0) # (x, y, z) coordinates
light_source = Light(position=light_source_position)
Placing a Camera
You also need a camera. To do that you can follow the code below:
import torusengine.camera import Camera
camera_point = (1, 0, 0) # (x, y, z) coordinates
camera = Camera(camera_position=camera_point)
Camera
takes as optional parameters point_to_fix
, which is where the camera is pointing ((0, 0, 0)
by default), and horizontal_rotation
which determines the tilt of the camera.
Putting it altogether to create a Scene
You can now create a Scene
, by passing the object, the light source and the camera:
import torusengine.scene import Scene
scene = Scene(torus, light_source, camera)
Scene
can also take the fps
parameter (frames per second), which is set to 5 by default.
With the object scene
instantiated, you can now call its start()
method:
scene.start()
It can take as parameter the boolean static
(set to False
by default), which determines whether to update the scene only once, or to update it conitnuously (according to its fps
value).
Additional methods of the class Scene
can be called, to change the camera (by moving it up, down, left or right), to increase or decrease the light source intensity, or even to change the object being rendered altogether.
🛠 Improvments
Feel free to create an issue or a pull request in case you find bugs or want to add a feature!
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file torus-engine-1.5.0.tar.gz
.
File metadata
- Download URL: torus-engine-1.5.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bd07e83359a525d75fa5a6375dd6e7b8479ecfa11c53a1a957bbda14795d0fc |
|
MD5 | cc155461b11a53df1fc9f6936559b12c |
|
BLAKE2b-256 | 844dd773a8182180f94a10b167362b9e5f8f47bfaac66fd6e00cbd1c889e6532 |
File details
Details for the file torus_engine-1.5.0-py3-none-any.whl
.
File metadata
- Download URL: torus_engine-1.5.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70f4abf26f7d639cb79a2c663c1048010d193514bb9482cea077be2ab509caa5 |
|
MD5 | b5cb9ce5170987c9e8fb613cbae41832 |
|
BLAKE2b-256 | ed7ad846757f96deba7fb7e679aeb339c1170029fdf52f8b3e64f6f6dbae93e3 |