Ask a question »

Graphics programming in C

June 2015

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



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.
For unlimited offline reading, you can download this article for free in PDF format:
Graphics-programming-in-c.pdf

See also

In the same category

Published by aakai1056. - Latest update by Paul Berentzen
This document entitled « Graphics programming in C » from CCM (ccm.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.