ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Home » C programs » graphics.h header file functions

bar3d() function in graphics.h in C

In this article, we are going to learn about the bar3d() function of graphics.h header file in C programming language and use it to design a cube design of different sizes.
Submitted by Manu Jemini, on March 20, 2018

This is very useful function as it allows us to make 3d shapes in C. To make this 3d bar, first thing is to initiate a graph. After initiating the graph we have to call the bar3d() function. This bar3d() function takes six parameters, which should numbers.

The Parameters defines the Left co-ordinate, Top co-ordinate, Right co-ordinate, Bottom co-ordinate, depth co-ordinate, and Top flag. The first four parameters define the co-ordinate of the front face, while the fifth parameter defines the depth or the width of the bar. To make it look bigger and more realistic, keep the depth relative to the width and length.

Making these 3d bars and shapes allow us to make very creative and complex shapes when working on games and puzzles. These shapes are used widely in the application which uses graphics.h library.

To make use of these function, one should always include the graphics.h library.

graphics.h - bar3d() function example in C



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

int main()
{
	//initilizing graphic driver and 
	//graphic mode variable
	int graphicdriver=DETECT,graphicmode;

	//calling initgraph
	initgraph(&graphicdriver,&graphicmode,"c:\\turboc3\\bgi");

	//Printing message for user
	outtextxy(10, 10 + 10, "Program to draw cubes of diffrent sizes in C graphics");

	//creating both the cubes using bar3d function.

	bar3d(200, 200, 300, 300, 50, 1);

	bar3d(100, 100, 200, 200, 25, 1);

	getch();
	return 0;
}

Output

graphics.h - bar3d() function program in C

ADVERTISEMENT




Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.