0% found this document useful (0 votes)
127 views

Example C Program Graphics

The first document contains code to create a basic graph by detecting the graphics driver, initializing the graphics mode, and plotting a single white pixel at coordinates 300, 200 before closing the graph. The second document contains code to simulate the movement of a truck by using a for loop to increment the x-coordinate over time, drawing the truck components at the new location each iteration and changing the color, creating an animated effect before closing the graph. The third document contains code to draw a full circle by using an arc and angle variable to incrementally draw the outline, retrieve the start coordinates to plot colored circles inside on each iteration, and delay to slow the animation, completing a full rotating circle before closing the graph.

Uploaded by

ManokRed123
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

Example C Program Graphics

The first document contains code to create a basic graph by detecting the graphics driver, initializing the graphics mode, and plotting a single white pixel at coordinates 300, 200 before closing the graph. The second document contains code to simulate the movement of a truck by using a for loop to increment the x-coordinate over time, drawing the truck components at the new location each iteration and changing the color, creating an animated effect before closing the graph. The third document contains code to draw a full circle by using an arc and angle variable to incrementally draw the outline, retrieve the start coordinates to plot colored circles inside on each iteration, and delay to slow the animation, completing a full rotating circle before closing the graph.

Uploaded by

ManokRed123
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Basic graph

#include <graphics.h>
#include <conio.h>

int main()
{
void clrscr();
int driver = DETECT ,mode;
initgraph(&driver,&mode,"c:\\tc\\bgi");
putpixel(300,200,WHITE);
getch();
closegraph();
}

Moving truck graph


#include <graphics.h>
#include <dos.h>
#include <conio.h>

main()
{
int i, j = 0, gd = DETECT, gm;

initgraph(&gd,&gm,"C:\\TC\\BGI");

settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(25,240,"Press any key to view the moving car");

getch();
setviewport(0,0,639,440,1);

for( i = 0 ; i <= 420 ; i = i + 10, j++ )


{
rectangle(50+i,275,150+i,400);
rectangle(150+i,350,200+i,400);
circle(75+i,410,10);
circle(175+i,410,10);
setcolor(j);
delay(100);

if( i == 420 )
break;

clearviewport();
}

getch();
closegraph();
return 0;
}
circle?
#include<graphics.h>
#include<conio.h>
#include<dos.h>

main()
{
int gd = DETECT, gm, x, y, color, angle = 0;
struct arccoordstype a, b;
initgraph(&gd, &gm, "C:\\TC\\BGI");
delay(2000);
while(angle<=360)
{
setcolor(BLACK);
arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100);
setcolor(RED);
getarccoords(&a);
circle(a.xstart,a.ystart,25);
setcolor(BLACK);
arc(getmaxx()/2,getmaxy()/2,angle,angle+2,150);
getarccoords(&a);
setcolor(GREEN);
circle(a.xstart,a.ystart,25);
angle = angle+5;
delay(50);
}
getch();
closegraph();
}

You might also like