summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/autodice.c96
-rw-r--r--tools/markers1.sh5
-rw-r--r--tools/markers2.sh132
-rw-r--r--tools/render_cards.sh63
-rw-r--r--tools/trim_border.sh20
5 files changed, 316 insertions, 0 deletions
diff --git a/tools/autodice.c b/tools/autodice.c
new file mode 100644
index 0000000..e053056
--- /dev/null
+++ b/tools/autodice.c
@@ -0,0 +1,96 @@
+#include <stdio.h>
+#include <string.h>
+#include <ppm.h>
+
+pixel **image;
+int w, h;
+pixval maxval;
+int rtl = 0;
+
+void save(int x1, int x2, int y1, int y2)
+{
+ int y;
+ ppm_writeppminit(stdout, x2 - x1, y2 - y1, maxval, 0);
+ for (y = y1; y < y2; ++y)
+ ppm_writeppmrow(stdout, &image[y][x1], x2-x1, maxval, 0);
+}
+
+void dice_ltr(int y1, int y2)
+{
+ int x, y, x0 = 0;
+ for (x = 0; x < w; ++x) {
+ for (y = y1; y < y2; ++y) {
+ pixel p = image[y][x];
+ if (p.r < maxval || p.g < maxval || p.b < maxval)
+ break;
+ }
+ if (y == y2) {
+ if (x > x0)
+ save(x0, x, y1, y2);
+ x0 = x + 1;
+ }
+ }
+ if (x > x0)
+ save(x0, x, y1, y2);
+}
+
+void dice_rtl(int y1, int y2)
+{
+ int x, y, x0 = w-1;
+ for (x = w-1; x >= 0; --x) {
+ for (y = y1; y < y2; ++y) {
+ pixel p = image[y][x];
+ if (p.r < maxval || p.g < maxval || p.b < maxval)
+ break;
+ }
+ if (y == y2) {
+ if (x < x0)
+ save(x+1, x0+1, y1, y2);
+ x0 = x - 1;
+ }
+ }
+ if (x < x0)
+ save(x+1, x0+1, y1, y2);
+}
+
+void dice(int y1, int y2)
+{
+ if (rtl)
+ dice_rtl(y1, y2);
+ else
+ dice_ltr(y1, y2);
+}
+
+void slice(void)
+{
+ int x, y, y0 = 0;
+ for (y = 0; y < h; ++y) {
+ for (x = 0; x < w; ++x) {
+ pixel p = image[y][x];
+ if (p.r < maxval || p.g < maxval || p.b < maxval)
+ break;
+ }
+ if (x == w) {
+ if (y > y0)
+ dice(y0, y);
+ y0 = y + 1;
+ }
+ }
+
+ if (y > y0)
+ dice(y0, y);
+}
+
+int main(int argc, char **argv)
+{
+ if (argc > 1 && !strcmp(argv[1], "-rtl"))
+ rtl = 1;
+
+ pm_init(argv[0], 0);
+
+ image = ppm_readppm(stdin, &w, &h, &maxval);
+ slice();
+ ppm_freearray(image, h);
+
+ return 0;
+}
diff --git a/tools/markers1.sh b/tools/markers1.sh
new file mode 100644
index 0000000..9b54701
--- /dev/null
+++ b/tools/markers1.sh
@@ -0,0 +1,5 @@
+pngtopnm HIRES/render/labels.png | ./tools/autodice | pnmsplit - HIRES/render/label_%d.ppm
+pngtopnm HIRES/render/marker11.png | ./tools/autodice | pnmsplit - HIRES/render/marker_1a_%d.ppm
+pngtopnm HIRES/render/marker12.png | ./tools/autodice -rtl | pnmsplit - HIRES/render/marker_1b_%d.ppm
+pngtopnm HIRES/render/marker21.png | ./tools/autodice | pnmsplit - HIRES/render/marker_2a_%d.ppm
+pngtopnm HIRES/render/marker22.png | ./tools/autodice -rtl | pnmsplit - HIRES/render/marker_2b_%d.ppm
diff --git a/tools/markers2.sh b/tools/markers2.sh
new file mode 100644
index 0000000..32196c5
--- /dev/null
+++ b/tools/markers2.sh
@@ -0,0 +1,132 @@
+# lancaster is red
+# york is white
+
+mkdir -p HIRES/output
+
+function trim {
+ echo trimming $3
+ bash tools/trim_border.sh $1 $2 HIRES/render/$3.ppm HIRES/output/$4.png
+}
+
+function small {
+ # large square 35x35 => 280
+ convert -gravity Center -crop 280x280+0+0 HIRES/render/$1.ppm HIRES/output/$2.png
+}
+
+function sticker {
+ # round sticker labels 40x40 => 320x320
+ trim 320 320 $1 $1
+}
+
+function round {
+ # round 50x50 => 400
+ trim 400 400 $1 $2
+}
+
+function large {
+ # large square 46x46 => 368
+ trim 368 368 $1 $2
+}
+
+function large2 {
+ large $1 ${3}_a
+ large $2 ${3}_b
+}
+
+sticker label_0
+sticker label_1
+sticker label_2
+sticker label_3
+sticker label_4
+sticker label_5
+sticker label_6
+sticker label_7
+sticker label_8
+sticker label_9
+sticker label_10
+sticker label_11
+sticker label_12
+sticker label_13
+sticker label_14
+sticker label_15
+sticker label_16
+sticker label_17
+sticker label_18
+sticker label_19
+sticker label_20
+sticker label_21
+sticker label_22
+sticker label_26
+
+round marker_1a_129 end
+round marker_1a_130 levy
+round marker_1b_130 campaign
+
+round marker_1a_128 exile_lancaster
+round marker_1a_132 exile_york
+
+for i in $(seq 0 52)
+do
+ large2 marker_1a_$i marker_1b_$i marker_$i
+done
+
+large marker_1a_54 ip_lancaster
+large marker_1b_54 ip_york
+
+large marker_1a_55 battle
+large marker_1a_56 moved_fought
+large marker_1b_56 source
+
+large marker_1a_126 cities_lancaster
+large marker_1b_126 cities_york
+large marker_1a_127 towns_lancaster
+large marker_1b_127 towns_york
+large marker_1a_134 fortresses_lancaster
+large marker_1b_134 fortresses_york
+large marker_1a_135 victory_check
+
+large marker_2a_0 coin_x1
+large marker_2a_12 coin_x3
+large marker_2a_16 prov_x1
+large marker_2a_33 prov_x3
+large marker_2a_35 cart_x1
+large marker_2a_51 cart_x3
+large marker_2a_57 ship_x1
+large marker_2a_132 retinue
+
+large marker_2b_0 coin_x2
+large marker_2b_12 coin_x4
+large marker_2b_16 prov_x2
+large marker_2b_50 cart_x4
+large marker_2b_33 prov_x4
+large marker_2b_35 cart_x2
+large marker_2b_57 ship_x2
+large marker_2b_132 fled
+
+small marker_1a_90 feed_x2
+small marker_1b_73 feed_x3
+
+small marker_1a_92 rose_lancaster
+small marker_1b_58 rose_york
+
+small marker_1a_103 number_1_lancaster
+small marker_1a_104 number_2_lancaster
+small marker_1a_105 number_3_lancaster
+small marker_1a_106 number_4_lancaster
+small marker_1a_107 number_5_lancaster
+small marker_1a_108 number_6_lancaster
+
+small marker_1b_103 number_1_york
+small marker_1b_104 number_2_york
+small marker_1b_105 number_3_york
+small marker_1b_106 number_4_york
+small marker_1b_107 number_5_york
+small marker_1b_108 number_6_york
+
+small marker_2a_72 hits_lancaster
+small marker_2a_89 hits_york
+
+small marker_2a_60 depleted
+small marker_2a_73 valour
+small marker_2b_60 exhausted
+small marker_2b_73 exile
diff --git a/tools/render_cards.sh b/tools/render_cards.sh
new file mode 100644
index 0000000..792aa2a
--- /dev/null
+++ b/tools/render_cards.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+#
+# Render, crop, resize, and rename card assets.
+#
+
+mkdir -p HIRES/cards
+mkdir -p HIRES/cards75
+mkdir -p HIRES/cards150
+mkdir -p cards.1x cards.2x
+
+gs -dUseBleedBox -sDEVICE=png16m -r1200 -o HIRES/cards/aow_lancaster_%d.png "HIRES/Plantagenet-AoW-Lanc (11).pdf"
+gs -dUseBleedBox -sDEVICE=png16m -r1200 -o HIRES/cards/aow_york_%d.png "HIRES/Plantagenet-AoW-York (15).pdf"
+gs -dUseBleedBox -sDEVICE=png16m -r1200 -o HIRES/cards/cc_lancaster_%d.png "HIRES/PLNT_CC_Lancaster-Front-HiRes.pdf"
+gs -dUseBleedBox -sDEVICE=png16m -r1200 -o HIRES/cards/cc_york_%d.png "HIRES/PLNT_CC_YORK-Front-HiRes.pdf"
+gs -dUseBleedBox -sDEVICE=png16m -r1200 -o HIRES/cards/lord_lancaster_%d.png "HIRES/PLNT_LordCards_Lancaster-HiRes.pdf"
+gs -dUseBleedBox -sDEVICE=png16m -r1200 -o HIRES/cards/lord_york_%d.png "HIRES/PLNT_LordCards_York-HiRes.pdf"
+
+for F in HIRES/cards/*.png
+do
+ B=$(basename $F)
+ echo $B
+ # crop to 186x261 (actual size is 187.5 x 263 - we trim 0.75 to 1 pixel off each margin)
+ convert -colorspace RGB +repage -gravity Center -crop 2976x4176+0+0 -resize 12.5% -colorspace sRGB $F HIRES/cards150/$B
+ convert -colorspace RGB +repage -gravity Center -crop 2976x4176+0+0 -resize 6.25% -colorspace sRGB $F HIRES/cards75/$B
+done
+
+function mv_card {
+ mv HIRES/cards150/$1.png cards.2x/$2.png
+ mv HIRES/cards75/$1.png cards.1x/$2.png
+}
+
+mv HIRES/cards75/aow_* cards.1x
+mv HIRES/cards150/aow_* cards.2x
+
+mv HIRES/cards75/lord_* cards.1x
+mv HIRES/cards150/lord_* cards.2x
+
+mv_card cc_lancaster_1 cc_lancaster_1
+mv_card cc_lancaster_4 cc_lancaster_2
+mv_card cc_lancaster_7 cc_lancaster_3
+mv_card cc_lancaster_10 cc_lancaster_4
+mv_card cc_lancaster_13 cc_lancaster_5
+mv_card cc_lancaster_16 cc_lancaster_6
+mv_card cc_lancaster_19 cc_lancaster_7
+mv_card cc_lancaster_22 cc_lancaster_8
+mv_card cc_lancaster_25 cc_lancaster_9
+mv_card cc_lancaster_28 cc_lancaster_10
+mv_card cc_lancaster_31 cc_lancaster_11
+mv_card cc_lancaster_34 cc_lancaster_12
+
+mv_card cc_york_1 cc_york_1
+mv_card cc_york_4 cc_york_2
+mv_card cc_york_7 cc_york_3
+mv_card cc_york_10 cc_york_4
+mv_card cc_york_13 cc_york_5
+mv_card cc_york_16 cc_york_6
+mv_card cc_york_19 cc_york_7
+mv_card cc_york_22 cc_york_8
+mv_card cc_york_25 cc_york_9
+mv_card cc_york_28 cc_york_10
+mv_card cc_york_31 cc_york_11
+mv_card cc_york_34 cc_york_12
+mv_card cc_york_37 cc_york_13
diff --git a/tools/trim_border.sh b/tools/trim_border.sh
new file mode 100644
index 0000000..9b03ca6
--- /dev/null
+++ b/tools/trim_border.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Trim black-ish border from rounded rectangle/circular token.
+# Fill corners with background color.
+# Center and crop to center.
+#
+# Usage "trim_border.sh input.png output.png width height
+
+w=$1
+h=$2
+
+convert -trim $3 /tmp/out1.png
+
+iw=$(convert /tmp/out1.png -format "%w" info:)
+cx=$(expr $iw / 2)
+bd=$(convert /tmp/out1.png -format "#%[hex:u.p{$cx,2}]" info:)
+bg=$(convert /tmp/out1.png -format "#%[hex:u.p{$cx,8}]" info:)
+
+convert /tmp/out1.png -fuzz 10% -trim -fill white -floodfill +$cx+2 "$bd" -fill "$bg" -floodfill +0+0 white /tmp/out2.png
+convert /tmp/out2.png +repage -gravity Center -crop ${w}x${h}+0+0! $4