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.
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
- Draw Lines
- Draw Rectangles
- Draw Triangles
- Draw Circles
- Add new objects
- Delete existing objects
- Modify object properties
- Redraw the canvas automatically after modifications
- Render the complete drawing in the terminal
- Support multiple graphical objects on the same canvas
- Language: C
- Compiler: GCC
- Graphics Representation: 2D Character Array
- Optional Library: ncurses (for enhanced terminal-based UI)
Efficiently draws straight lines between two points using integer arithmetic.
Generates circles by calculating symmetric points around the center.
Constructed using four connected line segments.
Constructed by connecting three vertices using line segments.
2D-Graphics-Editor/
│
├── graphics_editor.c
├── README.md
└── screenshots/
└── sample_output.png
Compile:
gcc graphics_editor.c -o graphics_editor -lmRun:
./graphics_editorCompile:
gcc graphics_editor.c -o graphics_editor.exe -lmRun:
graphics_editor.exe===== GRAPHICS EDITOR =====
1. Add Object
2. Delete Object
3. Modify Object
4. Display Canvas
5. Exit
1. Line
2. Rectangle
3. Triangle
4. Circle
Users can enter the required coordinates and dimensions to create the selected shape.
____________________________________________________________
____________________________________________________________
____________________________________________________________
____________________________________________________________
____________________________________________________________
_____****************_______________________________________
_____ * *______________________________________
_____ * *______________________________________
_____ * *______________________________________
_____ * *______________________________________
_____ * *______________________________________
_____ * *______________________________________
_____****************_______________________________________
____________________________________________________________
____________________________________________________________
Creates and stores a new graphical object on the canvas.
Removes a selected object and updates the drawing.
Updates the coordinates or dimensions of an existing object.
Prints the current drawing stored in the 2D character array.
This project helps in understanding:
- Basic Computer Graphics Concepts
- Raster Graphics Representation
- Graphics Drawing Algorithms
- Data Structures in C
- Object Management Techniques
- Modular Programming
- 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
Contributions are welcome.
- Fork the repository
- Create a feature branch
git checkout -b feature-name- Commit your changes
git commit -m "Add new feature"- Push to GitHub
git push origin feature-name- Open a Pull Request
Abhishek Reddy
First year Engineering student.