# include "data.h"

int center (int argc, char **argv) {
  
  double x, y;
  int zoom;
  char buffer[512], buffer2[20];
  int Ximage, Nimage, N;
  
  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 != 3) && (argc != 4)) {
    fprintf (stderr, "USAGE: center x y [zoom]\n");
    return (FALSE);
  }

  x = atof (argv[1]);
  y = atof (argv[2]);
  zoom = 0;
  if (argc == 4) {
    zoom = atof (argv[3]);
  }

  write (Ximage, "CENT", 4); /* tell Ximage to look for the incoming image */

  sprintf (buffer, "%8.3f %8.3f %8d ", x, y, zoom);
  sprintf (buffer2, "NBYTES %8d ", strlen (buffer));
  write (Ximage, buffer2, 16);
  write (Ximage, buffer, strlen (buffer));
  
  return (TRUE);

}
