Skip to content

Latest commit

 

History

History
137 lines (93 loc) · 5.02 KB

File metadata and controls

137 lines (93 loc) · 5.02 KB

Computer Graphics Using C

A comprehensive collection of computer graphics programs implemented in C. This repository contains various algorithms such as line, circle, and ellipse drawing (DDA, Bresenham, Midpoint) and polygon filling techniques (Boundary Fill, Flood Fill), along with sample outputs for visualization. Ideal for students and enthusiasts learning graphics programming.


Table of Contents

  1. Introduction
  2. Programs Included
  3. How to Compile and Run
  4. Screenshots
  5. License

Introduction

This repository is a curated collection of fundamental computer graphics programs written in C. Each program demonstrates a specific algorithm for rendering graphics on a screen, ranging from basic line drawing to complex polygon filling. The repository also includes screenshots of outputs to help visualize the results.


Programs Included

1. Line Drawing using Y = mX + C

  • Code: y_mx_c_line.c
  • Description: Draws a straight line based on the equation Y = mX + C.
  • Screenshot: Y=MX+C Output

2. Line Drawing using DDA Algorithm

  • Code: dda_line.c
  • Description: Implements the Digital Differential Analyzer (DDA) algorithm for line drawing.
  • Screenshot: DDA Line Output

3. Line Drawing using Bresenham’s Algorithm

  • Code: bresenham_line.c
  • Description: Implements Bresenham's line drawing algorithm for efficient rendering of straight lines.
  • Screenshot: Bresenham Line Output

4. Circle Drawing using Midpoint Circle Algorithm

  • Code: midpoint_circle.c
  • Description: Draws a circle using the Midpoint Circle algorithm.
  • Screenshot: Midpoint Circle Output

5. Circle Drawing using Bresenham’s Algorithm

  • Code: bresenham_circle.c
  • Description: Implements Bresenham's algorithm to draw a circle.
  • Screenshot: Bresenham Circle Output

6. Ellipse Drawing using Midpoint Ellipse Algorithm

  • Code: midpoint_ellipse.c
  • Description: Draws an ellipse using the Midpoint Ellipse algorithm.
  • Screenshot: Midpoint Ellipse Output

7. Hut Drawing in Computer Graphics

  • Code: hut_drawing.c
  • Description: Draws a simple hut-like structure using graphics primitives.
  • Screenshot: Hut Drawing Output

8. Polygon Filling using Boundary Fill Algorithm

  • Code: boundary_fill.c
  • Description: Fills a polygon region using the Boundary Fill algorithm.
  • Screenshot: Boundary Fill Output

9. Polygon Filling using Flood Fill Algorithm

  • Code: flood_fill.c
  • Description: Fills a polygon region using the Flood Fill algorithm.
  • Screenshot: Flood Fill Output

How to Compile and Run

  1. Install a C compiler such as GCC and ensure the graphics library (e.g., graphics.h) is set up.
  2. Compile a program using:
    gcc -o output_program programs/program_name.c -lgraph
  3. Run the program using:
    ./output_program

Screenshots

Below are sample outputs of the programs:

Midpoint Ellipse Drawing

Midpoint Ellipse Output

Boundary Fill Algorithm

Boundary Fill Output

Flood Fill Algorithm

Flood Fill Output


License

This repository is licensed under the MIT License. You are free to use, modify, and distribute the code with proper attribution.


Feel free to fork, star, or contribute to this repository! For any issues or suggestions, please open an issue in the repository.