home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / runtime / fxprmnt.ri < prev    next >
Text File  |  1996-03-22  |  3KB  |  94 lines

  1. /*
  2.  * fxprmnt.ri -- experimental graphics functions -- not for outside release
  3.  */
  4.  
  5.  
  6.  
  7. /*
  8.  * XAnimateFrame --
  9.  * This function is not finished; it should be generalized to handle
  10.  *  multiple moving pixmaps and multiple styles of animation.  I have in
  11.  *  mind that it become the "printf" of frame animation.
  12.  */
  13.  
  14. "XAnimateFrame(args[]){1} - animate frame"
  15.  
  16. function {1} XAnimateFrame(argv[argc])
  17.  
  18.    abstract {
  19.       return file
  20.       }
  21.  
  22.    body {
  23.       wbp _w_;
  24.       int i, j, n = 0, x[MAXXOBJS], y[MAXXOBJS], closed = 0, npixmaps=0;
  25.       int argsbeforeints = 2, delay = 0;
  26.       int warg = 0;
  27.       char *s;
  28.  
  29.       OptWindow;
  30.  
  31.       /*
  32.        * 1 or more pixmaps must be included
  33.        */
  34.       while(warg < argc && is:file(argv[warg]) &&
  35.         (BlkLoc(argv[warg])->file.status & Fs_Window)) {
  36.          npixmaps++;
  37.      warg++;
  38.          }
  39.       if (!npixmaps) runerr(140);
  40.  
  41.       /*
  42.        * missing arguments are treated as &null, which isn't convertible
  43.        * to integer.
  44.        */
  45.       CheckArgMultiple(2);
  46.       if (n < 2) runerr(101);
  47.  
  48.       if (IntVal(argv[warg]) == IntVal(argv[argc-2]) &&
  49.              IntVal(argv[warg+1]) == IntVal(argv[argc-1])) {
  50.             closed = 1;               /* duplicate the next to last point */
  51.             x[0] = IntVal(argv[argc-4]);
  52.             y[0] = IntVal(argv[argc-3]);
  53.         x[0] += _w_->dx;
  54.         y[0] += _w_->dy;
  55.             }
  56.          else if (argc > 1) {        /* duplicate the first point */
  57.             x[0] = IntVal(argv[warg]);
  58.             y[0] = IntVal(argv[warg+1]);
  59.         x[0] += _w_->dx;
  60.         y[0] += _w_->dy;
  61.             }
  62.          for (i = 0, j = 1; i < n; i++, j++) {
  63.         int base = warg + i * 2;
  64.        
  65.             if (j == MAXXOBJS) {
  66.                animate(_w_, &(argv[warg-npixmaps]), npixmaps,
  67.                x, y, MAXXOBJS, delay);
  68.                x[0] = x[j-3];
  69.                y[0] = y[j-3];         /* duplicate the last three points */
  70.                x[1] = x[j-2];         /*  for the next call, to insure   */
  71.                y[1] = y[j-2];         /*  continuity                     */
  72.                x[2] = x[j-1];
  73.                y[2] = y[j-1];
  74.                j = 3;
  75.                }
  76.             CnvCInteger(argv[base], x[j]);
  77.             CnvCInteger(argv[base + 1], y[j]);
  78.         x[j] += _w_->dx;
  79.         y[j] += _w_->dy;
  80.             }
  81.          if (closed) {                /* duplicate the second point */
  82.             x[j] = x[2];
  83.             y[j] = y[2];
  84.             }
  85.          else {                       /* duplicate the last point */
  86.             x[j] = x[j-1];
  87.             y[j] = y[j-1];
  88.             }
  89.          animate(_w_, &(argv[warg-npixmaps]), npixmaps, x, y, j+1, delay);
  90.  
  91.       ReturnWindow;
  92.       }
  93. end
  94.