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...

What is Servlet in Java?

A servlet is a small program that executes on a server. Just as applets dynamically extend the functionality of a web browser, servlets dynamically extend the functionality of a web server. It is helpful to understand that as useful as applets can be, they are just one half of the client/server equation. Not long after the initial release of Java, it became obvious that Java would also be useful on the server side. The result was the servlet. Thus, with the advent of the servlet, Java spanned both sides of the client/server connection.