Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshatAggarwal14 committed Apr 14, 2023
1 parent 2e602f9 commit a2bab35
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 101 deletions.
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# Paint-Application
This application is created by Akshat, Sahil & Tanveer.

This is a paint application that allows you to draw various shapes and patterns on the screen. The project is made using the `graphics.h` library and it provides a wide range of features for drawing and painting. Here are the features of the paint application:

## Features

- Choose the current color for drawing shapes or using brush using the different colors in Color box.
- Draw circles, lines, and rectangles.
- Use brush tool.
- Use fill tool to fill colors into a drawn shape.
- Use eraser tool to erase colored areas.
- Clear the screen using the clear button.
- Save the current drawing as `save.jpg` using the save button.
- Animate a car on the screen using the car button.
- Increase or decrease the size of the eraser or brush tool using `+` and `-` buttons.

## Preview

<p align="center">
The Paint Application

<img src="./images/EmptyScreen.png"/>
</p>

<p align="center">
Drawing made using different tools.

<img src="./images/Drawn.png"/>
</p>

<p align="center">
The animated car after you click the `car` button, and define the animation path by dragging and dropping.

<img src="./images/Car.png"/>
</p>

## Installation

1. Install the `graphics.h` library from [here](https://github.com/ullaskunder3/Solution-to-graphics.h).
2. Clone this github repository.
3. Build the `main.cpp` file using the `C/C++: Build .exe` task defined in `./.vscode/tasks.json`.

## Usage

To use the paint application, you can simply run the generated `a.exe` file after you build `main.cpp`. The application will open in a new window, and you can start drawing using the various tools and features available.

## Credits

This project was developed by the collaborative effort of Akshat and Sahil.
Binary file added images/Car.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Drawn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/EmptyScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
200 changes: 100 additions & 100 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void drawCar(int x, int y) {
int main() {
max_x = GetSystemMetrics(SM_CXSCREEN);
max_y = GetSystemMetrics(SM_CYSCREEN);
initwindow(max_x, max_y, "Paint - By Akshat, Sahil & Tanveer", -3, 0);
initwindow(max_x, max_y, "Paint - By Akshat and Sahil", -3, 0);
initial_screen();
initial_drawing_area();
display_buttons();
Expand Down Expand Up @@ -365,119 +365,119 @@ int main() {
}

switch (choice) {
case 0: {
break;
}
case 1: {
// circle
if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);

int cx = (x1 + x2) / 2, cy = (y1 + y2) / 2;
int r = sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))) / 2;
if (cy <= 100) continue;
if (cy - r <= 100) r = cy - 100;
cout << "Circle [(" << x1 << ", " << y1 << ") (" << x2 << ", " << y2 << ")]: (" << cx << ", " << cy << "), r = " << r << '\n';
circle(cx, cy, r);
// circle(cx, cy + 1, r);
case 0: {
break;
}
break;
}
case 2: {
// line
if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);

cout << "Line [(" << x1 << ", " << y1 << ") (" << x2 << ", " << y2 << ")]\n";
line(x1, max(y1, 101), x2, max(y2, 101));
// line(x1, max(y1 + 1, 101), x2, max(y2 + 1, 101));
case 1: {
// circle
if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);

int cx = (x1 + x2) / 2, cy = (y1 + y2) / 2;
int r = sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))) / 2;
if (cy <= 100) continue;
if (cy - r <= 100) r = cy - 100;
cout << "Circle [(" << x1 << ", " << y1 << ") (" << x2 << ", " << y2 << ")]: (" << cx << ", " << cy << "), r = " << r << '\n';
circle(cx, cy, r);
// circle(cx, cy + 1, r);
}
break;
}
break;
}
case 3: {
// rectangle
if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);

cout << "Rectangle [(" << x1 << ", " << y1 << ") (" << x2 << ", " << y2 << ")]\n";
drawRectangle(x1, max(y1, 101), x2, max(y2, 101));
// drawRectangle(x1, max(y1 + 1, 101), x2, max(y2 + 1, 101));
case 2: {
// line
if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);

cout << "Line [(" << x1 << ", " << y1 << ") (" << x2 << ", " << y2 << ")]\n";
line(x1, max(y1, 101), x2, max(y2, 101));
// line(x1, max(y1 + 1, 101), x2, max(y2 + 1, 101));
}
break;
}
break;
}
case 4: {
// brush
if (GetAsyncKeyState(VK_LBUTTON)) {
x2 = Cursor.x, y2 = Cursor.y;
int tsize = size / 2;
if (y2 - tsize <= 100) continue;
while (tsize--) {
circle(x2, y2, tsize);
case 3: {
// rectangle
if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);

cout << "Rectangle [(" << x1 << ", " << y1 << ") (" << x2 << ", " << y2 << ")]\n";
drawRectangle(x1, max(y1, 101), x2, max(y2, 101));
// drawRectangle(x1, max(y1 + 1, 101), x2, max(y2 + 1, 101));
}
break;
}
break;
}
case 5: {
// flood fill
if (GetAsyncKeyState(VK_LBUTTON)) {
if (Cursor.y <= 100) continue;
floodfill(Cursor.x, Cursor.y, BLACK); // no floodfill on black
case 4: {
// brush
if (GetAsyncKeyState(VK_LBUTTON)) {
x2 = Cursor.x, y2 = Cursor.y;
int tsize = size / 2;
if (y2 - tsize <= 100) continue;
while (tsize--) {
circle(x2, y2, tsize);
}
}
break;
}
break;
}
case 6: {
// eraser
int old = getcolor();
setcolor(WHITE);
if (GetAsyncKeyState(VK_LBUTTON)) {
x2 = Cursor.x, y2 = Cursor.y;
int tsize = size;
if (y2 - tsize / 2 < 100) continue;
while (tsize--) {
rectangle(x2 - tsize / 2, y2 - tsize / 2, x2 + tsize / 2, y2 + tsize / 2);
case 5: {
// flood fill
if (GetAsyncKeyState(VK_LBUTTON)) {
if (Cursor.y <= 100) continue;
floodfill(Cursor.x, Cursor.y, BLACK); // no floodfill on black
}
break;
}
setcolor(old);
break;
}
case 7: {
// car

if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);
if (x2 == x1 && y2 == y1) {
drawCar(x1 - 88, y1 - 40);
break;
case 6: {
// eraser
int old = getcolor();
setcolor(WHITE);
if (GetAsyncKeyState(VK_LBUTTON)) {
x2 = Cursor.x, y2 = Cursor.y;
int tsize = size;
if (y2 - tsize / 2 < 100) continue;
while (tsize--) {
rectangle(x2 - tsize / 2, y2 - tsize / 2, x2 + tsize / 2, y2 + tsize / 2);
}
}
setcolor(old);
break;
}
case 7: {
// car

initial_drawing_area();
setcolor(COLOR(163, 167, 176));
line(0, 98, max_x, 98);

int delta_x = x2 - x1, delta_y = y2 - y1;
int steps = max(abs(delta_x), abs(delta_y));
float dx = delta_x / (float)steps;
float dy = delta_y / (float)steps;
float x = x1, y = y1;
if (ismouseclick(WM_LBUTTONUP)) {
x2 = Cursor.x, y2 = Cursor.y;
clearmouseclick(WM_LBUTTONUP);
if (x2 == x1 && y2 == y1) {
drawCar(x1 - 88, y1 - 40);
break;
}

for (int i = 0; i <= steps; ++i) {
initial_drawing_area();
setcolor(COLOR(163, 167, 176));
line(0, 98, max_x, 98);

int delta_x = x2 - x1, delta_y = y2 - y1;
int steps = max(abs(delta_x), abs(delta_y));
float dx = delta_x / (float)steps;
float dy = delta_y / (float)steps;
float x = x1, y = y1;

for (int i = 0; i <= steps; ++i) {
drawCar(round(x) - 88, round(y) - 40);
delay(1); // to see line being drawn
x += dx;
y += dy;

setfillstyle(SOLID_FILL, WHITE);
rectangle(0, 100, max_x - 1, max_y - 1);
floodfill(2, 105, COLOR(163, 167, 176));
}
drawCar(round(x) - 88, round(y) - 40);
delay(1); // to see line being drawn
x += dx;
y += dy;

setfillstyle(SOLID_FILL, WHITE);
rectangle(0, 100, max_x - 1, max_y - 1);
floodfill(2, 105, COLOR(163, 167, 176));
}
drawCar(round(x) - 88, round(y) - 40);
break;
}
break;
}
}
}

Expand Down

0 comments on commit a2bab35

Please sign in to comment.