c语言标准图形库,C语言图形库函数.docx
1?初始化圖形系統
函數名:ini tgraph
功能:初始化圖形系統
用 法:void far initgraph(int far *graphdriver, int far *grciphmode, char far *pathtodriver);
程序例:
^include
★include
^include #includo int main(void)
{
/* request auto detection */
int gdriver = DETEC1\ gmode, errorcode;
/* initialize graphics mode */
initgraph(&gdriver, &gmode,"“);
/* read result of initialization */
errorcode 二 graphresult():
if (errorcode != grOk) /* an error occurred */
(
prin tf (''Graphics error: %s\n: grapherrormsg (errorcode)):
printf("Press any key to halt:"):
getch ();
exi t(1);/* return wi th error code */
/* draw a line */
line(0, 0, gctmaxx0, gctmaxy());
/* clean up */
getch ();
closegraph ();
return 0;
2.
函數名:
drawpoly
功能:
畫多邊形
用法:
void far drawpoly(int numpoints, int far *polypoints);
程序例:
#include〈graphics? h>
★include
^include
#include irH main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode; int maxx, mcixy;
/* our polygon array */
int polyL1OJ;
/* initialhe graphics and local variables */
initgraph(&gdriver, &gmode,;
/* read result of initialization */ errorcode = graphresult();
if (errorcode != grOk)
/* an error occurred */
{
printf(^Graphics error: %s\n", \ grapherrormsg(orrorcode));
prin訂("Press any key to halt/); getch ();
/? terminate with an error code */ exi t (1);
}
meixx = getmeixx ();
mcixy = getmcixy 0 ;
poly[0] = 20;/* 1st vertext */
poly[1] = maxy / 2;
poly[2] = maxx - 20; /* 2nd */ poly[3] = 20;
poly [4] = maxx - 50; /* 3rd */ poly [5] = maxy - 20;
poly[6] = maxx / 2;/* 4th */
poly[7] = maxy / 2;
/*
drawpoly doesn't automatically close the polygon, so we close il?
poly [8] = poly[0]: poly[9] = poly[l]:
/* draw the polygon */ drawpoly(5, poly);
/* clean up */ getchO ; elosegraph ();
return 0;
}
函數名:
ellipse
功能:
畫一橢圓
用法:
void far ellipse(int x, int y, int stangle, int endangle,
int
程序例:
xradius, int yradius);
#include #include #includo ^inc
總結
以上是生活随笔為你收集整理的c语言标准图形库,C语言图形库函数.docx的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux实验五编程淮海工学院,实验一-
- 下一篇: 可逆素数编程c语言,巧用C语言求四位的可