Skip to main content

Graphics


Computer graphics is one of the most powerful and interesting aspects of computers. There is a lot that we can do in graphics apart from drawing figures of various shapes. All video games, animation, multimedia predominantly works with computer graphics. To work with graphics, C has various library functions. Some of built in functions which are defined within header file graphics.h are illustrated in this chapter.
Let us see one example which demonstrates graphics initialization and some built in functions related to graphics.

#include<graphics.h>
void main()
{
int gDriver=DETECT,gMode;
int polyArray[]={200,100,250,150,300,200,350,200,300,150,200,100};
initgraph(&gDriver,&gMode,"c:\\tc\\bgi");
setcolor(GREEN);
line(200,100,300,250); /*line from (200,100) to (300,250) */
circle(300,300,50); /*circle at center (300,300) having radius 50 */
ellipse(150,200,0,360,100,50);           /* ellipse at center (150,200) and angle from 0 to              
                                                             360 and the xradius 100, yradius 50*/
arc(200,300,300,90,80);  /* arc having center at (200,300) and radius 80 from starting
                                           angle 300 to end angle 90 */
rectangle(50,100,350,400);  /* rectangle of diagonal points at (50,100) and (350,400)*/
drawpoly(6,polyArray); /* polygon of 6 corner points*/
getch();
closegraph();

}

Comments

Popular posts from this blog

What is Java Applets?

An applet is a special kind of Java program that is designed to be transmitted over the Internet and automatically executed by a Java-compatible web browser. Furthermore, an applet is downloaded on demand, without further interaction with the user. If the user clicks a link that contains an applet, the applet will be automatically downloaded and run in the browser. Applets are intended to be small programs. They are typically used to display data provided by the server, handle user input, or provide simple functions, such as a loan calculator, that execute locally, rather than on the server. In essence, the applet allows some functionality to be moved from the server to the client.

What is manipulator in C++?

Answer: Manipulators are special functions that can be included in the I/O statement to alter the format parameters of a stream. Table-2 shows some important manipulator functions that are frequently used. To access these manipulators, the file < iomanip.h > should be included in program.                               Table-2               Manipulators                                                    Equivalent ios function               set...

Network Topology

A network topology is the arrangement of the computers cable and other components on a network. The major goal of network topology is to find out the most economical and efficient way to connect all the users to the network resources while providing adequate capacity to handle users demand, maintain system reliability and decrease the delay.    Topology is the map of physical network. The type of topology we use defect the type and capabilities network hardware’s its management and possibilities for future expansion. There are many types of network topology, some of these are:   Bus Topology Star Topology Mesh Topology   Ring Topology Tree Topology