- struct state * state = calloc(1, sizeof(*state)); // TODO: Check calloc() call
- XGCValues gcv;
- XWindowAttributes xgwa;
-
- state->dpy = dpy;
- state->win = win;
-
- XGetWindowAttributes(state->dpy, state->win, &xgwa);
- state->xlim = xgwa.width;
- state->ylim = xgwa.height;
- state->ypos = 0; // TODO: Explain why.
-
- state->fg = gcv.foreground = get_pixel_resource(state->dpy, xgwa.colormap, "foreground", "Foreground");
- state->bg = gcv.background = get_pixel_resource(state->dpy, xgwa.colormap, "background", "Background");
- state->gc = XCreateGC(state->dpy, state->win, GCForeground, &gcv);
-
- state->delay_microsec = get_integer_resource(state->dpy, "delay", "Integer");
- if (state->delay_microsec < 0) state->delay_microsec = 0;
-
- // TODO: These should be command-line options, but I need to learn how the get_integer_resource() and similar functions work first.
- state->display_info = True;
- state->ruleset = 30;
- state->num_generations = 10000; // TODO: Enforce that this is >1 in order to hold the seed generation and at least one pass through WolframAutomata_draw(), which is where we check for a full pixmap.
-
- state->current_generation = calloc(1, (sizeof(*(state->current_generation))*(state->xlim))); // TODO: Check calloc() call TODO: Can't recall precedence; can I eliminate any parenthesis?
- // TODO: Make the starting state a user-configurable option. At least give the user some options like 'random', 'one-middle', 'one edge', etc.
- // Ideally accept something like a list of integers representing starting pixels to be "on".
- state->current_generation[state->xlim-1] = True;
-
- state->evolution_history = XCreatePixmap(state->dpy, state->win, state->xlim, state->num_generations, 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);
- XFillRectangle(state->dpy, state->evolution_history, state->gc, 0, 0, state->xlim, state->num_generations);
- XSetForeground(state->dpy, state->gc, state->fg);
- // TODO: Need to draw starting generation on pixmap and increment state->ypos.
-
- return state;
+ struct state * state = calloc(1, sizeof(*state)); // TODO: Check calloc() call
+ XGCValues gcv;
+ XWindowAttributes xgwa;
+
+ state->dpy = dpy;
+ state->win = win;
+
+ XGetWindowAttributes(state->dpy, state->win, &xgwa);
+ state->xlim = xgwa.width;
+ state->ylim = xgwa.height;
+ state->ypos = 0; // TODO: Explain why.
+
+ state->fg = gcv.foreground = get_pixel_resource(state->dpy, xgwa.colormap, "foreground", "Foreground");
+ state->bg = gcv.background = get_pixel_resource(state->dpy, xgwa.colormap, "background", "Background");
+ state->gc = XCreateGC(state->dpy, state->win, GCForeground, &gcv);
+
+ state->delay_microsec = get_integer_resource(state->dpy, "delay", "Integer");
+ if (state->delay_microsec < 0) state->delay_microsec = 0;
+
+ // TODO: These should be command-line options, but I need to learn how the get_integer_resource() and similar functions work first.
+ state->display_info = True;
+ state->ruleset = 30;
+ state->num_generations = 10000; // TODO: Enforce that this is >1 in order to hold the seed generation and at least one pass through WolframAutomata_draw(), which is where we check for a full pixmap.
+
+ state->current_generation = calloc(1, (sizeof(*(state->current_generation))*(state->xlim))); // TODO: Check calloc() call TODO: Can't recall precedence; can I eliminate any parenthesis?
+ // TODO: Make the starting state a user-configurable option. At least give the user some options like 'random', 'one-middle', 'one edge', etc.
+ // Ideally accept something like a list of integers representing starting pixels to be "on".
+ state->current_generation[state->xlim-1] = True;
+
+ state->evolution_history = XCreatePixmap(state->dpy, state->win, state->xlim, state->num_generations, 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);
+ XFillRectangle(state->dpy, state->evolution_history, state->gc, 0, 0, state->xlim, state->num_generations);
+ XSetForeground(state->dpy, state->gc, state->fg);
+ // TODO: Need to draw starting generation on pixmap and increment state->ypos.
+
+ return state;