[C] 设置当前画线颜色 →→→→→进入此内容的聊天室

来自 , 2021-02-25, 写在 C, 查看 153 次.
URL http://www.code666.cn/view/2d2ca7ee
  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. int main(void)
  7. {
  8.    /* select a driver and mode that supports */
  9.    /* multiple drawing colors.               */
  10.    int gdriver = EGA, gmode = EGAHI, errorcode;
  11.    int color, maxcolor, x, y;
  12.    char msg[80];
  13.  
  14.    /* initialize graphics and local variables */
  15.    initgraph(&gdriver, &gmode, "");
  16.  
  17.    /* read result of initialization */
  18.    errorcode = graphresult();
  19.    if (errorcode != grOk)  /* an error occurred */
  20.    {
  21.       printf("Graphics error: %s\n", grapherrormsg(errorcode));
  22.       printf("Press any key to halt:");
  23.       getch();
  24.       exit(1); /* terminate with an error code */
  25.    }
  26.  
  27.    /* maximum color index supported */
  28.    maxcolor = getmaxcolor();
  29.  
  30.    /* for centering text messages */
  31.    settextjustify(CENTER_TEXT, CENTER_TEXT);
  32.    x = getmaxx() / 2;
  33.    y = getmaxy() / 2;
  34.  
  35.    /* loop through the available colors */
  36.    for (color=1; color<=maxcolor; color++)
  37.    {
  38.       /* clear the screen */
  39.       cleardevice();
  40.  
  41.       /* select a new background color */
  42.       setcolor(color);
  43.  
  44.       /* output a messsage */
  45.       sprintf(msg, "Color: %d", color);
  46.       outtextxy(x, y, msg);
  47.       getch();
  48.    }
  49.  
  50.    /* clean up */
  51.    closegraph();
  52.    return 0;
  53. }
  54.  

回复 "设置当前画线颜色"

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

captcha