[C] 返回当前图形模式的纵横比 getaspectratio →→→→→进入此内容的聊天室

来自 , 2021-01-20, 写在 C, 查看 141 次.
URL http://www.code666.cn/view/e0f7a4d0
  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. int main(void)
  7. {
  8. /* request auto detection */
  9.    int gdriver = DETECT, gmode, errorcode;
  10.    int xasp, yasp, midx, midy;
  11.  
  12. /* initialize graphics and local variables */
  13.    initgraph(&gdriver, &gmode, "");
  14.  
  15. /* read result of initialization */
  16.    errorcode = graphresult();
  17. /* an error occurred */
  18.    if (errorcode != grOk)
  19.    {
  20.       printf("Graphics error: %s\n",
  21.              grapherrormsg(errorcode));
  22.       printf("Press any key to halt:");
  23.       getch();
  24. /* terminate with an error code */
  25.       exit(1);
  26.    }
  27.  
  28.    midx = getmaxx() / 2;
  29.    midy = getmaxy() / 2;
  30.    setcolor(getmaxcolor());
  31.  
  32. /* get current aspect ratio settings */
  33.    getaspectratio(&xasp, &yasp);
  34.  
  35. /* draw normal circle */
  36.    circle(midx, midy, 100);
  37.    getch();
  38.  
  39. /* draw wide circle */
  40.    cleardevice();
  41.    setaspectratio(xasp/2, yasp);
  42.    circle(midx, midy, 100);
  43.    getch();
  44.  
  45. /* draw narrow circle */
  46.    cleardevice();
  47.    setaspectratio(xasp, yasp/2);
  48.    circle(midx, midy, 100);
  49.  
  50. /* clean up */
  51.    getch();
  52.    closegraph();
  53.    return 0;
  54. }

回复 "返回当前图形模式的纵横比 getaspectratio"

这儿你可以回复上面这条便签

captcha