Edit
Edit
SE D 2024-25
CG Lab Practical
Code:
#include <graphics.h>
#include <iostream> #include
<math.h>
using namespace std;
float x = x1;
float y = y1;
while (y >= x) {
putpixel(xc + x, yc + y, WHITE);
putpixel(xc - x, yc + y, WHITE);
putpixel(xc + x, yc - y, WHITE);
putpixel(xc - x, yc - y, WHITE); putpixel(xc
+ y, yc + x, WHITE); putpixel(xc - y, yc + x,
WHITE); putpixel(xc + y, yc - x, WHITE);
putpixel(xc - y, yc - x, WHITE);
x++;
if (d > 0) {
y--;
d = d + 4 * (x - y) + 10;
} else {
d = d + 4 * x + 6;
}
}
}
int x1 = xc, y1 = yc - r;
int x2 = xc - r * sqrt(3) / 2, y2 = yc + r / 2;
int x3 = xc + r * sqrt(3) / 2, y3 = yc + r / 2;
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, (char*)"");
ShapeDrawer drawer;
int xc,yc,r;
cout<<"Name: Binay Tilokchandani"; cout<<"\
nenter x coordinate of center: ";
cin>>xc;
cout<<"enter y coordinate of center: ";
cin>>yc;
cout<<"enter radius: ";
cin>>r;
drawer.drawPattern(xc, yc, r);
getch(); closegraph();
return 0;
}
OUTPU
T