WolframAutomata now uses a black background for the pixmap, reserving the fg/bg color...
authorAaron Taylor <ataylor@subgeniuskitty.com>
Tue, 16 Mar 2021 05:49:03 +0000 (22:49 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Tue, 16 Mar 2021 05:49:03 +0000 (22:49 -0700)
hacks/WolframAutomata/WolframAutomata.c

index 5e20718..b6da506 100644 (file)
@@ -254,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);
         }
     }
 }
         }
     }
 }
@@ -370,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);