Generating Random circle: using c/c++ and graphics

Hey guys, in this post I am writing very short graphics program. This program generates random circle of random size. You can modify the delay time to see the effect more clearly. Here's the screen shot of the output.


Here's the program. Enjoy coding...

/* 
    Programmer: Ashok Kumar Shrestha (ak007)
    Program details: Generates the random circle
*/

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
int main()
{
    int i,j,x=0,y=0;
    int color=0;
    int gd=DETECT, gm;
    initgraph(&gd,&gm,"..\\bgi");
    cleardevice();
    setcolor(0);
    randomize();
    while(!kbhit())
    {
        delay(70);

        color=15-random(1500)%15;
        setcolor(color);
        setfillstyle(1,color);
        x=639-random(90000)%639;
        y=460-random(90000)%460;
        circle(x,y,110-random(1000)%100);
        floodfill(x,y,color);
    }
    return 0;
}
//End of the program

Comments

Post a Comment

Popular posts from this blog

Wizard Quiz: Privacy Policy

Sorting Hat: Privacy Policy

mTranslator