projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.31.tar.gz
[xscreensaver]
/
hacks
/
forest.c
diff --git
a/hacks/forest.c
b/hacks/forest.c
index 0a64c0609a11087f58db86dba8ac4d83a6d7b86e..23392c741da996ef2fc06d8d7f10baf0f6832b3e 100644
(file)
--- a/
hacks/forest.c
+++ b/
hacks/forest.c
@@
-14,24
+14,32
@@
* implied warranty.
*/
* implied warranty.
*/
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* ****************************** NOTE ******************************
+
+ This is not the xlockmore version of forest, but a much better
+ looking rewrite. Be careful not to delete it in a merging frenzy...
+
+ **********************************************************************
+ */
#ifdef STANDALONE
#ifdef STANDALONE
-# define PROGCLASS "Forest" /*"XTree"*/
-# define HACK_INIT init_trees
-# define HACK_DRAW draw_trees
-# define trees_opts xlockmore_opts
# define DEFAULTS "*delay: 500000 \n" \
# define DEFAULTS "*delay: 500000 \n" \
- "*ncolors: 20 \n" \
- "*eraseSpeed: 400 \n" \
- "*eraseMode: -1 \n" \
- "*installColormap False"
+ "*ncolors: 20 \n" \
+ "*fpsSolid: true \n" \
+
# include "xlockmore.h" /* from the xscreensaver distribution */
# include "xlockmore.h" /* from the xscreensaver distribution */
+# define refresh_trees 0
+# define reshape_trees 0
+# define trees_handle_event 0
#else /* !STANDALONE */
# include "xlock.h" /* from the xlockmore distribution */
#endif /* !STANDALONE */
#else /* !STANDALONE */
# include "xlock.h" /* from the xlockmore distribution */
#endif /* !STANDALONE */
-ModeSpecOpt trees_opts = {0, NULL, 0, NULL, NULL};
+
ENTRYPOINT
ModeSpecOpt trees_opts = {0, NULL, 0, NULL, NULL};
typedef struct {
int x;
typedef struct {
int x;
@@
-40,13
+48,14
@@
typedef struct {
double size;
long color;
int toDo;
double size;
long color;
int toDo;
+ int pause;
int season;
} treestruct;
static treestruct *trees = NULL;
int season;
} treestruct;
static treestruct *trees = NULL;
-XColor colors[20];
-int color;
+
static
XColor colors[20];
+
static
int color;
static long colorM[12] = {0xff0000, 0xff8000, 0xffff00, 0x80ff00,
0x00ff00, 0x00ff80, 0x00ffff, 0x0080ff,
static long colorM[12] = {0xff0000, 0xff8000, 0xffff00, 0x80ff00,
0x00ff00, 0x00ff80, 0x00ffff, 0x0080ff,
@@
-56,7
+65,9
@@
static long colorV[12] = {0x0a0000, 0x0a0500, 0x0a0a00, 0x050a00,
0x000a00, 0x000a05, 0x000a0a, 0x00050a,
0x00000a, 0x05000a, 0x0a000a, 0x0a0005};
0x000a00, 0x000a05, 0x000a0a, 0x00050a,
0x00000a, 0x05000a, 0x0a000a, 0x0a0005};
-void init_trees(ModeInfo * mi) {
+ENTRYPOINT void
+init_trees(ModeInfo * mi)
+{
unsigned long pixels[20];
treestruct *tree;
Display *display = MI_DISPLAY(mi);
unsigned long pixels[20];
treestruct *tree;
Display *display = MI_DISPLAY(mi);
@@
-132,13
+143,15
@@
void init_trees(ModeInfo * mi) {
color = i;
}
color = i;
}
-double rRand(double a, double b) {
+static double rRand(double a, double b)
+{
return (a+(b-a)*NRAND(10001)/10000.0);
}
return (a+(b-a)*NRAND(10001)/10000.0);
}
-void draw_line(ModeInfo * mi,
- int x1, int y1, int x2, int y2,
- double angle, int widths, int widthe) {
+static void draw_line(ModeInfo * mi,
+ int x1, int y1, int x2, int y2,
+ double angle, int widths, int widthe)
+{
Display *display = MI_DISPLAY(mi);
GC gc = MI_GC(mi);
Display *display = MI_DISPLAY(mi);
GC gc = MI_GC(mi);
@@
-166,7
+179,8
@@
void draw_line(ModeInfo * mi,
}
}
}
}
-void draw_tree_rec(ModeInfo * mi, double thick, int x, int y, double angle) {
+static void draw_tree_rec(ModeInfo * mi, double thick, int x, int y, double angle)
+{
treestruct *tree = &trees[MI_SCREEN(mi)];
Display *display = MI_DISPLAY(mi);
GC gc = MI_GC(mi);
treestruct *tree = &trees[MI_SCREEN(mi)];
Display *display = MI_DISPLAY(mi);
GC gc = MI_GC(mi);
@@
-202,14
+216,22
@@
void draw_tree_rec(ModeInfo * mi, double thick, int x, int y, double angle) {
}
}
}
}
-void draw_trees(ModeInfo * mi) {
+ENTRYPOINT void
+draw_trees(ModeInfo * mi)
+{
treestruct *tree = &trees[MI_SCREEN(mi)];
int width = MI_WIN_WIDTH(mi);
int height = MI_WIN_HEIGHT(mi);
treestruct *tree = &trees[MI_SCREEN(mi)];
int width = MI_WIN_WIDTH(mi);
int height = MI_WIN_HEIGHT(mi);
- if (
--(tree->toDo) == 0
) {
-
usleep(3000000)
;
+ if (
tree->pause == 1
) {
+
tree->pause--
;
init_trees(mi);
init_trees(mi);
+ } else if (tree->pause > 1) {
+ tree->pause--;
+ return;
+ } else if (--(tree->toDo) == 0) {
+ tree->pause = 6;
+ return;
}
tree->x = NRAND(width);
}
tree->x = NRAND(width);
@@
-225,9
+247,14
@@
void draw_trees(ModeInfo * mi) {
draw_tree_rec(mi, tree->thick, tree->x, tree->y, rRand(-0.1, 0.1));
}
draw_tree_rec(mi, tree->thick, tree->x, tree->y, rRand(-0.1, 0.1));
}
-void release_trees(ModeInfo * mi) {
+
+ENTRYPOINT void
+release_trees(ModeInfo * mi)
+{
if (trees != NULL) {
(void) free((void *) trees);
trees = NULL;
}
}
if (trees != NULL) {
(void) free((void *) trees);
trees = NULL;
}
}
+
+XSCREENSAVER_MODULE_2 ("Forest", forest, trees)