0% found this document useful (0 votes)
37 views

Graphics Functions

The document describes various graphics functions in C++ that allow manipulating graphical elements like pixels, lines, rectangles, circles, ellipses, text and colors. Some key functions are putpixel() to draw pixels, setcolor() to set the drawing color, rectangle() to draw rectangles, circle() to draw circles, line() to draw lines, outtextxy() to print text at coordinates, and floodfill() to fill areas with color. These functions provide basic tools for creating graphics and visual output using C++.

Uploaded by

rkpaul89
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Graphics Functions

The document describes various graphics functions in C++ that allow manipulating graphical elements like pixels, lines, rectangles, circles, ellipses, text and colors. Some key functions are putpixel() to draw pixels, setcolor() to set the drawing color, rectangle() to draw rectangles, circle() to draw circles, line() to draw lines, outtextxy() to print text at coordinates, and floodfill() to fill areas with color. These functions provide basic tools for creating graphics and visual output using C++.

Uploaded by

rkpaul89
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

GRAPHICS FUNCTIONS

1. Putpixel Purpose:- Putpixel function is to draw the pixel on the screen. Pixel is small dot on the screen. Syntax:- putpixel(x co-orinate, y co-ordinate,COLOR); Example: - putpixel(100,100,BLUE);

2. SetbkColor Purpose:- Setbkcolor function is used to set background color of the screen. Syntax:- setbkcolor(COLOR); Example:- stebkcolor(RED);

3. Setlinestyle Purpose:- setlinestyle function is used to set the current line style, width and pattern Syntax:- setlinestyle(linestyle, pattern, thickness); Example:- setlinestyle(SOLID_LINE,1,2);

4. Setcolor Purpose:- setcolor is to set color of the objects which is to be drawn after this setcolor line. Syntax:- setcolor(COLOR); Example:- setcolor(RED);

5. Rectange:-

Purpose:- Rectangle function is used to draw the rectangle on the screen. X1,y1 are the lower left co-ordinates of the rectangle and the x2,y2 are the upper right co-ordinates of the rectangle. Syntax:- rectangle(x1,,y1,x2,y2); Example:- rectangle(100,100,200,200);

6. Textheight Purpose:- textheight returns the height of a string in pixels. Syntax:- textheight(STRING); Example:- i=textheight(HELLO);

7. Textwidth Purpose:- textwidth returns the width of a string in pixels Syntax:- textwidth(STRING); Example:- i=textwidth(HELLO);

8. Getx Purpose:- getx returns the current positions of x o-ordinate Syntax:-getx(); Example:- x=getx();

9. Gety Purpose:- gety returns the current positions of y co-ordinate Syntax:- gety();

Example:- y=gety();

10.

Getmaxx

Purpose:-getmaxxreturns the maximum x co-ordinate on the screen Syntax:-getmaxx(); Example:- maxx=getmaxx();

11.

Getmaxy

Purpose:- getmaxy returns the maximum y co-ordinate on the screen Syntax:- getmaxy(); Example:- maxy=getmaxy();

12.

Line

Purpose:- Line function is used to draw the line on the screen. Syntax: line(x1,y1,x2,y2); Example:- line(100,100,200,100);

13. Closegraph

Purpose:- closegraph function shut down the graphic system Syntax:- closegraph(); Example:- closegraph();

14.

Moveto

Purpose:- moveto function moves current cursor position on the screen Syntax:- moveto(x co-ordinate, y co-ordinate); Example:- moveto(getmaxx/2, getmaxy/2);

15.

Settextstyle

Purpose:- settextstyle sets the current text characteristics like font, direction and size Syntax:- settextstyle(font, direction size); Example:- settextstyle(1,1,10); Font 1 2 3 4 5 DEFAULT TRIPLEX SMALL SANS SERIF GOTHIC HORIZ_DIR VERT_DIR SMALL large

Direction 0 1 Size 0 10

16.

Circle

Purpose: Circle function is used to draw the circle on the screen Syntax:- circle(x,y,radius); Example: circle(100,100,50);

17.

Cleardevice

Purpose: cleardevice function is used to clear the contents or graphic images on the screen in graphics mode. Syntax: cleardevice(); Example: cleardevice();

18.

Outtextxy

Purpose: outtextxy function is used to print the text on the screen in graphics mode. Syntax: outtext(x,y,text); Example:- outtextxy(100,100,HELLO);

19. Sector

Purpose: sector function draws and fills an elliptical pie slice. Syntax: sector(x, y, starting angle, ending angle, xradius, yradius); Example: sector(100,100,45 135 100 50);

20. Arc

Purpose: arc draws the arc on the screen, arc is a part of the circle Syntax: arc(x, y, starting angle, ending angle, radius); Example: arc( 100,100,90,180,50);

21.

Setfillstyle

Purpose: setfillstyle is used to set the color and style to be filled in the object using the flood fill method.

Syntax: stefillstyle(STYLE, COLOR); Example: setfillstyle(1,RED)

22. Floodfill

Purpose: floodfill function is used to fill the color in the object, object may be circle, rectangle or any other closed image. Syntax: floodfill(x,y,boundary color); Example: floodfill(100,100,BLUE);

23. Ellipse

Purpose: ellipse function is used to draw the ellipse on the screen. Syntax: ellipse(x, y, starting angle, ending angle, xradius, yradius); Example: ellipse(100,100,90,200,20,20);

24. Outtext

Purpose: outtext function is used to display the text on the screen, using this function text is display in the current position. Syntax: outtext(STRING); Example: outtex(HELLO);

25. Getcolor

Purpose: getcolor returns the current drawing color. Syntax: getcolor(); Example: int clr = getcolor();

26. Getpixel

Purpose: getpixel gets the color of a specified pixel. Syntax: getpixel(x,y); Example: color = getpixel(100,100);

You might also like