From 8c85f1367d1ef12205c5ed9f9771d62458cc3cdf Mon Sep 17 00:00:00 2001 From: Aaron Taylor Date: Mon, 15 Mar 2021 22:49:03 -0700 Subject: [PATCH] WolframAutomata now uses a black background for the pixmap, reserving the fg/bg colors for active/inactive cells. --- hacks/WolframAutomata/WolframAutomata.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hacks/WolframAutomata/WolframAutomata.c b/hacks/WolframAutomata/WolframAutomata.c index 5e20718..b6da506 100644 --- a/hacks/WolframAutomata/WolframAutomata.c +++ b/hacks/WolframAutomata/WolframAutomata.c @@ -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); + } 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. - 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); -- 2.20.1