Welcome to FunGraphics, a Python port of the library originally designed for teaching imperative programming at HES-SO Valais//Wallis.
This library makes 2D graphics fun and easy! It's perfect for learning how to code games, visualizations, and interactive apps without getting bogged down in complex frameworks.
- 🖌️ Simple 2D Graphics: Draw lines, rectangles, circles, text, and images with simple commands.
- ⌨️ Input Handling: React to keyboard events instantly.
- 💬 Dialogs: Built-in popups for asking questions (strings, characters) and showing messages.
- 🚀 Native Backend: Built on
tkinter(standard Python). No heavy downloads or complex setups!
- 🐍 Python 3.x
- 🖼️ Tkinter: Usually comes pre-installed with Python.
- 🍎 macOS users: If you see an error, just run:
brew install python-tk
- 🍎 macOS users: If you see an error, just run:
Clone the repository and you are ready to code! The library is self-contained in the src directory.
We've included some cool examples to get you started:
🔹 Basic Demo See what the library can do:
python3 examples/demo.py😵 Hangman Game A fully playable game:
python3 examples/hangman.pyIt's super easy to start your own project. Here is a template:
- Create a new file (e.g.,
my_game.py). - Make sure the
srcfolder is nearby. - Copy-paste this code:
import sys
import os
# 🔌 Connect to the library
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
from fungraphics.fun_graphics import FunGraphics
def main():
# 1️⃣ Create a window
fg = FunGraphics(800, 600, "My Awesome App 🚀")
# 2️⃣ Draw something cool
fg.setColor((255, 0, 0)) # 🔴 Red
fg.drawFillRect(100, 100, 200, 150)
fg.setColor((0, 0, 255)) # 🔵 Blue
fg.drawString(100, 300, "Hello World!", font_size=40)
# 3️⃣ Keep it running
while True:
fg.syncGameLogic(60) # 60 FPS
if __name__ == "__main__":
main()Here's where everything lives:
- 📦
src/fungraphics/: The magic happens here (Library code).fun_graphics.py: The main graphics engine.utils.py: Helpers for images.
- 💡
examples/: Learn by example.hangman.py: The classic word game.demo.py: Shows off all the drawing features.dialogs.py: Helpers for popups.
Based on the original FunGraphics library for Scala/Java developed by P.-A. Mudry at HES-SO Valais//Wallis.
This Python version was created entirely with the assistance of Artificial Intelligence.
The conversion from Scala/Java to Python was accomplished through:
- AI-driven code translation from the original Scala implementation
- Automated feature implementation to achieve 100% feature parity
- AI-assisted debugging and optimization
- Intelligent adaptation to Python idioms and best practices
This project demonstrates the power of AI in software development, successfully porting a complete graphics library while maintaining full compatibility with the original API design.
Technologies: Python 3.x, Tkinter, PIL/Pillow (optional) AI Tools: Advanced language models for code generation and problem-solving