cgl icon indicating copy to clipboard operation
cgl copied to clipboard

Add 8 new Python examples for CGL library

Open Copilot opened this issue 7 months ago • 0 comments

This PR significantly expands the Python examples collection for the CGL library, adding 8 comprehensive new examples that demonstrate various features and capabilities.

New Examples Added

Basic Examples

  • basic_window.py - Simple window creation with OpenGL setup and event handling
  • basic_widgets.py - Comprehensive widget demonstration with animations, interactivity, and multiple demo modes

Mathematical Visualizations

  • approximating_pi.py - Monte Carlo method for approximating π with real-time visualization and statistics
  • basic_plotting.py - Data visualization suite with function plots, scatter plots, bar charts, and pie charts
  • mandelbrot_viewer.py - Interactive Mandelbrot set fractal viewer with zoom, pan, and parameter controls
  • triangle_fractal.py - Sierpinski triangle fractal with both chaos game and recursive rendering modes

Games and Simulations

  • game_of_life.py - Interactive Conway's Game of Life with pattern insertion, mouse drawing, and controls
  • simple_physics.py - Physics simulation with bouncing balls, collision detection, trails, and force application

Features

Translated from C examples: Several examples are faithful Python translations of existing C examples
Original Python examples: New examples designed specifically for Python wrapper capabilities
Educational value: Progressive complexity from basic window creation to advanced simulations
Interactive controls: Mouse and keyboard interactions for enhanced user experience
Comprehensive documentation: Each example includes detailed comments and usage instructions
Consistent style: All examples follow the same MIT license format and coding patterns

Quality Assurance

  • All examples pass Python syntax validation
  • API usage verified against existing examples for consistency
  • Created comprehensive README.md documentation for the Python examples directory
  • Examples demonstrate diverse CGL features: windowing, widgets, graphics, mathematics, physics, and fractals

This brings the total Python examples from 7 to 15, providing much better learning resources for users of the CGL Python wrapper.

Fixes #38.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Jul 06 '25 13:07 Copilot