Category Archives: Graphics

Bresenham’s Line Drawing Algorithm in C and C++

Here you will get program for bresenham’s line drawing algorithm in C and C++. This algorithm is used in computer graphics for drawing line. The program will work in Turbo C or Turbo C++ compiler as it uses graphics.h header file. Make sure to change the path of BGI folder inside initgraph() function according to your… Read More »

Bresenham’s Midpoint Circle Algorithm in C and C++

Here you will get program for bresenham’s midpoint circle algorithm in C and C++. It is an algorithm used in computer graphics for drawing circle. This program will work in Turbo C or Turbo C++ compiler as it uses graphics.h header file. Change the path of BGI file inside initgraph() function according to your system… Read More »

Make Analog Clock in C Using Graphics

In this tutorial you will learn how you can create an analog clock in C using graphics. This tutorial is written in a way that a beginner C graphics programmer can also understand. Before getting into the main let me explain the functions I have used in the program. Also Read: C/C++ Program to Create a… Read More »

Simple program to create a moving car in graphics

#include<graphics.h> #include<conio.h> #include<dos.h> void main() { int gdriver=DETECT,gmode,i=0,j=0; initgraph(&gdriver,&gmode,”c:\turboc3\bgi”); for(i;i<420;++i) { line(0,245,650,245); line(0+i,200,210+i,200); line(50+i,200,70+i,170); line(70+i,170,140+i,170); line(140+i,170,160+i,200); line(85+i,170,85+i,200); line(125+i,170,125+i,200); line(0+i,200,0+i,230); line(210+i,200,210+i,230); line(0+i,230,50+i,230); circle(65+i,230,15); line(80+i,230,130+i,230); circle(145+i,230,15); line(210+i,230,160+i,230); pieslice(65+i,230,359-j,360-j,15); pieslice(65+i,230,179-j,180-j,15); pieslice(65+i,230,89-j,90-j,15); pieslice(65+i,230,269-j,270-j,15); pieslice(145+i,230,359-j,360-j,15); pieslice(145+i,230,179-j,180-j,15); pieslice(145+i,230,89-j,90-j,15); pieslice(145+i,230,269-j,270-j,15); if(j==179) j=0; ++j; delay(30); cleardevice(); } closegraph(); }

C++ program to create a loading bar

#include<iostream.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main() { int x=170,i,gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,”c:\tc\bgi”); settextstyle(DEFAULT_FONT,HORIZ_DIR,2); outtextxy(170,180,”LOADING,PLEASE WAIT”); for(i=0;i<300;++i) { delay(30); line(x,200,x,220); x++; } getch(); closegraph(); }

C++ Program to print a man using graphics

#include<graphics.h> #include<iostream.h> #include<stdlib.h> #include<stdio.h> #include<conio.h> void main() {    int gdriver=DETECT,gmode;    initgraph(&gdriver, &gmode, “c:\turboc3\bgi”);    //for head    ellipse(320,95,360,0,25,20);    line(298,85,341,85);    circle(310,90,2);    circle(330,90,2);    arc(320,100,200,-20,10);    //for neck    line(313,115,313,125);    line(328,115,328,125);    //For centre part    arc(320,225,72,107,100);    line(290,129,290,200);    line(350,129,350,200);    line(290,193,350,193);    line(290,200,350,200);    //for legs    line(290,200,285,280);  … Read More »