X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fdemon.c;h=947134841ec64482f0c09ccb891418bd9085f842;hb=4ade52359b6eba3621566dac79793a33aa4c915f;hp=fcb965980417b319749145d8edfa3b17d5ccd97b;hpb=ffd8c0873576a9e3065696a624dce6b766b77062;p=xscreensaver diff --git a/hacks/demon.c b/hacks/demon.c index fcb96598..94713484 100644 --- a/hacks/demon.c +++ b/hacks/demon.c @@ -46,23 +46,25 @@ static const char sccsid[] = "@(#)demon.c 5.00 2000/11/01 xlockmore"; Triangle 3, 9, or 12 */ +#ifndef HAVE_COCOA +# define DO_STIPPLE +#endif + #ifdef STANDALONE -#define MODE_demon -#define PROGCLASS "Demon" -#define HACK_INIT init_demon -#define HACK_DRAW draw_demon -#define demon_opts xlockmore_opts -#define DEFAULTS "*delay: 50000 \n" \ - "*count: 0 \n" \ - "*cycles: 1000 \n" \ - "*size: -7 \n" \ - "*ncolors: 64 \n" \ - "*neighbors: 0 \n" -#define UNIFORM_COLORS -#include "xlockmore.h" /* in xscreensaver distribution */ +# define MODE_demon +# define DEFAULTS "*delay: 50000 \n" \ + "*count: 0 \n" \ + "*cycles: 1000 \n" \ + "*size: -7 \n" \ + "*ncolors: 64 \n" \ + "*fpsSolid: true \n" \ + "*ignoreRotation: True \n" \ + +# define demon_handle_event 0 +# define UNIFORM_COLORS +# include "xlockmore.h" /* in xscreensaver distribution */ #else /* STANDALONE */ -#include "xlock.h" /* in xlockmore distribution */ - +# include "xlock.h" /* in xlockmore distribution */ #endif /* STANDALONE */ #include "automata.h" @@ -89,7 +91,7 @@ static OptionStruct desc[] = {"-neighbors num", "squares 4 or 8, hexagons 6, triangles 3, 9 or 12"} }; -ModeSpecOpt demon_opts = +ENTRYPOINT ModeSpecOpt demon_opts = {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc}; #ifdef USE_MODULES @@ -164,8 +166,9 @@ drawcell(ModeInfo * mi, int col, int row, unsigned char state) gc = MI_GC(mi); } else { XGCValues gcv; - +#ifdef DO_STIPPLE gcv.stipple = dp->pixmaps[(state - 1) % (NUMSTIPPLES - 1)]; +#endif /* DO_STIPPLE */ gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), dp->stippledGC, @@ -328,7 +331,9 @@ draw_state(ModeInfo * mi, int state) } else { XGCValues gcv; +#ifdef DO_STIPPLE gcv.stipple = dp->pixmaps[(state - 1) % (NUMSTIPPLES - 1)]; +#endif /* DO_STIPPLE */ gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), dp->stippledGC, @@ -401,7 +406,6 @@ draw_state(ModeInfo * mi, int state) } } free_state(dp, state); - XFlush(MI_DISPLAY(mi)); return True; } @@ -422,11 +426,10 @@ RandomSoup(ModeInfo * mi) } } -void -init_demon(ModeInfo * mi) +ENTRYPOINT void +init_demon (ModeInfo * mi) { Display *display = MI_DISPLAY(mi); - Window window = MI_WINDOW(mi); int size = MI_SIZE(mi), nk; demonstruct *dp; @@ -439,8 +442,10 @@ init_demon(ModeInfo * mi) dp->generation = 0; dp->redrawing = 0; +#ifdef DO_STIPPLE if (MI_NPIXELS(mi) < NUMSTIPPLES) { - if (dp->stippledGC == None) { + Window window = MI_WINDOW(mi); + if (dp->stippledGC == None) { XGCValues gcv; gcv.fill_style = FillOpaqueStippled; @@ -458,8 +463,13 @@ init_demon(ModeInfo * mi) } } } +#endif /* DO_STIPPLE */ free_struct(dp); +#ifdef HAVE_COCOA + jwxyz_XSetAntiAliasing (MI_DISPLAY(mi), MI_GC(mi), False); +#endif + for (nk = 0; nk < NEIGHBORKINDS; nk++) { if (neighbors == plots[0][nk]) { dp->neighbors = plots[0][nk]; @@ -588,8 +598,8 @@ init_demon(ModeInfo * mi) RandomSoup(mi); } -void -draw_demon(ModeInfo * mi) +ENTRYPOINT void +draw_demon (ModeInfo * mi) { int i, j, k, l, mj = 0, ml; demonstruct *dp; @@ -688,7 +698,7 @@ draw_demon(ModeInfo * mi) dp->newcell[i + mj] = dp->oldcell[k + ml]; /* W */ k = (!i) ? dp->ncols - 1 : i - 1; - l = j; + /*l = j;*/ ml = mj; if (dp->oldcell[k + ml] == (int) (dp->oldcell[i + mj] + 1) % dp->states) @@ -858,7 +868,7 @@ draw_demon(ModeInfo * mi) dp->newcell[i + mj] = dp->oldcell[k + ml]; /* EE */ k = (i + 1 == dp->ncols) ? 0 : i + 1; - l = j; + /*l = j;*/ ml = mj; if (dp->oldcell[k + ml] == (int) (dp->oldcell[i + mj] + 1) % dp->states) @@ -890,7 +900,7 @@ draw_demon(ModeInfo * mi) dp->newcell[i + mj] = dp->oldcell[k + ml]; /* WW */ k = (!i) ? dp->ncols - 1 : i - 1; - l = j; + /*l = j;*/ ml = mj; if (dp->oldcell[k + ml] == (int) (dp->oldcell[i + mj] + 1) % dp->states) @@ -938,8 +948,18 @@ draw_demon(ModeInfo * mi) } } } -void -release_demon(ModeInfo * mi) + + +ENTRYPOINT void +reshape_demon(ModeInfo * mi, int width, int height) +{ + XClearWindow (MI_DISPLAY (mi), MI_WINDOW(mi)); + init_demon (mi); +} + + +ENTRYPOINT void +release_demon (ModeInfo * mi) { if (demons != NULL) { int screen; @@ -951,8 +971,8 @@ release_demon(ModeInfo * mi) } } -void -refresh_demon(ModeInfo * mi) +ENTRYPOINT void +refresh_demon (ModeInfo * mi) { demonstruct *dp; @@ -964,4 +984,6 @@ refresh_demon(ModeInfo * mi) dp->redrawpos = 0; } +XSCREENSAVER_MODULE ("Demon", demon) + #endif /* MODE_demon */