#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "GrWin.h"

/* 入力した指示によって処理を変える */

int main()
{
  float x, y, size;
  int xx, yy, c, type;

  printf("drawing type (1-4) and size = ");
  scanf("%d %f", &type, &size);

  GWopen(0);
  GWindow(0.0, 0.0, 200.0, 200.0);

  c=0; /* 最初の色 (0:黒) */
  y=20.0; /* 最初の下端の位置 */
  for(yy=1; yy<=8; yy++) {
    x=10.0; /* 左端の位置 */
    for(xx=1; xx<=8; xx++) { 
      switch( type ) {
      case 1:
        /* 塗りつぶした四角形 */
        GWsrect(x, y, x+size, y+size, c);
        break;
      case 2:
        /* 塗りつぶした円 */
        GWscircle(x, y, x+size, y+size, c);
        break;
      case 3:
        /* 扇形 */
        GWxpie(x, y, x+size, y+size, 0.3, 0.7, c);
        break;
      case 4:
        /* 角の丸い四角 */
        GWsetpen(c,-1,-1,4); /* ペンの色を設定 */
        GWsetbrs(c,1,-1); /* 塗りつぶし色も指定 */
        GWrrect(x, y, x+size, y+size, size/3.0, size/3.0);
        break;
      default:
        printf(" 1 か 2 で指定してください\n");
        GWquitx(0);
        return 0;
      };
      x=x+20.0;
      c++;
      if( c == 19 ) {
        c=0; /* 白(19)は使わず黒(0)に戻す */
      };
    };
    y=y+20.0;
  };

  return 0;
}

