From http://www.jwz.org/xscreensaver/xscreensaver-5.18.tar.gz
[xscreensaver] / hacks / abstractile.c
index 6053b7a94805a1343d2ee72d5139fd4a4f5bb2f4..647b7aab93180c8e8db6294e1e511fdaf4d252ef 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (c) 2004, 2007 Steve Sundstrom
+ * Copyright (c) 2004-2009 Steve Sundstrom
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -64,8 +64,6 @@
 #define WAVES                  6
 #define STRETCHES              8
 
-const double PI = 3.1415926535;
-
 struct lineStruct {
     unsigned int x, y, len, obj, color, ndol;
     int deo;
@@ -171,10 +169,10 @@ _wave(struct state *st, int x, int h, int l, int wave)
   l+=1; 
   switch(wave) {
     case 0:                                         /* cos wave*/
-      return((int)(cos((double)x*PI/l)*h));
+      return((int)(cos((double)x*M_PI/l)*h));
     case 1:                                      /* double wave*/
     case 2:                                      /* double wave*/
-      return((int)(cos((double)x*PI/l)*h)+(int)(sin((double)x*PI/l/st->cs1[1])*h));
+      return((int)(cos((double)x*M_PI/l)*h)+(int)(sin((double)x*M_PI/l/st->cs1[1])*h));
     case 3:                                         /* zig zag */
       return(abs((x%(l*2)-l))*h/l);
     case 4:                                   /* giant zig zag */
@@ -774,10 +772,10 @@ _pattern(struct state *st, int x, int y, int n)
       x+=_wave(st,st->gridy-y,st->gridy/(1+st->cs1[n]),st->gridy,0);
       break;
     case 4:                                           /* U curves */
-      x+=_wave(st,y,st->cs1[n]*st->csw[n]/2,st->gridy*2/PI,0);
+      x+=_wave(st,y,st->cs1[n]*st->csw[n]/2,st->gridy*2/M_PI,0);
       break;
     case 5:
-      x-=_wave(st,y,st->cs1[n]*st->csw[n]/2,st->gridy*2/PI,0);
+      x-=_wave(st,y,st->cs1[n]*st->csw[n]/2,st->gridy*2/M_PI,0);
       break;
   }
   switch(st->wsy[0]) {
@@ -794,10 +792,10 @@ _pattern(struct state *st, int x, int y, int n)
       y+=_wave(st,st->gridx-ox,st->gridx/(1+st->cs1[n]),st->gridx,0);
       break;
     case 4:                                         /* U curves */
-      y+=_wave(st,ox,st->cs1[n]*st->csw[n]/2,st->gridy*2/PI,0);
+      y+=_wave(st,ox,st->cs1[n]*st->csw[n]/2,st->gridy*2/M_PI,0);
       break;
     case 5:
-      y-=_wave(st,ox,st->cs1[n]*st->csw[n]/2,st->gridy*2/PI,0);
+      y-=_wave(st,ox,st->cs1[n]*st->csw[n]/2,st->gridy*2/M_PI,0);
       break;
   }
   switch(st->pattern[n]) {
@@ -1104,6 +1102,7 @@ _create_screen(struct state *st)
   values tuned for it draw the screen in a blink on Linux.  Therefore we
   draw 1/200th of the screen with each update and sleep, if necessary */
   st->lpu = (st->dialog) ? st->li/50 : st->li/200;   
+  if (!st->lpu) st->lpu = 1;
   st->bi=1;
   st->mode=MODE_ERASE;
 }
@@ -1521,7 +1520,10 @@ abstractile_draw (Display *dpy, Window window, void *closure)
   int mse, usleep;
  
   gettimeofday(&st->time, NULL);
-  switch (st->mode) {
+
+  /* If the window is too small, do nothing, sorry! */
+  if (st->xgwa.width > 20 && st->xgwa.height > 20) {
+    switch (st->mode) {
     case MODE_CREATE:
       _init_screen(st);
       _create_screen(st);
@@ -1532,6 +1534,7 @@ abstractile_draw (Display *dpy, Window window, void *closure)
     case MODE_DRAW:
       _draw_lines(st);
       break;
+    }
   }
   mse=_mselapsed(st);
   usleep = ((!st->ii) && (st->mode==MODE_CREATE)) ?  0 :
@@ -1570,6 +1573,7 @@ abstractile_free (Display *dpy, Window window, void *closure)
 static const char *abstractile_defaults [] = {
   ".background:    black",
   ".foreground:    white",
+  "*fpsSolid:     true",
   "*sleep:             3",
   "*speed:             3",
   "*tile:         random",