C language commonly used functions graphical interface Collection

(In the following function should be used after the initial graphics mode (initgraph (a, b)), when using the graphics program template BGI win-tc in which there is defined a initgr function, after the function to be executed in the main function initgr and then use these functions. using these functions should be included in the program header file graphics.h, that is, when the program began have #include "graphics.h")

. 1, setColor (color value) : Set the drawing color, the use of this function, the function pattern drawn line or curve function for the specified color. E.g:

    setcolor(YELLOW);

    circle(320,240,100);

In the center of the screen drawn in yellow circle with a radius of 100.

2, SetBkColor (color value) : setting the background color graphic screen, screen pattern used after the clear screen function, that function as the background color specified color. If you do not use this function to set the background color, the background color graphic screen is black.

3, cleardevice () : clear the content on the graphics screen has been drawn, the function has no parameters.

. 4, Line (X1, Y1, X2, Y2) : draw a line segment, where (x1, y1) is a coordinate endpoint, (x2, y2) is the coordinates of the other endpoint. Color line is in use prior to this function by function setcolor color set. E.g:

    setcolor(WHITE);

    line (0,240,639,240); draw an intermediate white horizontal line running through the screen.

. 5, Circle (X, Y, r) : to draw a (x, y) coordinates as the center, a circle with a radius r. E.g:

    setcolor(WHITE);

    circle (320,240,100); in a draw (320, 240) as the center position, the radius of the circle 100.

. 6, Rectangle (X1, Y1, X2, Y2) : to draw a (x1, y1) and (x2, y2) for the angular coordinates of endpoints of a rectangle

. 7, putpixel (X, Y, Color) : draw a point (x, y) at a coordinate position specified by the color point color. E.g:

   putpixel (320,240, RED); at the center of the screen to draw a red dot.

8, getbkcolor () : Get current background color graphic screen, the color values are determined using setbkcolor function settings. E.g:

    setcolor (getbkcolor ()); the current drawing color is set to the background color.

    After this statement is executed, in the same drawing original position of the graphic, the graphic will be erased. E.g:

    setcolor(RED);

    circle(320,240,100);

    delay(10000);

    setcolor(getbkcolor());

    circle(320,240,100);

    The code first draw a red circle, 10,000 units after the delay interval (i.e. after the holding period of the pattern), and then erased.

9, closegraph () : Close the graphic work, return to the character work. After calling this function, the screen has drawn graphics will be cleared.

10, Ellipse (X, Y, startAngle, endAngle, xradius, yRadius) : draw an ellipse. The center of the ellipse (x, y), startangle as the start angle, endangle terminate angle, xradius elliptical cross-radius, yradius elliptical vertical radius. Note: This function uses a value point of view, rather than radians. E.g:

     ellipse(320,240,0,360,200,100);
 

. 11, a SECTOR (X, Y, startAngle, endAngle, xradius, yRadius) : draw a sector. Sector center position (x, y), startangle as the start angle, endangle terminate angle, xradius fan-shaped cross-radius, yradius vertical radius of a fan. Note: This function uses a value point of view, rather than radians. E.g:

     sector(320,240,0,60,200,100);

Guess you like

Origin www.cnblogs.com/huke123/p/9086799.html