Patchwork is a lightweight tool for visualizing 2D environments, built with Python. It serves as a testbed for experimenting with graphical rendering of grids and virtual environments using various graphics libraries—starting with Pygame.
This project is part of the Viron ecosystem and provides a visual layer to its simulated environments.
- Grid-based rendering of 2D environments
- Initial support for Pygame
- Interactive toggling of cell states
- Modular structure designed for future support of other graphics libraries
- Clean interface for testing Viron entity placement and behavior
- RenderWindow class for simplified Pygame window management
Patchwork provides a RenderWindow class that encapsulates Pygame initialization and window management. This class is designed for composition, not inheritance, making it easy to integrate into projects without subclassing.
- Automatic Pygame initialization
- Window and surface management
- Event loop handling with custom event handlers
- Frame rate control
- Clean API for common rendering operations
from render_window import RenderWindow
import pygame
# Create window
window = RenderWindow("My Application", 800, 600)
surface = window.get_surface()
# Register custom event handlers
def handle_input(event):
if event.type == pygame.KEYDOWN:
print(f"Key pressed: {event.key}")
window.register_event_handler(handle_input)
# Main loop
while window.should_continue():
surface.fill((0, 0, 0))
# ... render your content ...
pygame.display.update()
window.tick(60) # 60 FPS
pygame.quit()See render_window_example.py for more usage examples, including integration with the existing Graphik class.
Clone the repository and install dependencies:
git clone https://github.com/dmccoystephenson/testing-drawing-grid.git
cd testing-drawing-grid
pip install -r requirements.txt # if a requirements file existsTo launch the Patchwork visualization:
bash run.shOr run it directly:
python main.pyMake sure Viron is running or properly configured for environment data access.
- Visualization of entity grids and spatial data from Viron
- Debugging simulations in real-time
- Prototyping user interfaces or tile-based systems
- Educational demos of 2D virtual environments
- Add support for other graphics libraries (Tkinter, OpenGL, etc.)
- Layered rendering and animation
- Customizable grid styling
- Real-time interaction with live Viron simulations
This project is licensed under the Preponderous Non-Commercial License (Preponderous-NC).
It is free to use, modify, and self-host for non-commercial purposes, but commercial use requires a separate license.
Disclaimer: Preponderous Software is not a legal entity.
All rights to works published under this license are reserved by the copyright holder, Daniel McCoy Stephenson.
Full license text:
https://github.com/Preponderous-Software/preponderous-nc-license/blob/main/LICENSE.md
Created by Daniel McCoy Stephenson as part of the Preponderous ecosystem.