X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fcrystal.c;h=a1c501d84978099dd886ceb4dd11a3a531996ba0;hb=6f5482d73adb0165c0130bb47d852644ab0c4869;hp=be090c2efc0a8fa076da55596a8e3116d9468a5d;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/crystal.c b/hacks/crystal.c index be090c2e..a1c501d8 100644 --- a/hacks/crystal.c +++ b/hacks/crystal.c @@ -73,8 +73,9 @@ static const char sccsid[] = "@(#)crystal.c 4.12 98/09/10 xlockmore"; "*count: -500 \n" \ "*cycles: 200 \n" \ "*size: -15 \n" \ - "*ncolors: 100 \n" -# define reshape_crystal 0 + "*ncolors: 100 \n" \ + "*fpsSolid: true \n" \ + # define crystal_handle_event 0 # include "xlockmore.h" /* in xscreensaver distribution */ #else /* STANDALONE */ @@ -92,6 +93,9 @@ static const char sccsid[] = "@(#)crystal.c 4.12 98/09/10 xlockmore"; #define DEF_MAXSIZE "False" #define DEF_CYCLE "True" +#undef NRAND +#define NRAND(n) ( (n) ? (int) (LRAND() % (n)) : 0) + #define min(a,b) ((a) <= (b) ? (a) : (b)) static int nx, ny; @@ -980,9 +984,12 @@ init_crystal(ModeInfo * mi) cryst->offset_w = (int) (cryst->b * 0.5); } } else { + int max_repeat = 10; cryst->offset_w = -1; - while (cryst->offset_w < 4 || (int) (cryst->offset_w - cryst->b * - sin((cryst->gamma - 90) * PI_RAD)) < 4) { + while (max_repeat-- && + (cryst->offset_w < 4 || (int) (cryst->offset_w - cryst->b * + sin((cryst->gamma - 90) * PI_RAD)) < 4) + ) { cryst->b = NRAND((int) (cryst->win_height / (cos((cryst->gamma - 90) * PI_RAD))) - cell_min) + cell_min; if (cryst->planegroup > 8) @@ -1262,4 +1269,11 @@ init_crystal(ModeInfo * mi) XSetFunction(display, cryst->gc, GXcopy); } +ENTRYPOINT void +reshape_crystal(ModeInfo * mi, int width, int height) +{ + release_crystal(mi); + init_crystal(mi); +} + XSCREENSAVER_MODULE ("Crystal", crystal)