Skip to content

This repository contains a collection of examples and exercises developed for a Computer Graphics course, utilizing Python and OpenGL. It serves as a practical resource for students and enthusiasts to explore fundamental concepts in computer graphics through hands-on coding.

Notifications You must be signed in to change notification settings

othman-shbeir/Computer-Graphics-Course-Using-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Computer Graphics Course Using Python

This repository contains a collection of examples and exercises developed for a Computer Graphics course, utilizing Python and OpenGL. It serves as a practical resource for students and enthusiasts to explore fundamental concepts in computer graphics through hands-on coding.

📁 Repository Structure

  • firstAttempt.py: Initial setup and basic OpenGL window creation.
  • MakingLineDrawings.py: Demonstrates line drawing techniques using OpenGL.
  • drawPolyLineFile.py: Reads coordinate data from files and renders polylines.
  • DrawingTheSierpinskiGasket.py: Illustrates recursive drawing of the Sierpinski Gasket fractal.
  • DotPlot(Curve).py: Plots curves using dot representations.
  • BigDipper.py: Renders the Big Dipper constellation using coordinate data.
  • data/: Contains data files (e.g., dino.dat) used for polyline rendering.
  • MakingLineDrawings.py: Plots curves using line strips.
  • hardwireHouse.py: Draws a house by defining all its vertices coordinates.
  • parameterizedHouse.py: Draws a house by defining only the peak coordinates, the house width, and its height.
  • drawPolyLine.py: Drawing Polyline using drawPolyLine Function.
  • drawingLinesUsingMoveToAndLineTo.py: Draws lines using custom moveTo and lineTo functions in a 2D space.
  • drawingChessBoard.py: Draws an 8x8 chessboard using OpenGL's glRecti, alternating square colors.
  • DrawTwoRectanglesUsing glRecti.py: Renders two filled rectangles using glRecti function.
  • drawFlurry.py: Generates a random flurry of shaded rectangles across the screen using glRecti.
  • drawRectangleCornerSize.py: Draws a rectangle from a given corner point with a specified width and aspect ratio.
  • drawRectangleFromCentralPoint.py: Draws a filled rectangle centered at a given point with specified width and height.
  • LargestRectangleWithAspectRatioR.py: Draws the largest possible filled rectangle within a 400x400 drawing area, scaled according to a user-specified aspect ratio R.
  • DrawPolygon.py: Demonstrates polygon drawing technique using OpenGL.
  • Interactive_creation_of_a_polyline.py: Draws Polyline using Mouse Clicks.
  • Freehand.py: Freehand Drawing with Mouse Movement.
  • Keyboard_interaction.py: Demonstrate keyboard Input and Drawing.
  • sincFunction.py: Demonstrating sinc function ploting using setWindow and setViewport.
  • drawDinoAndShowItInViewport.py: Drawing a dino from file in a viewport.
  • ngon.py: Drawing Regular Polygons with N edges.
  • Rosette.py: Drawing Rosette diagrams.
  • ArcDrawing.py: Drawing Arcs.
  • StellationDiagram.py: Drawing stellation diagrams.
  • Cohen-Sutherland.py: Cohen Sutherland algorithm implementation.
  • Cohen-Sutherlan-Case-study.py: Add a case study on Cohen sutherland algorithm. The case-study is a window and a line. The parts which are outside the window will be in red color while the parts which lies inside the window in green color.
  • TransformedHouse.py: Applying some transformations on house drawing.
  • TransformedDino.py: Using transformations to draw rotated dinos in circle view.
  • TransformedDino2.py: Using transformations to draw not rotated dinos in circle.

🛠️ Prerequisites

Ensure you have the following installed:

You can install the required packages using pip:

pip install PyOpenGL PyOpenGL_accelerate numpy

🚀 Getting Started

  1. Clone the repository:

    git clone https://github.com/cu2021/Computer-Graphics-Course-Using-Python.git
    cd Computer-Graphics-Course-Using-Python
  2. Run an example:

    python firstAttempt.py

Replace firstAttempt.py with any other script to explore different examples.

📚 Course Topics Covered

  • OpenGL basics and window management
  • Drawing primitives: points, lines, and polygons
  • Transformations: translation, rotation, scaling
  • Recursive graphics and fractals
  • Reading and rendering coordinate data from files
  • Plotting curves and constellations

🤝 Contributing

Contributions are welcome! If you have suggestions, improvements, or additional examples to share, feel free to fork the repository and submit a pull request.

About

This repository contains a collection of examples and exercises developed for a Computer Graphics course, utilizing Python and OpenGL. It serves as a practical resource for students and enthusiasts to explore fundamental concepts in computer graphics through hands-on coding.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages