getaspectratio

getaspectratio的功能是返回當前圖形模式的縱橫比。

基本介紹

  • 外文名: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\n",
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;
}

相關詞條

熱門詞條

聯絡我們