示例#1
0
/* Compute the revolutions per minute of a gear.
 */
static void
compute_rpm (ModeInfo *mi, gear *g)
{
  double fps, rpf, rps;
  fps = (MI_PAUSE(mi) == 0 ? 999999 : 1000000.0 / MI_PAUSE(mi));

  if (fps > 150) fps = 150;  /* let's be reasonable... */
  if (fps < 10)  fps = 10;

  rpf    = (g->ratio * spin_speed) / 360.0;   /* rotations per frame */
  rps    = rpf * fps;                         /* rotations per second */
  g->rpm = rps * 60;
}
示例#2
0
ENTRYPOINT void
draw_triangle (ModeInfo * mi)
{
    trianglestruct *tp = &triangles[MI_SCREEN(mi)];
    int         d, d2, i, j, delta;

    if (!tp->init_now) {
        draw_mesh(mi, tp, tp->d / 2, MAX_SIZE / tp->d);

        /* The init_now flag will pop up when the scene is complete.
         * Cycles specifies how long to wait, in 1/10 secs.
         TODO: This is wrong for multi-screens ***
         */
        if (tp->init_now) {
#ifndef STANDALONE
            MI_PAUSE(mi) = 2000000;
#else
            if (tp->stage == -1)
            {
                XClearWindow(MI_DISPLAY(mi), MI_WINDOW(mi));
                if (!mono_p)
                {
                    free_colors(mi->xgwa.screen, mi->xgwa.colormap, mi->colors,
                                mi->npixels);
                    mi->npixels =
                        get_integer_resource (mi->dpy, "ncolors", "Integer");
                    make_smooth_colormap (mi->xgwa.screen,
                                          mi->xgwa.visual, mi->xgwa.colormap,
                                          mi->colors, &mi->npixels,
                                          True, &mi->writable_p, True);
                }
            }
#endif
        }
        return;
    }
    if (tp->delta[0] > 0) {
        if (!(++tp->stage)) {
            tp->h[0][0] = (short int) MAX(0, DISPLACE(0, tp->delta[0]));
            tp->h[tp->size][0] = (short int) MAX(0, DISPLACE(0, tp->delta[0]));
            tp->h[0][tp->size] = (short int) MAX(0, DISPLACE(0, tp->delta[0]));
        } else {
            d = 2 << (tp->steps - tp->stage);
            d2 = d / 2;
            delta = tp->delta[tp->stage - 1];

            for (i = 0; i < tp->size; i += d) {
                for (j = 0; j < (tp->size - i); j += d) {
                    tp->h[i + d2][j] = (short int) DISPLACE(tp->h[i][j] +
                                                            tp->h[i + d][j], delta);
                    tp->h[i][j + d2] = (short int) DISPLACE(tp->h[i][j] +
                                                            tp->h[i][j + d], delta);
                    tp->h[i + d2][j + d2] = (short int) DISPLACE(tp->h[i + d][j] +
                                            tp->h[i][j + d], delta);
                }

                tp->init_now = 0;
                tp->i = 0;
                tp->j = 0;
                tp->d = d;
            }
        }
    }
    if (tp->stage == tp->steps) {
        tp->stage = -1;
    }
}