setaspectratio用于设置当前缩放因子。
简介
函数名:setaspectratio
功能:
函数原型:void setaspectratio(
float xasp,
float yasp
);
参数:xasp:x方向上的缩放因子。例如绘制宽度为100的矩形,实际绘制宽度为100*xasp。
yasp:y方向上的缩放因子。例如绘制高度为100的矩形,实际绘制高度为100*yasp。
程序例
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int xasp, yasp, midx, midy;
/* initialize graphics and local variables */
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* get current aspect ratio settings */
getaspectratio(&xasp, &yasp);
/* draw normal circle */
circle(midx, midy, 100);
getch();
/* claer the screen */
cleardevice();
/* adjust the aspect for a wide circle */
setaspectratio(xasp/2, yasp);
circle(midx, midy, 100);
getch();
/* adjust the aspect for a narrow circle */
cleardevice();
setaspectratio(xasp, yasp/2);
circle(midx, midy, 100);
/* clean up */
getch();
closegraph();
return 0;
}