[go: up one dir, main page]

0% found this document useful (0 votes)
76 views11 pages

Graphics1 PDF

This document provides code snippets and explanations for 20 graphics functions from the header file Graphics.h in alphabetical order. For each function, it lists the syntax, provides a short program demonstrating its use, and displays the output. The functions covered include arc, bar, bar3d, circle, cleardevice, clearviewport, closegraph, detectgraph, drawpoly, ellipse, fillellipse, fillpoly, floodfill, getarccoords, getaspectratio, getbkcolor, getcolor, getdefaultpalette, getdrivername, and getfillpattern.

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views11 pages

Graphics1 PDF

This document provides code snippets and explanations for 20 graphics functions from the header file Graphics.h in alphabetical order. For each function, it lists the syntax, provides a short program demonstrating its use, and displays the output. The functions covered include arc, bar, bar3d, circle, cleardevice, clearviewport, closegraph, detectgraph, drawpoly, ellipse, fillellipse, fillpoly, floodfill, getarccoords, getaspectratio, getbkcolor, getcolor, getdefaultpalette, getdrivername, and getfillpattern.

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

COMPUTER GRAPHICS AND MULTEMEDIA

(DCO-511)

Program 1: Write first 20 graphics function from header file Graphics.h in alphabetical
order

Submitted by:

Mohd Aadil Rana

Roll. No. 16-DCS-031

Diploma in Computer Engineering- V Semester

Computer Engineering Section


University Polytechnic, Faculty of Engineering and Technology
Jamia Millia Islamia (A Central University)
New Delhi-110025
Session 2017-2018
Functions
1. Arc
Syntax: arc(int x, int y, int stratingangle, int endangle, int radius);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
arc(150,150,30,270,100);
getch();
}
//Output

2. Bar
Syntax: bar(int left, int top, int right, int bottom,);

Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
bar(200,300,20,60);
getch();
}
//Output
3. Bar3d
Syntax: bar3d(int left, int top, int right, int bottom, int depth, int topf lag);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
bar3d(200,300,30,40,40,50);
getch();
}
//Output

4. Circle
Syntax: circle(int x, int y, int y);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
circle(200,200,80);
getch();
}
//Output

5. Cleardevice
Syntax: cleardevice(void);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
fillellipse(100,100,50,60);
outtext("Presss any to Key to clear screen");
getch();
cleardevice();
getch();
}
/OUTPUT
After clicking

6. Clearviewport
Syntax: clearviewport(void);
Program
7. Closegraph
Syntax: closegraph(void);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
outtext("Presss any to Key to close the graphics mode");
getch();
closegraph();
getch();
}
//Output
8. Detectgraph
Syntax: detectgraph(int *graphdriver, int graphmode);
Program
9. Drawpoly
Syntax: drawpoly(int numpoints, int far *polypoints);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int a[]={300,100,400,200,250,350,300,100};
initgraph(&gd,&gm,"");
drawpoly(4,a);
getch();
closegraph();
getch();
}
//Output

10. Ellipse
Syntax: ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
ellipse(300,300,10,320,60,80);
getch();
}
//Output

11. Fillellipse
Syntax: fillellipse(int x, int y, int xradius, int yradius);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
fillellipse(300,300,40,60);
getch();
}
//Output

12. Fillpoly
Syntax: fillpoly(int numpoints, int *polypoints);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int a[]={170,300,450,300,450,400,500,250,170,300};
initgraph(&gd,&gm,"");
fillpoly(5,a);
getch();
closegraph();
getch();
}
//Output

13. Floodfill
Syntax: floodfill(int x, int y, int border);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
int x_radius=200,y_radius=200;
initgraph(&gd,&gm,"");
setfillstyle(LINE_FILL,CYAN);
circle(x_radius,y_radius,90);
floodfill(x_radius,y_radius,WHITE);
getch();
closegraph();
getch();
}
//Output
14. Getarccoords
Syntax: getarccoords(struct arccoordstype far *arccoords);
Program
#include <graphics.h>
#include <stdio.h>
#include<conio.h>
void main()
{
int gd = DETECT, gm;
struct arccoordstype p;
char arr[100];
initgraph(&gd, &gm, "");
arc(250,200,0,90,100);
getarccoords(&p);
sprintf(arr, "(%d, %d)", p.xstart,
p.ystart);
outtextxy(360, 195, arr);

sprintf(arr, "(%d, %d)", p.xend,


p.yend);

outtextxy(245, 85, arr);

getch();
closegraph();

getch();
}
//Output
15. Getaspectratio
Syntax: getaspectratio(int far *xasp, int far *yasp);
Program
16. Getbkcolor
Syntax: getbkcolor(void);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm;
char arr[100];
initgraph(&gd,&gm,"");
setbkcolor(CYAN);
sprintf(arr,"Current background Color is=%d",getbkcolor());
outtextxy(40,40,arr);
getch();
closegraph();
getch();
}
//Output

17. Getcolor
Syntax: getcolor(void);
Program
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,drawcolor;
char arr[100];
initgraph(&gd,&gm,"");
setcolor(RED);
drawcolor=getcolor();
sprintf(arr,"current color=%d",drawcolor);
outtextxy(10,10,arr);
getch();
closegraph();
getch();
}
//Output

18. Getdefaultpalette
Syntax: getpalette(struct palettetype far *palette);
Program
19. Getdrivername
Syntax: getdrivername(void);
Program
20. Getfillpattern
Syntax: getfillpattern(char far *pattern);
Program

You might also like