# include "data.h"

int erase (int argc, char **argv) {
  
  int i, N;
  int Ximage, Nimage;
  
  Nimage = -1;
  if ((N = get_argument (argc, argv, "-n"))) {
    remove_argument (N, &argc, argv);
    Nimage = atof (argv[N]);
    remove_argument (N, &argc, argv);
  }
  if (!GetImage (&Ximage, &Nimage)) return (FALSE);

  if (argc < 2) {
    gprint (GP_ERR, "USAGE: erase (overlay) [overlay, overlay, ..] \n");
    gprint (GP_ERR, " (overlay) may be: red (0), green (1), blue (2), yellow (3) or all\n");
    return (FALSE);
  }

  for (i = 1; i < argc; i++) {
    if (!(strcasecmp (argv[i], "all"))) {
      KiiEraseOverlay (Ximage, "red");
      KiiEraseOverlay (Ximage, "green");
      KiiEraseOverlay (Ximage, "blue");
      KiiEraseOverlay (Ximage, "yellow");
      continue;
    }
    if (!KiiSelectOverlay (argv[i], &N)) {
      gprint (GP_ERR, "%s is not a valid overlay\n", argv[i]);
      return (FALSE);
    }
    KiiEraseOverlay (Ximage, argv[i]);
  }
  return (TRUE);
}
