Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions Lab-3_29-08-2019/circle.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Author: Kartikei Mittal
// Author: Kartikei Mittal, Tokir Manva
// Circle Drawing
#include <bits/stdc++.h>
#include <graphics.h>
Expand All @@ -15,31 +15,7 @@ void draw_y_axis() {for(int i=-my_SIZE[1]; i<my_SIZE[1]; i+=4) my_putpixel(0, i,

void my_circle(int x_c, int y_c, int r)
{
// int p = 1-r, x=r, y=0;
// while(x>y)
// {
// y++;
// if (p <= 0)
// p += 2*y + 1;
// else
// {
// x--;
// p += 2*(y-x) + 1;
// }
// if (x < y)
// break;
// my_putpixel(x + x_c, y + y_c, GREEN);
// my_putpixel(-x + x_c, y + y_c, WHITE);
// my_putpixel(x + x_c, -y + y_c, WHITE);
// my_putpixel(-x + x_c, -y + y_c, WHITE);
// if(x != y)
// {
// my_putpixel( y + x_c, x + y_c, GREEN);
// my_putpixel(-y + x_c, x + y_c, WHITE);
// my_putpixel( y + x_c, -x + y_c, WHITE);
// my_putpixel(-y + x_c, -x + y_c, WHITE);
// }
// }

int p = 1-r;
for(int x=0, y=r; x<=r;)
{
Expand All @@ -56,14 +32,36 @@ void my_circle(int x_c, int y_c, int r)
my_putpixel( y + x_c, -x + y_c, WHITE);
my_putpixel(-y + x_c, -x + y_c, WHITE);
}
// delay(50);
}
void flood(int x,int y)
{
if(getpixel(x,y) == BLACK )
{
putpixel(x,y,YELLOW);
flood(x+1,y);
flood(x-1,y);
flood(x,y+1);
flood(x,y-1);
}
delay(10);
}

int main()
{
//w for width of circle and width is 10
int w=10;
cout<<"Hello World! ";
// cout<<"Enter Width of Circle\n";
// scanf("%d",&w);
initwindow(my_SIZE[0], my_SIZE[1], "Graphics Window");
draw_x_axis(); draw_y_axis();
// int gd,gm;
// detectgraph(&gd,&gm);
// initgraph(&gd,&gm,"c:\\tc\\bgi");
my_circle(60, 80, 50);
my_circle(60, 80, 50+w);
flood(60+80+5,80);
while(!kbhit())
delay(100);
return 0;
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
# Computer Graphics Lab

This repositry contains work done in Computer Graphics Lab.

## Contributer(s)

[Kartikei Mittal](https://github.com/Kartikei-12)

[Tokir Manva](https://github.com/tokirmanva22)