projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
http://ftp.x.org/contrib/applications/xscreensaver-3.03.tar.gz
[xscreensaver]
/
hacks
/
coral.c
diff --git
a/hacks/coral.c
b/hacks/coral.c
index eddde276d3bfb29ab93ea6bd68b0d8a6df51cca4..55186747327297fbe731753507d061b0c3815064 100644
(file)
--- a/
hacks/coral.c
+++ b/
hacks/coral.c
@@
-11,8
+11,9
@@
#include "screenhack.h"
#include "colors.h"
#include "screenhack.h"
#include "colors.h"
+#include "erase.h"
-static GC draw_gc;
+static GC draw_gc
, erase_gc
;
static unsigned int default_fg_pixel;
#define NCOLORSMAX 200
static XColor colors[NCOLORSMAX];
static unsigned int default_fg_pixel;
#define NCOLORSMAX 200
static XColor colors[NCOLORSMAX];
@@
-20,12
+21,12
@@
static int ncolors = 0;
static int colorindex = 0;
static int colorsloth;
static int colorindex = 0;
static int colorsloth;
-static XPoint *walkers;
+static XPoint *walkers
= 0
;
static int nwalkers;
static int width, widthb;
static int height;
static int nwalkers;
static int width, widthb;
static int height;
-static unsigned int *board;
+static unsigned int *board
= 0
;
#define getdot(x,y) (board[(y*widthb)+(x>>5)] & (1<<(x & 31)))
#define setdot(x,y) (board[(y*widthb)+(x>>5)] |= (1<<(x & 31)))
#define getdot(x,y) (board[(y*widthb)+(x>>5)] & (1<<(x & 31)))
#define setdot(x,y) (board[(y*widthb)+(x>>5)] |= (1<<(x & 31)))
@@
-46,6
+47,7
@@
init_coral(Display *dpy, Window window)
width = xgwa.width;
widthb = ((xgwa.width + 31) >> 5);
height = xgwa.height;
width = xgwa.width;
widthb = ((xgwa.width + 31) >> 5);
height = xgwa.height;
+ if (board) free(board);
board = (unsigned int *)calloc(widthb * xgwa.height, sizeof(unsigned int));
if(!board) exit(1);
cmap = xgwa.colormap;
board = (unsigned int *)calloc(widthb * xgwa.height, sizeof(unsigned int));
if(!board) exit(1);
cmap = xgwa.colormap;
@@
-55,14
+57,24
@@
init_coral(Display *dpy, Window window)
}
gcv.foreground = default_fg_pixel = get_pixel_resource("foreground", "Foreground", dpy, cmap);
draw_gc = XCreateGC(dpy, window, GCForeground, &gcv);
}
gcv.foreground = default_fg_pixel = get_pixel_resource("foreground", "Foreground", dpy, cmap);
draw_gc = XCreateGC(dpy, window, GCForeground, &gcv);
+ gcv.foreground = get_pixel_resource ("background", "Background",dpy, cmap);
+ erase_gc = XCreateGC (dpy, window, GCForeground, &gcv);
ncolors = NCOLORSMAX;
make_uniform_colormap(dpy, xgwa.visual, cmap, colors, &ncolors, True, &writeable, False);
ncolors = NCOLORSMAX;
make_uniform_colormap(dpy, xgwa.visual, cmap, colors, &ncolors, True, &writeable, False);
+ if (ncolors <= 0) {
+ ncolors = 2;
+ colors[0].red = colors[0].green = colors[0].blue = 0;
+ colors[1].red = colors[1].green = colors[1].blue = 0xFFFF;
+ XAllocColor(dpy, cmap, &colors[0]);
+ XAllocColor(dpy, cmap, &colors[1]);
+ }
colorindex = random()%ncolors;
density = get_integer_resource("density", "Integer");
if( density < 1 ) density = 1;
if( density > 100 ) density = 90; /* more like mold than coral */
nwalkers = (width*height*density)/100;
colorindex = random()%ncolors;
density = get_integer_resource("density", "Integer");
if( density < 1 ) density = 1;
if( density > 100 ) density = 90; /* more like mold than coral */
nwalkers = (width*height*density)/100;
+ if (walkers) free(walkers);
walkers = (XPoint *)calloc(nwalkers, sizeof(XPoint));
if( (XPoint *)0 == walkers ) exit(1);
walkers = (XPoint *)calloc(nwalkers, sizeof(XPoint));
if( (XPoint *)0 == walkers ) exit(1);
@@
-215,13
+227,13
@@
coral(Display *dpy, Window window)
char *progclass = "Coral";
char *defaults[] = {
char *progclass = "Coral";
char *defaults[] = {
-
"Coral.background:
black",
-
"Coral.foreground:
white",
-
"*density:
25",
-
"*seeds:
20", /* too many for 640x480, too few for 1280x1024 */
-
"*delay:
5",
-
"*delay2:
1000",
-
0
+
".background:
black",
+
".foreground:
white",
+
"*density:
25",
+
"*seeds:
20", /* too many for 640x480, too few for 1280x1024 */
+
"*delay:
5",
+
"*delay2:
1000",
+ 0
};
XrmOptionDescRec options[] = {
};
XrmOptionDescRec options[] = {
@@
-238,10
+250,10
@@
Display *dpy;
Window window;
{
int delay = get_integer_resource ("delay", "Integer");
Window window;
{
int delay = get_integer_resource ("delay", "Integer");
-
while( 1 ) {
init_coral(dpy, window);
coral(dpy, window);
if( delay ) sleep(delay);
while( 1 ) {
init_coral(dpy, window);
coral(dpy, window);
if( delay ) sleep(delay);
+ erase_full_window(dpy, window);
}
}
}
}