1 --- hacks/glx/psychedelic.c.orig 2011-03-26 21:21:59.000000000 -0400
2 +++ hacks/glx/psychedelic.c 2011-05-04 16:08:17.670000454 -0400
7 +#include "plasmamap.h"
10 #define DEFAULTS "*delay: 30000 \n" \
12 /* #define DEF_STEP "200" */
13 #define DEF_SMOOTH "False"
14 #define DEF_CLOVER "False"
15 -#define DEF_SIMPLE "False"
16 -#define DEF_SIMPLE2 "False"
17 +#define DEF_PLASMA "False"
18 +#define DEF_SINES "False"
20 -enum displaymap {CLOVER, SIMPLE, SIMPLE2};
21 +enum displaymap {CLOVER, PLASMA, SINES};
22 /* #define NUMMAPS 3 */
26 /* static int step; */
34 static XrmOptionDescRec opts[] = {
35 { "-map", ".map", XrmoptionSepArg, 0 },
37 {"+smooth", ".smooth", XrmoptionNoArg, "False" },
38 {"-clover", ".clover", XrmoptionNoArg, "True" },
39 {"+clover", ".clover", XrmoptionNoArg, "False" },
40 - {"-simple", ".simple", XrmoptionNoArg, "True" },
41 - {"+simple", ".simple", XrmoptionNoArg, "False" },
42 - {"-simple2", ".simple2", XrmoptionNoArg, "True" },
43 - {"+simple2", ".simple2", XrmoptionNoArg, "False" },
44 + {"-plasma", ".plasma", XrmoptionNoArg, "True" },
45 + {"+plasma", ".plasma", XrmoptionNoArg, "False" },
46 + {"-sines", ".sines", XrmoptionNoArg, "True" },
47 + {"+sines", ".sines", XrmoptionNoArg, "False" },
50 static argtype vars[] = {
52 /* {&step, "step", "Step", DEF_STEP, t_Int}, */
53 {&smooth, "smooth", "Smooth", DEF_SMOOTH, t_Bool},
54 {&clover, "clover", "Clover", DEF_CLOVER, t_Bool},
55 - {&simple, "simple", "Simple", DEF_SIMPLE, t_Bool},
56 - {&simple2, "simple2", "Simple2", DEF_SIMPLE2, t_Bool},
57 + {&plasma, "plasma", "Plasma", DEF_PLASMA, t_Bool},
58 + {&sines, "sines", "Sines", DEF_SINES, t_Bool},
61 static OptionStruct desc[] = {
63 /* {"-step", "how far the flyers should move forward in one frame"}, */
64 {"-smooth", "whether to use smooth color transitions"},
65 {"-clover", "whether to use the clover (default) colormap--overrides other maps"},
66 - {"-simple", "whether to use the simple colormap"},
67 - {"-simple2", "whether to use the other simple colormap"},
68 + {"-plasma", "whether to use the plasma colormap"},
69 + {"-sines", "whether to use the other simple colormap"},
72 ENTRYPOINT ModeSpecOpt psychedelic_opts = {countof(opts), opts, countof(vars), vars, desc};
77 -/* === some simple maps for testing */
79 -simpleImage(int * bits, int width, int height, int numcolors)
80 +/* === some simple maps that are too small to merit their own file */
81 +static void sineImage(int * bits, int width, int height, int numcolors)
85 - for (i = 0; i < height; i++) {
86 - for (j = 0; j< width / 2; j++) {
87 - bits[ i * width + j ] = bits[i * width + width - j] = j % numcolors;
91 + float xexpand, yexpand;
93 + xexpand = yexpand = 0.0;
94 + while (xexpand == 0.0) xexpand = (float)(random() % 100) / 1000.;
95 + while (yexpand == 0.0) yexpand = (float)(random() % 100) / 1000.;
96 + for (itor = 0; itor < height; itor++)
98 + for (jtor = 0; jtor < width; jtor++)
100 + /* factors between 0.1 and 0.01, assign both separately */
101 + sinemap = 0.25 * (sin(yexpand * itor) + sin(xexpand * jtor)) + 0.5;
102 + bits[itor * width + jtor] = sinemap * (numcolors - 1);
108 -simple2Image(int * bits, int width, int height, int numcolors)
112 - for (i = 0; i < height/2; i++) {
113 - for (j = 0; j< width; j++) {
114 -/* bits[ i * width + j ] =(i > height/2 ? numcolors -(i % numcolors) - 1 : i % numcolors);; */
115 - bits[ i * width + j ] = bits[(height - i) * width + j] = i % numcolors;
122 +/* simpleImage(int * bits, int width, int height, int numcolors) */
126 +/* for (i = 0; i < height; i++) { */
127 +/* for (j = 0; j< width / 2; j++) { */
128 +/* bits[ i * width + j ] = bits[i * width + width - j] = j % numcolors; */
134 +/* sinesImage(int * bits, int width, int height, int numcolors) */
138 +/* for (i = 0; i < height/2; i++) { */
139 +/* for (j = 0; j< width; j++) { */
140 +/* bits[ i * width + j ] = bits[(height - i) * width + j] = i % numcolors; */
146 /* ===== end maps ============== */
148 ENTRYPOINT void reshape_psychedelic (ModeInfo *mi, int width, int height)
149 @@ -209,12 +228,14 @@
150 make_smooth_colormap (MI_DISPLAY(mi),MI_VISUAL(mi), MI_COLORMAP(mi),
151 lp->colors, &lp->numcolors, True, False, 0);
154 make_random_colormap (MI_DISPLAY(mi),MI_VISUAL(mi), MI_COLORMAP(mi),
155 lp->colors, &lp->numcolors, True, False, 0, True);
157 /* add bg color to last slot, overwriting the assigned color */
158 lp->colors[lp->numcolors-1].pixel = MI_BLACK_PIXEL(mi);
159 XQueryColor(MI_DISPLAY(mi), MI_COLORMAP(mi), &lp->colors[lp->numcolors - 1]);
162 lp->pixcolors = calloc(lp->numcolors, sizeof(GLuint));
163 if (lp->pixcolors == NULL)
164 @@ -247,19 +268,19 @@
166 memset(lp->pixgrid, 0, lp->gridheight * lp->gridwidth * sizeof(int));
168 - if (simple) dmap = SIMPLE;
169 - if (simple2) dmap = SIMPLE2;
170 + if (plasma) dmap = PLASMA;
171 + if (sines) dmap = SINES;
172 if (clover) dmap = CLOVER;
176 cloverImage(lp->pixgrid, lp->numcolors, lp->gridwidth, lp->gridheight, R);
179 - simpleImage(lp->pixgrid, lp->gridwidth, lp->gridheight, lp->numcolors );
181 + plasmaImage(lp->pixgrid, lp->gridwidth, lp->gridheight, lp->numcolors );
184 - simple2Image(lp->pixgrid, lp->gridwidth, lp->gridheight, lp->numcolors );
186 + sineImage(lp->pixgrid, lp->gridwidth, lp->gridheight, lp->numcolors );
189 cloverImage(lp->pixgrid, lp->numcolors, lp->gridwidth, lp->gridheight, R);
191 /* deal with likely non-portability of packed pixels -- maybe MI_VISUAL(mi) will be useful */
193 /* make more maps, handle option for them better */
194 +/* come up with a better name for "sines", I know I've seen this pattern before */
195 /* make mono a ramp of greys, not just black and white */
196 +/* save moduloing each pixel by making color array twice the length of ncolors,
197 + * and repeating the colors in the second half
200 -/* take black stripe out of smooth? */
201 /* apparently there is a bug in clovermap that leaves
202 * some indices == numcolors, not numcolors -1
203 * this can cause an out of range error if not modulo'd again
204 --- hacks/glx/Makefile.in.orig 2011-03-27 00:24:34.000000000 -0400
205 +++ hacks/glx/Makefile.in 2011-05-04 15:32:45.000000000 -0400
207 $(UTILS_SRC)/yarandom.o $(UTILS_SRC)/xshm.o $(UTILS_SRC)/erase.o
209 SRCS = xlock-gl-utils.c fps.c xpm-ximage.c xbmread.c flyer.c \ berlinuhr.c bclockhousing.c bclocklamps.c soma.c \ bevelcube.c skylark.c crater4.c ejecta.c craters.c \
210 - clovermap.c psychedelic.c
211 + clovermap.c plasmamap.c psychedelic.c
215 OBJS = xlock-gl-utils.o fps.o xpm-ximage.o xbmread.o flyer.o \
216 berlinuhr.o bclockhousing.o bclocklamps.o soma.o \
217 bevelcube.o skylark.o crater4.o ejecta.o craters.o \
218 - clovermap.o psychedelic.o
219 + clovermap.o plasmamap.o psychedelic.o
222 GL_EXES = flyer berlinuhr soma skylark craters psychedelic
226 HDRS = xpm-ximage.h xbmread.h bclockconnector.h bclockhousing.h \ bclocklamps.h bclocklightbank.h bevelcube.h flipguide.h \ somafigures.h boomerangs.h crater4.h ejecta.h \
228 + clovermap.h plasmamap.h
230 GL_MEN = flyer.man berlinuhr.man soma.man skylark.man craters.man \
233 craters: craters.o crater4.o ejecta.o $(HACK_OBJS)
234 $(CC_HACK) -o $@ $@.o crater4.o ejecta.o $(HACK_OBJS) $(XPM_LIBS)
236 -psychedelic: psychedelic.o clovermap.o $(HACK_OBJS)
237 - $(CC_HACK) -o $@ $@.o clovermap.o $(HACK_OBJS) $(XPM_LIBS)
238 +psychedelic: psychedelic.o clovermap.o plasmamap.o $(HACK_OBJS)
239 + $(CC_HACK) -o $@ $@.o clovermap.o plasmamap.o $(HACK_OBJS) $(XPM_LIBS)
244 fps.o: $(HACK_SRC)/xlockmoreI.h
245 psychedelic.o: $(srcdir)/clovermap.h
246 psychedelic.o: ../../config.h
247 +psychedelic.o: $(srcdir)/plasmamap.h
248 psychedelic.o: $(HACK_SRC)/screenhackI.h
249 psychedelic.o: $(UTILS_SRC)/colors.h
250 psychedelic.o: $(UTILS_SRC)/grabscreen.h