chiark / gitweb /
Correct URL and add it to output
[bedbugs.git] / src / bedbugs.c
index 05d22ba39bb3ba41b11fd58d67b4f9f88a546373..c9e70e20e68c0388d3c2e31589965b278d71d422 100644 (file)
@@ -43,7 +43,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Website: http://www.chiark.greenend.org.uk/ucgi/~jacobn/git/bedbugs-git/
+ * Website: http://www.chiark.greenend.org.uk/ucgi/~jacobn/git/bedbugs.git/
  *
  *
  * This source file, bedbugs.c, is based on
@@ -298,7 +298,12 @@ void icons(void)
                 int size = sizes[size_index], state;
                 printf("XPM\n/* width height num_colors chars_per_pixel */\n");
                 printf("\"%d %d 2 1\"\n", size, size*33);
-                printf("/* colors */\n\". c #000000\"\n\"A c #FFFFFF\"\n");
+                /* We have to have a non-greyscale colour to trigger Golly's
+                 * "multi-colour icon" mode, so that we can make some states'
+                 * non-icon versions black. And it's not sufficient to
+                 * include an unreferenced, colour, so our 'on' state is
+                 * off-white. */
+                printf("/* colors */\n\". c #000000\"\n\"A c #FEFEFF\"\n");
                 /* icons never used for state 0 */
                 for (state = 1; state < 34; state++) {
                     bool *r = blank(size);
@@ -324,6 +329,26 @@ void icons(void)
         }
 }
 
+void colours(void)
+{
+    int i;
+    for (i=0; i<34; i++) {
+        int lvl;
+        switch (i) {
+            case 0:
+                lvl = 0;
+                break;
+            case 1:
+                lvl = 255;
+                break;
+            default:
+                lvl = (i >= 2+16) ? 255 : 0;
+                break;
+        }
+        printf("%2d %3d %3d %3d\n", i, lvl, lvl, lvl);
+    }
+}
+
 int main(int argc, char *argv[])
 {
     while (!feof(stdin)) {
@@ -341,6 +366,8 @@ int main(int argc, char *argv[])
                 bedstead();
             } else if (strncmp(l+2, "ICONS", n) == 0) {
                 icons();
+            } else if (strncmp(l+2, "COLORS", n) == 0) {
+                colours();
             } else {
                 /* Bodily insert named file on stdout. */
                 FILE *f;