WolframAutomata now uses a black background for the pixmap, reserving the fg/bg color...
[screensavers] / hacks / WolframAutomata / WolframAutomata.c
index 59562b3..b6da506 100644 (file)
@@ -49,6 +49,7 @@
 //              -background "COLORNAME"
 //              (default is black and white)
 //              (mention sample color combinations in manpage, and link to: https://en.wikipedia.org/wiki/X11_color_names)
 //              -background "COLORNAME"
 //              (default is black and white)
 //              (mention sample color combinations in manpage, and link to: https://en.wikipedia.org/wiki/X11_color_names)
+//              (note to the user that most color names they can naturally think of (e.g. red, purple, gray, pink, etc) are valid X11 color names for these CLI options.)
 //        display info overlay with CA number and start conditions?
 //              -overlay
 //        which ruleset number to use? Or random? Or random from small set of hand-selected interesting examples?
 //        display info overlay with CA number and start conditions?
 //              -overlay
 //        which ruleset number to use? Or random? Or random from small set of hand-selected interesting examples?
@@ -166,9 +167,35 @@ struct color_pair {
 };
 
 // TODO: Decorations
 };
 
 // TODO: Decorations
-// TODO: Populate this table with more examples.
 static const struct color_pair color_list[] = {
 static const struct color_pair color_list[] = {
+    {"red", "black"},
+    {"olive", "black"},
+    {"teal", "black"},
+    {"slateblue", "black"},
+    {"violet", "black"},
+    {"purple", "black"},
     {"white", "black"},
     {"white", "black"},
+    {"white", "darkgreen"},
+    {"white", "darkmagenta"},
+    {"white", "darkred"},
+    {"white", "darkblue"},
+    {"darkslategray", "darkslategray1"},
+    {"lightsteelblue", "darkslategray"},
+    {"royalblue4", "royalblue"},
+    {"antiquewhite2", "antiquewhite4"},
+    {"darkolivegreen1", "darkolivegreen"},
+    {"darkseagreen1", "darkseagreen4"},
+    {"pink", "darkred"},
+    {"lightblue", "darkgreen"},
+    {"red", "blue"},
+    {"red", "darkgreen"},
+    {"aqua", "teal"},
+    {"darkblue", "teal"},
+    {"khaki", "seagreen"},
+    {"khaki", "darkolivegreen"},
+    {"lightslategray", "darkslategray"},
+    {"tomato", "darkslategray"},
+    {"tomato", "darkcyan"}
 };
 
 /* -------------------------------------------------------------------------- */
 };
 
 /* -------------------------------------------------------------------------- */
@@ -227,6 +254,10 @@ render_current_generation(struct state * state)
     for (xpos = 0; xpos < state->number_of_cells; xpos++) {
         if (state->current_generation[xpos] == True) {
             XFillRectangle(state->dpy, state->evolution_history, state->gc, xpos*state->pixel_size, state->ypos, state->pixel_size, state->pixel_size);
     for (xpos = 0; xpos < state->number_of_cells; xpos++) {
         if (state->current_generation[xpos] == True) {
             XFillRectangle(state->dpy, state->evolution_history, state->gc, xpos*state->pixel_size, state->ypos, state->pixel_size, state->pixel_size);
+        } else {
+            XSetForeground(state->dpy, state->gc, state->bg);
+            XFillRectangle(state->dpy, state->evolution_history, state->gc, xpos*state->pixel_size, state->ypos, state->pixel_size, state->pixel_size);
+            XSetForeground(state->dpy, state->gc, state->fg);
         }
     }
 }
         }
     }
 }
@@ -343,7 +374,9 @@ WolframAutomata_init(Display * dpy, Window win)
     state->evolution_history = XCreatePixmap(state->dpy, state->win, state->xlim, state->num_generations*state->pixel_size, xgwa.depth);
     // Pixmap contents are undefined after creation. Explicitly set a black
     // background by drawing a black rectangle over the entire pixmap.
     state->evolution_history = XCreatePixmap(state->dpy, state->win, state->xlim, state->num_generations*state->pixel_size, xgwa.depth);
     // Pixmap contents are undefined after creation. Explicitly set a black
     // background by drawing a black rectangle over the entire pixmap.
-    XSetForeground(state->dpy, state->gc, state->bg);
+    XColor blackx, blacks;
+    XAllocNamedColor(state->dpy, DefaultColormapOfScreen(DefaultScreenOfDisplay(state->dpy)), "black", &blacks, &blackx);
+    XSetForeground(state->dpy, state->gc, blacks.pixel);
     XFillRectangle(state->dpy, state->evolution_history, state->gc, 0, 0, state->xlim, state->num_generations*state->pixel_size);
     XSetForeground(state->dpy, state->gc, state->fg);
     render_current_generation(state);
     XFillRectangle(state->dpy, state->evolution_history, state->gc, 0, 0, state->xlim, state->num_generations*state->pixel_size);
     XSetForeground(state->dpy, state->gc, state->fg);
     render_current_generation(state);