示例#1
0
文件: areas.c 项目: sdzharkov/ECS30
int main() {
    do_rect();
    do_square();
    do_tri();
    do_circle();
    do_trap();
    return 0;
}
示例#2
0
static FT_Error
Render_GammaGrid( grBitmap*  bitmap )
{
  int   g;
  int   xmargin = 10;
  int   gamma_first = 16;
  int   gamma_last  = 26;
  int   gammas      = gamma_last - gamma_first + 1;
  int   xside       = (bitmap->width-100)/gammas - xmargin;
  int   yside       = (bitmap->rows-100)/2;
  int   yrepeat     = 1;

  int   x_0     = (bitmap->width - gammas*(xside+xmargin)+xmargin)/2;
  int   y_0     = (bitmap->rows  - (8+yside*2*yrepeat))/2;
  int   pitch   = bitmap->pitch;


  if ( pitch < 0 )
    pitch = -pitch;

#if 1
  memset( bitmap->buffer, 255, pitch*bitmap->rows );
#else
 /* fill the background with a simple pattern corresponding to 50%
  * linear gray from a reasonable viewing distance
  */
  {
    int             nx, ny;
    unsigned char*  line = bitmap->buffer;
    if ( bitmap->pitch < 0 )
      line -= (bitmap->pitch*(bitmap->rows-1));

    for ( ny = 0; ny < bitmap->rows; ny++, line += bitmap->pitch )
    {
      unsigned char*  dst = line;
      int             nx;

      for ( nx = 0; nx < bitmap->width; nx++, dst += 3 )
      {
        int  color = ((nx+ny) & 1)*255;

        dst[0] = dst[1] = dst[2] = (unsigned char)color;
      }
    }
  }
#endif

  grGotobitmap( bitmap );

  for ( g = gamma_first; g <= gamma_last; g += 1 )
  {
    double gamma_value = g/10.0;
    char   temp[6];
    int    x = x_0 + (xside+xmargin)*(g-gamma_first);
    int    y = y_0;
    int    ny;

    grSetPixelMargin( x, y_0-8 );
    grGotoxy( 0, 0 );

    sprintf( temp, "%.1f", gamma_value );
    grWrite( temp );

    for ( ny = 0; ny < yrepeat; ny++, y += 2*yside )
    {
      do_rect( bitmap, x, y, xside, yside,
               (int)( 255.0 * pow( 0.5, 1.0 / gamma_value ) ) );
      do_rect( bitmap, x, y+yside, xside, yside, -1 );
    }
  }
  return 0;
}