Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
163 views

Graphics Programming in C

The document discusses graphics programming in C and provides a sample code for basic car animation to help a user new to graphics programming in C learn. The sample code uses graphics functions in C like line, circle, rectangle to draw different parts of a car that animates across the screen. It includes the necessary header files, declares variables for delay and screen size, initializes the graphics screen, and uses a for loop with delay to repeatedly draw the car in a new position to create animation.

Uploaded by

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

Graphics Programming in C

The document discusses graphics programming in C and provides a sample code for basic car animation to help a user new to graphics programming in C learn. The sample code uses graphics functions in C like line, circle, rectangle to draw different parts of a car that animates across the screen. It includes the necessary header files, declares variables for delay and screen size, initializes the graphics screen, and uses a for loop with delay to repeatedly draw the car in a new position to create animation.

Uploaded by

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

Graphics programming in C

June 2014
The general purpose programming language C is the basic language in computer programming
but at the same the application of this language is most widely used.C language is used to
mimic text documents, mathematical and statistical operations and can also be used to create
animation programs.With the help of theC language, programs which create computer
graphics can be made. In the script of the C language, you can input the logic of the code that
can be used for designing graphics programsfor various animation needs, like that of car
animation.

Graphics programming in C
Issue
Solution
Note

Issue
I am new to graphics programming in C and would like some sample code for a
basic animation to help me learn.

Solution
This is the program for car animation:

#include<graphics.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<string.h>
#include<stdlib.h>
void main()
{
int v,s;
int gd= DETECT,gm;
initgraph(&gd,&gm," ");
line(0,290,634,290);
for(int i=10;i<=634;i++)
{
cleardevice();
line(130+i,200,180+i,150);
line(180+i,150,250+i,150);
line(250+i,150,300+i,200);
circle(300+i,275,15);
circle(150+i,275,15);
rectangle(120+i,200,350+i,260);
//line(0,275,634,275);
line(0,290,634,290);
delay(10);
}
for( i=634;i>=0;i

Note
Thanks to anu for this tip on the forum.
This document entitled Graphics programming in C from Kioskea (en.kioskea.net) is made available under the
Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license,
as this note appears clearly.

You might also like