Why detect is used in computer graphics




















Here is our first C Graphics program to draw a straight line on screen. In this program initgraph function auto detects an appropriate graphics driver and sets graphics mode maximum possible screen resolution. Then line function draws a straight line from coordinate , to , Then we added a call to getch function to avoid instant termination of program as it waits for user to press any key.

At last, we unloads the graphics drivers and sets the screen back to text mode by calling closegraph function. If directory path is not provided, then it will search for driver files in current working directory directory. At the end of our graphics program, we have to unloads the graphics drivers and sets the screen back to text mode by calling closegraph function. There are 16 colors declared in graphics. We use colors to set the current drawing color, change the color of background, change the color of text, to color a closed shape etc Foreground and Background Color.

To specify a color, we can either use color constants like setcolor RED , or their corresponding integer codes like setcolor 4. Below is the color code in increasing order. Defined in conio. Graphics graphics. By Vineet Choudhary.

Explanation of Code : The first step in any graphics program is to include graphics. The Graphics Card is responsible for rendering an image to your monitor, and it does this by converting data into a signal your monitor can understand. The better your graphics card the better and smoother an image can be produced. This is naturally very important for gamers and video editors. To initialize graphics mode we use initgraph function in our program. To begin with we have declared two variables of int type gd and gm for graphics driver and graphics mode respectively, you can choose any other variable name as well.

Initgraph function automatically decides an appropriate graphics driver and mode such that maximum screen resolution is set, getch helps us to wait until a key is pressed, closegraph function closes the graphics mode, and finally return statement returns a value 0 to main indicating successful execution of the program.

After you have understood initgraph function then you can use functions to draw shapes such as circle, line , rectangle, etc.



0コメント

  • 1000 / 1000