Turbo C Graphics - Drawing Circles with Pixels
by Prabakaran[ Edit ] 2012-09-07 15:09:16
#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <bios.h>
#include <math.h>
void DrawCircle(int x, int y, int r, int color)
{
static const double PI = 3.1415926535;
double i, angle, x1, y1;
for(i = 0; i < 360; i += 0.1)
{
angle = i;
x1 = r * cos(angle * PI / 180);
y1 = r * sin(angle * PI / 180);
putpixel(x + x1, y + y1, color);
}
}
void main()
{
int grd, grm, i;
int color, xmax, ymax;
detectgraph(&grd,&grm);
initgraph(&grd, &grm, "");
color = GREEN;
setbkcolor(BLUE);
xmax = getmaxx();
ymax = getmaxy();
setcolor(WHITE);
rectangle(0,0,xmax,ymax);
for(i = 0; i < 230; i += 10)
{
DrawCircle(320, 240, i, color++);
if(color > WHITE)
color = GREEN;
}
getch();
closegraph();
}