- lisacons *lc = &Lisa[MI_SCREEN(mi)];
- lisafuncs **lf = loop->function;
- XPoint *lp;
- int phase, pctr, fctr, xctr, yctr;
- double xprod, yprod, xsum, ysum;
-
- if (MI_NPIXELS(mi) > 2) {
- loop->color = 0;
- } else
- loop->color = MI_WHITE_PIXEL(mi);
- loop->nsteps = MI_CYCLES(mi);
- if (loop->nsteps == 0)
- loop->nsteps = 1;
- lc->maxcycles = (MAXCYCLES * loop->nsteps) - 1;
- loop->melting = 0;
- loop->nfuncs = 1;
- loop->pistep = 2.0 * M_PI / (double) loop->nsteps;
- loop->center.x = lc->width / 2;
- loop->center.y = lc->height / 2;
- loop->radius = (int) MI_SIZE(mi);
- checkRadius(loop, lc);
- loop->dx = NRAND(XVMAX);
- loop->dy = NRAND(YVMAX);
- loop->dx++;
- loop->dy++;
- lf[0] = &Function[lc->loopcount % NUMSTDFUNCS];
- if ((lp = loop->lastpoint = (XPoint *)
- calloc(loop->nsteps, sizeof (XPoint))) == NULL) {
- free_lisa(lc);
- return False;
+ lisacons *lc = &Lisa[MI_SCREEN(mi)];
+ lisafuncs **lf = loop->function;
+ XPoint *lp;
+ int phase, pctr, fctr, xctr, yctr, extra_points;
+ double xprod, yprod, xsum, ysum;
+
+ xMaxLines = (XMaxRequestSize(MI_DISPLAY(mi))-3)/2;
+ /* printf("Got xMaxLines = %d\n", xMaxLines); */
+ loop->nsteps = MI_CYCLES(mi);
+ if (loop->nsteps == 0)
+ loop->nsteps = 1;
+ if (MI_NPIXELS(mi) > 2) {
+ loop->color = STARTCOLOR;
+ loop->cstep = (loop->nsteps > MI_NPIXELS(mi)) ? loop->nsteps / MI_NPIXELS(mi) : 1;
+ } else {
+ loop->color = MI_WHITE_PIXEL(mi);
+ loop->cstep = 0;
+ }
+ extra_points = loop->cstep - (loop->nsteps % loop->cstep);
+ lc->maxcycles = (MAXCYCLES * loop->nsteps) - 1;
+ loop->cstep = ( loop->nsteps > MI_NPIXELS(mi) ) ? loop->nsteps / MI_NPIXELS(mi) : 1;
+ /* printf("Got cstep = %d\n", loop->cstep); */
+ loop->melting = 0;
+ loop->nfuncs = 1;
+ loop->pistep = 2.0 * M_PI / (double) loop->nsteps;
+ loop->center.x = lc->width / 2;
+ loop->center.y = lc->height / 2;
+ loop->radius = (int) MI_SIZE(mi);
+ CHECK_RADIUS(loop, lc);
+ loop->dx = NRAND(XVMAX);
+ loop->dy = NRAND(YVMAX);
+ loop->dx++;
+ loop->dy++;
+#if defined STARTFUNC
+ lf[0] = &Function[STARTFUNC];
+#else /* STARTFUNC */
+ lf[0] = &Function[NRAND(NUMSTDFUNCS)];
+#endif /* STARTFUNC */
+
+ if ((lp = loop->lastpoint = (XPoint *)
+ calloc(loop->nsteps+extra_points, sizeof (XPoint))) == NULL) {
+ free_lisa(lc);
+ return False;
+ }
+ phase = lc->loopcount % loop->nsteps;
+
+#if defined DEBUG
+ printf( "nsteps = %d\tcstep = %d\tmrs = %d\textra_points = %d\n",
+ loop->nsteps, loop->cstep, xMaxLines, extra_points );
+ PRINT_FUNC(lf[0]);
+#endif /* DEBUG */
+
+ for (pctr = 0; pctr < loop->nsteps; pctr++) {
+ loop->phi = (double) (pctr - phase) * loop->pistep;
+ loop->theta = (double) (pctr + phase) * loop->pistep;
+ fctr = loop->nfuncs;
+ xsum = ysum = 0.0;
+ while (fctr--) {
+ xprod = yprod = (double) loop->radius;
+ xctr = lf[fctr]->nx;
+ yctr = lf[fctr]->ny;
+ while (xctr--)
+ xprod *= sin(lf[fctr]->xcoeff[xctr] * loop->theta);
+ while (yctr--)
+ yprod *= sin(lf[fctr]->ycoeff[yctr] * loop->phi);
+ xsum += xprod;
+ ysum += yprod;