Skip to main content

Liquid-Red

A Python 3D rasterizer engine running entirely in the terminal. No GPU, no display server - just ASCII characters and math. Built on perspective projection, barycentric rasterization, a z-buffer, and Lambert shading. Designed to be used as a library for TUI 3D applications and games.


Features

  • Perspective projection with configurable focal length and zoom
  • Z-buffer for correct depth ordering
  • Barycentric triangle rasterization
  • Lambert shading with ASCII intensity ramp
  • Camera with yaw/pitch rotation and jump physics
  • Plane drawing helpers (draw_plane_xy, draw_plane_xz, draw_plane_yz)
  • Solid cube with faces and wireframe edges
  • Keyboard input via pynput

Installation

pip install pynput numpy LiquidRed

Quick Start

import time
from LiquidRed.camera import Camera
from LiquidRed.grid import Renderer
from LiquidRed.events import pressed
from LiquidRed.geometry import Point3d
import numpy as np
 
CANVAS_WIDTH = 64
CANVAS_HEIGHT = 32
LIGHT = np.array([0, 0, -1])
 
camera = Camera(x=0, y=0, z=-5)
renderer = Renderer(camera, LIGHT, CANVAS_WIDTH, CANVAS_HEIGHT)
 
last_update = 0
 
while True:
    now = time.time()
    if now - last_update < 1 / 60:
        continue
    last_update = now
 
    camera.update(pressed, now)
    renderer.clear_grid()
 
    # draw a floor plane
    renderer.draw_plane_xz(-4, 4, 0, 20, 2)
 
    renderer.show_grid()

Cube(size, cx, cy, cz)

A solid cube centered at (cx, cy, cz).

from LiquidRed.objects import Cube
 
cube = Cube(size=2, cx=0, cy=0, cz=5)
 
# Draw as solid faces
for v0, v1, v2, v3 in cube.faces:
    renderer.draw_plane(v0, v1, v2, v3)
 
# Draw as wireframe
for i, j in cube.edges:
    renderer.draw_line(cube.vertices[i], cube.vertices[j])

Coordinate System

      -Y (up)
       |
       |
-X ----+---- +X
       |
       |
      +Y (down)
 
+Z = into the screen (away from camera)
-Z = toward the camera

Camera starts at negative Z looking toward positive Z. Place objects at positive Z values to put them in front of the camera.


Example: Corridor Scene

from LiquidRed.camera import Camera
from LiquidRed.grid import Renderer
from LiquidRed.events import pressed
import numpy as np, time
 
camera = Camera(z=-1)
renderer = Renderer(camera, np.array([0, 0, -1]), 64, 32)
 
W, H = 4, 3  # corridor half-width, half-height
 
while True:
    now = time.time()
    camera.update(pressed, now)
    renderer.clear_grid()
 
    # floor, ceiling, left wall, right wall
    renderer.draw_plane_xz(-W, W, 0, 30,  H)   # floor
    renderer.draw_plane_xz(-W, W, 0, 30, -H)   # ceiling
    renderer.draw_plane_yz(-H, H, 0, 30, -W)   # left
    renderer.draw_plane_yz(-H, H, 0, 30,  W)   # right
 
    renderer.show_grid()
    time.sleep(1/60)

Metadata

Release files for LiquidRed 0.3.1

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

Source distribution (sdist)

Source distribution for LiquidRed 0.3.1
File Size Uploaded Provenance Actions
liquidred-0.3.1.tar.gz 10.7 kB Without provenance Details for liquidred-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for LiquidRed 0.3.1
File Interpreter ABI Platform Actions
liquidred-0.3.1-py3-none-any.whl Python 3 none any Details for liquidred-0.3.1-py3-none-any.whl

Total release size: 21.5 kB

Release files / liquidred-0.3.1.tar.gz

Download URL liquidred-0.3.1.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ff0ee368eafd8439e7e8457aa5741211a533ca60eec5459b8ab1f9d0df5e6a2d
BLAKE2b-256 checksum
How to use checksums
92262b25843735ed0bcb5e877fd18025bdd074f5e8ea07b12ae69b44547387f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / liquidred-0.3.1-py3-none-any.whl

Download URL liquidred-0.3.1-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8454f40cb8c06b722812751b3322dd5932b8bcc2d9ca462c9cf454daf1ab9ecf
BLAKE2b-256 checksum
How to use checksums
da26a8c6c1cdf6fcc63fa604def1a56aa9eb02c5325bd87d9b84b676ab14110d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for LiquidRed 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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