X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxlyap.c;h=3742df68858b61e40a6d5236a70c3f87ae738a21;hb=278c59e14c53fd412b734e699bd4f314f766f804;hp=a343cfff4759176ddd169b117aa5c9e49a329625;hpb=c6b273ef7292ba10943694df1656b05203d7b62f;p=xscreensaver diff --git a/hacks/xlyap.c b/hacks/xlyap.c index a343cfff..3742df68 100644 --- a/hacks/xlyap.c +++ b/hacks/xlyap.c @@ -47,8 +47,8 @@ char *progclass = "XLyap"; char *defaults [] = { - "*background: black", - "*foreground: white", + ".background: black", + ".foreground: white", "*randomize: false", "*builtin: -1", "*minColor: 1", @@ -582,6 +582,9 @@ main_event(void) break; case ButtonRelease: EndRubberBand(canvas, &rubber_data, &event); + break; + default: + screenhack_handle_event (dpy, &event); break; } } @@ -596,8 +599,8 @@ main_event(void) static int complyap(void) { - register i, bindex; - double total, prod, x, r; + int i, bindex; + double total, prod, x, dx, r; if (!run) return TRUE; @@ -646,7 +649,14 @@ complyap(void) if (useprod) { /* using log(a*b) */ for (i=0;i 1.0e12) || (prod < 1.0e-12)) { total += log(prod); @@ -666,12 +676,19 @@ complyap(void) #endif } total += log(prod); - lyapunov = (total * M_LOG2E) / (double)dwell; + lyapunov = (total * M_LOG2E) / (double)i; } else { /* use log(a) + log(b) */ for (i=0;i= maxindex) { bindex = 0; if (Rflag) @@ -685,8 +702,9 @@ complyap(void) deriv = Derivs[Forcing[findex]]; #endif } - lyapunov = (total * M_LOG2E) / (double)dwell; + lyapunov = (total * M_LOG2E) / (double)i; } + if (sendpoint(lyapunov) == TRUE) return FALSE; else { @@ -1422,6 +1440,15 @@ sendpoint(double expo) static int index; static double tmpexpo; +#if 0 +/* The relationship minexp <= expo <= maxexp should always be true. This test + enforces that. But maybe not enforcing it makes better pictures. */ + if (expo < minexp) + expo = minexp; + else if (expo > maxexp) + expo = maxexp; +#endif + point.x++; tmpexpo = (negative) ? expo : -1.0 * expo; if (tmpexpo > 0) { @@ -1854,6 +1881,14 @@ InitBuffer(void) static void BufferPoint(Display *display, Window window, int color, int x, int y) { + +/* Guard against bogus color values. Shouldn't be necessary but paranoia + is good. */ + if (color < 0) + color = 0; + else if (color >= maxcolor) + color = maxcolor - 1; + if (Points.npoints[color] == MAXPOINTS) { XDrawPoints(display, window, Data_GC[color],