#include "c4.h"
#include <string.h>

int main(int argc,
         char *argv[])
{
  int i;
  int w=222,h=222;
  unsigned char r=200,g=50,b=200;
  char *my_name;
  struct Image *img;

  my_name = argv[0];

  for(i=1;i<argc;i++) {
    if(!strcmp(argv[i],"-h") ||
       !strcmp(argv[i],"--help")) {
      printf(

"usage:\n"
"  %s [ options ]\n"
"options:\n"
"  -h || --help               this help message\n"
"  -d || --dim <w> <h>        sets image width and height\n"
"                              to w and h\n"
"  -c || --color <r> <g> <b>  sets the image background\n"
"                              color\n",

             my_name);
      exit(0);
    }
    else if(!strcmp(argv[i],"-d") ||
            !strcmp(argv[i],"--dim")) {
      w = atoi(argv[++i]);
      h = atoi(argv[++i]);
    }
    else if(!strcmp(argv[i],"-c") ||
            !strcmp(argv[i],"--color")) {
      r = atoi(argv[++i]);
      g = atoi(argv[++i]);
      b = atoi(argv[++i]);
    }
    else
      fprintf(stderr,
              "%s: unknown option '%s'; use -h for help\n",
              my_name,
              argv[i]);
  }

  img = c4_image_create(w,h);

  c4_image_set(img,r,g,b);

  c4_image_destroy(img);

  return(0);
}
