Computer Graphics in C for CARROM Design


//Developed by Ashish Prajapati
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int i,midx,midy,left, top, right, bottom;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "..//bgi");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)  /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
setbkcolor(WHITE);
{
setcolor(RED);

for(i=0;i<24;i++)
{
left = getmaxx() / 2 - 200;
top = getmaxy() / 2 - 200;//Developed by Ashish Prajapati
right = getmaxx() / 2 + 200;
bottom = getmaxy() / 2 + 200;
/* draw a rectangle */
rectangle(left-i,top-i,right+i,bottom+i);
}


}
setcolor(YELLOW);

for(i=0;i<200;i++)
{
left = getmaxx() / 2 - 200;
top = getmaxy() / 2 - 200;
right = getmaxx() / 2 + 200;
bottom = getmaxy() / 2 + 200;
/* draw a rectangle */
rectangle(left+i,top+i,right-i,bottom-i);
}
setcolor(BROWN);
line(left-20,top-20,left-5,bottom+5);
line(right+5,top-5,right+20,bottom+20);
line(right+5,bottom+5,left-20,bottom+20);
line(left-5,top-5,right+20,top-20);


setcolor(GREEN);
midx = getmaxx() / 2;
midy = getmaxy() / 2;
for(i=0;i<5;i++)
{
circle(midx,midy,39-i);
}
setcolor(RED);
circle(midx,midy,42);
setcolor(MAGENTA);
for(i=0;i<3;i++)
circle(midx,midy,45+i);

setcolor(CYAN);
for(i=0;i<12;i++)
{
circle(midx-188,midy-188,12-i);
circle(midx-188,midy+188,12-i);
circle(midx+188,midy-188,12-i);
circle(midx+188,midy+188,12-i);
}
/*circle hole*/
setcolor(RED);
circle(midx-188,midy-188,12);
circle(midx-188,midy+188,12);//Developed by Ashish Prajapati
circle(midx+188,midy-188,12);
circle(midx+188,midy+188,12);

setcolor(BLUE);
for(i=0;i<7;i++)
{
circle(midx-188,midy-188,7-i);
circle(midx-188,midy+188,7-i);
circle(midx+188,midy-188,7-i);
circle(midx+188,midy+188,7-i);
}


setcolor(BLUE);
line(midx-60,midy-60,midx-160,midy-160)   ;
line(midx-160,midy-60+220,midx-60,midy-160+220) ;
line(midx-160+220,midy-60,midx-60+220,midy-160) ;

line(midx-60+220,midy-60+220,midx-160+220,midy-160+220);
for(i=0;i<21;i++)
{
setcolor(39);
line(midx+20,midy+20,midx-i,midy+i);
setcolor(6);
line(midx+20,midy+20,midx+i,midy-i);
setcolor(5);
line(midx-20,midy-20,midx-i,midy+i);
setcolor(3);
line(midx-20,midy-20,midx+i,midy-i);

}
setcolor(BLUE);
for(i=0;i<4;i++)
{
circle(midx,midy,4-i);
}
setcolor(BLUE);
for(i=0;i<2;i++)
{
circle(midx,midy,20-i)  ;//Developed by Ashish Prajapati
}
setcolor(RED)  ;
line(midx+24,midy+24,midx-24,midy-24);
line(midx+24,midy+24,midx-24,midy+24);
line(midx-24,midy-24,midx-24,midy+24);
line(midx-24,midy+24,midx+24,midy-24);
line(midx-24,midy-24,midx+24,midy-24);
line(midx+24,midy+24,midx+24,midy-24);
/*Fall Circle*/
setcolor(BLUE);
{
circle(midx-140,midy-140,4);

circle(midx-140,midy+140,4);
circle(midx+140,midy-140,4);
circle(midx+140,midy+140,4);
}

/* circle of fall side*/
setcolor(BLUE);
{
circle(midx-148,midy-132,8);
circle(midx-148,midy+132,8);
circle(midx+148,midy-132,8);
circle(midx+148,midy+132,8);
circle(midx-132,midy-148,8);
circle(midx-132,midy+148,8);
circle(midx+132,midy-148,8);
circle(midx+132,midy+148,8);
}
/*Circle inside circle*/
setcolor(RED);
for(i=0;i<5;i++)
{
circle(midx-148,midy-132,5-i);
circle(midx-148,midy+132,5-i);
circle(midx+148,midy-132,5-i);
circle(midx+148,midy+132,5-i);
circle(midx-132,midy-148,5-i);
circle(midx-132,midy+148,5-i);
circle(midx+132,midy-148,5-i);
circle(midx+132,midy+148,5-i);
}
setcolor(BLUE);
/*Circle attachment line*/

for(int j=0;j<6;j++)
{
line(midx-134+2*j,midy-156+j,midx+134-2*j,midy-156+j);
line(midx-136,midy-140,midx+136,midy-140);

line(midx-134+2*j,midy+156-j,midx+134-2*j,midy+156-j);
line(midx+136,midy+140,midx-136,midy+140);

line(midx+156-j,midy+134-2*j,midx+156-j,midy-134+2*j);
line(midx+140,midy+136,midx+140,midy-136);

line(midx-156+j,midy-134+2*j,midx-156+j,midy+134-2*j);
line(midx-140,midy-136,midx-140,midy+136);
}//Developed by Ashish Prajapati


//line arc
{
arc(midx+60+10, midy-60-10,90,0, 14);
arc(midx+60+10, midy+60+10,0,270, 14);
arc(midx-60-10, midy-60-10,180,90, 14);
arc(midx-60-10, midy+60+10,270,180, 14);
}
getch();
closegraph();
return 0;
}//Developed by Ashish Prajapati

Post a Comment

7 comments:

  1. Amazing Personality of Mumbai Escorts Girls when you will look them you can’t stop your feelings. Feelings of every humen being, is very important to fulfill them because of our is life too short no one can say when it will be stop. You should to enjoy each and every moments of your life. If you want to enjoy your whole life with someone special so don’t worry about it. Because we brought new and fresh Mumbai Escorts who can give you deeply satisfaction. Now days every Mumbai Female Escorts are very professional in their work and they know how to keep client happy. They are very naughty and open minded Escorts in Mumbai. Foreigners and peoples who come outside of Mumbai in city are very crazy to meet our Independent Mumbai Escorts because they know here they find quality and trusty Escorts Service in Mumbai. When they enter in our agency they tells us their entire requirements and we finds the exact match for them because we don’t want to disappointed our customers at any cost. We have good collection of Independent Escorts in Mumbai and celebrities, models, Collage Girls Mumbai and premium escorts are on Demand. If you are looking something spicy and taste like red chilly then make us call or drop an e-mail for booking. We provides both incall and outcall Mumbai Escorts Service at reputed hotels. If you want to book our Mumbai Call Girls or Call Girls in Mumbai then don’t hesitate feel free contact us now. we are also providing service in these area also:- Rajkot Escorts | Juhu Escorts | Andheri Escorts | Raipur Escorts

    ReplyDelete
  2. If running proves to be a problem then it may be wise to find alternative exercises such as circuit training, weight training, swimming or cycling. great post to read

    ReplyDelete
  3. My site has some tips on how to perform search engine optimization (also know as SEO) on your website. check it out Using keyword analysis, you can identify the market size, number of search for that exact keyword, competitive arena and even identify the intent behind keyword searches.

    ReplyDelete
  4. Hi this is James Mexwell from USA and has been working as software service provider and providing help regarding pbs.org/activate If anyone among you faces this problem then do consider us immediately.

    ReplyDelete
  5. Then why does Woori Casino have a good reputation among not only users, but also eat-and-test sites compared to other competitive online casino sites? 우리카지노

    ReplyDelete
  6. i would alway prefer hotel rooms with flannel sheets and cotton beddings, i love the feel of those fabric’ Ada Compliance Website Design

    ReplyDelete
  7. There are many kinds of social graph sites that you can enjoy online. You can play pure games, and there are graph games only for betting sites. 바둑이사이트

    ReplyDelete