Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🎨 2D Graphics Editor in C

A menu-driven 2D Graphics Editor implemented in C using a 2D character array as the drawing canvas. The editor allows users to create, display, modify, and delete basic geometric shapes such as lines, rectangles, triangles, and circles directly in the terminal.


📖 Overview

This project simulates a simple graphics editor using ASCII characters. The canvas is initialized with underscore (_) characters representing empty space, while graphical objects are drawn using asterisks (*).

The project demonstrates fundamental concepts of:

  • Computer Graphics
  • Data Structures
  • Algorithm Design
  • Character-Based Rendering
  • Menu-Driven Programming in C

✨ Features

Drawing Operations

  • Draw Lines
  • Draw Rectangles
  • Draw Triangles
  • Draw Circles

Object Management

  • Add new objects
  • Delete existing objects
  • Modify object properties
  • Redraw the canvas automatically after modifications

Display

  • Render the complete drawing in the terminal
  • Support multiple graphical objects on the same canvas

🛠 Technologies Used

  • Language: C
  • Compiler: GCC
  • Graphics Representation: 2D Character Array
  • Optional Library: ncurses (for enhanced terminal-based UI)

🧠 Algorithms Implemented

Bresenham's Line Drawing Algorithm

Efficiently draws straight lines between two points using integer arithmetic.

Midpoint Circle Algorithm

Generates circles by calculating symmetric points around the center.

Rectangle Drawing

Constructed using four connected line segments.

Triangle Drawing

Constructed by connecting three vertices using line segments.


📂 Project Structure

2D-Graphics-Editor/
│
├── graphics_editor.c
├── README.md
└── screenshots/
    └── sample_output.png

🚀 Compilation and Execution

Linux/macOS

Compile:

gcc graphics_editor.c -o graphics_editor -lm

Run:

./graphics_editor

Windows (MinGW)

Compile:

gcc graphics_editor.c -o graphics_editor.exe -lm

Run:

graphics_editor.exe

📋 Menu Options

===== GRAPHICS EDITOR =====

1. Add Object
2. Delete Object
3. Modify Object
4. Display Canvas
5. Exit

Add Object Menu

1. Line
2. Rectangle
3. Triangle
4. Circle

Users can enter the required coordinates and dimensions to create the selected shape.


📸 Sample Output

____________________________________________________________
____________________________________________________________
____________________________________________________________
____________________________________________________________
____________________________________________________________
_____****************_______________________________________
_____ *              *______________________________________
_____ *              *______________________________________
_____ *              *______________________________________
_____ *              *______________________________________
_____ *              *______________________________________
_____ *              *______________________________________
_____****************_______________________________________
____________________________________________________________
____________________________________________________________

🔄 Supported Operations

Add Object

Creates and stores a new graphical object on the canvas.

Delete Object

Removes a selected object and updates the drawing.

Modify Object

Updates the coordinates or dimensions of an existing object.

Display Canvas

Prints the current drawing stored in the 2D character array.


🎯 Learning Outcomes

This project helps in understanding:

  • Basic Computer Graphics Concepts
  • Raster Graphics Representation
  • Graphics Drawing Algorithms
  • Data Structures in C
  • Object Management Techniques
  • Modular Programming

🔮 Future Enhancements

  • Interactive drawing using ncurses
  • Mouse and keyboard support
  • Shape filling algorithms
  • Colored graphics
  • Save and load drawings from files
  • Undo/Redo functionality
  • Object selection and movement
  • Layer-based rendering

🤝 Contributing

Contributions are welcome.

  1. Fork the repository
  2. Create a feature branch
git checkout -b feature-name
  1. Commit your changes
git commit -m "Add new feature"
  1. Push to GitHub
git push origin feature-name
  1. Open a Pull Request

👨‍💻 Author

Abhishek Reddy

First year Engineering student.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors