Added notes on generating screenshots of running hacks.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 7 Jun 2021 22:08:44 +0000 (15:08 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 7 Jun 2021 22:08:44 +0000 (15:08 -0700)
hacks/WolframAutomata/screenshot_notes.md [new file with mode: 0644]

diff --git a/hacks/WolframAutomata/screenshot_notes.md b/hacks/WolframAutomata/screenshot_notes.md
new file mode 100644 (file)
index 0000000..61cdbd4
--- /dev/null
@@ -0,0 +1,49 @@
+Screenshots for the README were generated by dumping X pixmaps in XPM format,
+followed by conversion to GIF and integration into animated GIF using
+ImageMagick.
+
+First, to generate an XPM screenshot on each frame, make the following code
+modifications to `WolframAutomata.c`.
+
+Add to `struct state`:
+
+    int framenumber;
+
+In `WolframAutomata_init()`:
+
+    state->framenumber = 0;
+
+In `WolframAutomata_draw()`, toward the end, right before returning:
+
+    XWindowAttributes xgwa;
+    XGetWindowAttributes(state->dpy, state->win, &xgwa);
+    Pixmap temp = XCreatePixmap(state->dpy, state->win, state->dpy_width, state->dpy_height, xgwa.depth);
+    XCopyArea(state->dpy, state->evolution_history, temp, state->gc, 0, window_y_offset, state->dpy_width, state->dpy_height, 0, 0);
+    char * buffer = malloc(29);
+    snprintf(buffer, 29, "/tmp/wolfram-frame-%05d.xpm", state->framenumber);
+    XpmWriteFileFromPixmap(state->dpy, buffer, temp, 0, NULL);
+    state->framenumber++;
+    XFreePixmap(state->dpy, temp);
+
+Deleting every other frame had negligible visual impact, so all odd number
+frames were deleted to shrink file size of the resulting animation.
+
+To convert all XPM files in a directory using ImageMagick's `convert`, use the
+following bash snippet:
+
+    for f in *.xpm ; do convert "$f" "${f%.xpm}.gif" ; done
+
+To combine GIFs into a single animated GIF, use the following command:
+
+    convert -layers OptimizePlus -delay 10x600 wolfram-frame-*.gif -loop 0 wolfram.gif
+
+Check the ImageMagick manual for other `-layers` options. Some had significant
+impact on filesize and the manual contains good descriptions of the algorithm
+behind each.
+
+For setting the replay speed of the animated GIF, note that `-delay` is of the
+form `ticks-per-frame x ticks-per-second`. For example, `10x600` is ten ticks
+per frame and 600 ticks per second.
+
+Unlike what one might expact, `-loop 0` causes the animated GIF to loop and
+`-loop 1` causes it to halt.