예제 #1
0
파일: gnugraph.c 프로젝트: kashif/evolver
void init_gnugraph()
{ int k;
  int c;    /* color, 0-15 */
  int g;    /* gray level, 0-15 */

  GrSetMode(GR_default_graphics);
  numcolors = GrNumColors();
  if ( (numcolors < 256) && color_flag )
      shading_flag = 0;  /* not enough for shading */
  
  /* first index background color */
  for ( c = 0 ; c < 16 ; c++ ) color_perm[c] = c;
  color_perm[background_color] = 0;
  color_perm[0] = background_color;
  
  if ( shading_flag && color_flag )
  { for ( c = 0 ; c < 16 ; c++ )
      for ( g = 0 ; g <= MAXGRAY ; g++ )
        GrSetColor(CINDEX(c,g),
         (int)(0xff*(g+12.)/(MAXGRAY+12.)*rgb_colors[c][0]), 
         (int)(0xff*(g+12.)/(MAXGRAY+12.)*rgb_colors[c][1]),
         (int)(0xff*(g+12.)/(MAXGRAY+12.)*rgb_colors[c][2]));
    }
    else if ( shading_flag ) /* shading */
    { for ( g = 0 ; g <= MAXGRAY ; g++ )
        GrSetColor(CINDEX(WHITE,g),
         (int)(0xff*(g+12.)/(MAXGRAY+12.)), 
         (int)(0xff*(g+12.)/(MAXGRAY+12.)),
         (int)(0xff*(g+12.)/(MAXGRAY+12.)));
    }
    else if ( color_flag )
    { for ( c = 0 ; c < 16 ; c++ )
        GrSetColor(CINDEX(c,MAXGRAY),
         (int)(0xff*rgb_colors[c][0]), 
         (int)(0xff*rgb_colors[c][1]),
         (int)(0xff*rgb_colors[c][2]));
    }

  if ( numcolors == 32768 )
     GrClearScreen(CINDEX(WHITE,MAXGRAY));
  else
  {  GrFreeColor(0);
      GrSetColor(0,(int)(0xff*rgb_colors[background_color][0]),
        (int)(0xff*rgb_colors[background_color][1]),
        (int)(0xff*rgb_colors[background_color][2]));
  }

  maxx = GrMaxX(); maxy = GrMaxY();
  if ( maxx/3 < maxy/3 )
    { xscale = maxx/3;
      yscale = xscale; /* assume square pixel screen */
    }
  else
    { yscale = maxy/3;
      xscale = yscale; /* assume square pixel screen */
    }
}
예제 #2
0
static void PrintInfo(void)
{
    char aux[81];
    int x, y;

    sprintf(aux, " Mode: %dx%d %d bpp ", GrCurrentVideoMode()->width,
    GrCurrentVideoMode()->height, GrCurrentVideoMode()->bpp);
    x = (GrMaxX() -
        GrFontStringWidth(&GrDefaultFont, aux, strlen(aux), GR_BYTE_TEXT)) / 2;
    y = (GrMaxY() -
        GrFontStringHeight(&GrDefaultFont, aux, strlen(aux), GR_BYTE_TEXT)) / 2;
    GrTextXY(x, y, aux, GrWhite(), GrBlack());
}