词条 | getaspectratio |
释义 | § 词条解释 函数名: getaspectratio 功 能: 返回当前图形模式的纵横比 用 法: void far getaspectratio (int far *xasp, int far *yasp); § 程序例 #include <graphics .h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xasp, yasp, midx, midy; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); /* terminate with an error code */ exit(1); } midx = getmaxx() / 2; midy = getmaxy() / 2; setcolor(getmaxcolor()); /* get current aspect ratio settings */ getaspectratio(&xasp, &yasp); /* draw normal circle */ circle(midx, midy, 100); getch(); /* draw wide circle */ cleardevice(); setaspectratio(xasp/2, yasp); circle(midx, midy, 100); getch(); /* draw narrow circle */ cleardevice(); setaspectratio(xasp, yasp/2); circle(midx, midy, 100); /* clean up */ getch(); closegraph(); return 0; } |
随便看 |
百科全书收录594082条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。