Skip to main content

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!

Release files for torus-engine 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torus-engine 1.5.0
File Size Uploaded
torus-engine-1.5.0.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torus-engine 1.5.0
File Interpreter ABI Platform
torus_engine-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.5 kB

Release files / torus-engine-1.5.0.tar.gz

Download URL torus-engine-1.5.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4bd07e83359a525d75fa5a6375dd6e7b8479ecfa11c53a1a957bbda14795d0fc
BLAKE2b-256 checksum
How to use checksums
844dd773a8182180f94a10b167362b9e5f8f47bfaac66fd6e00cbd1c889e6532
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / torus_engine-1.5.0-py3-none-any.whl

Download URL torus_engine-1.5.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70f4abf26f7d639cb79a2c663c1048010d193514bb9482cea077be2ab509caa5
BLAKE2b-256 checksum
How to use checksums
ed7ad846757f96deba7fb7e679aeb339c1170029fdf52f8b3e64f6f6dbae93e3
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.3

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.1.4

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page