Commit 7370815b9a6e1bae472e62c591ddd0fc0e222b57
Factor out card into theme file
cel committed on 1/25/2019, 10:03:46 PMParent: b2d0368816eaed34a39c0101fed0639cdf4146b3
Files changed
Makefile | changed |
cards.ps | changed |
gencards.sh | changed |
common.ps | added |
themes/original.ps | added |
Makefile | ||
---|---|---|
@@ -1,4 +1,6 @@ | ||
1 … | +THEME = themes/original.ps | |
2 … | + | |
1 | 3 … | all: view-cards.pid |
2 | 4 … | |
3 | 5 … | view-cards.pid: cards.pdf |
4 | 6 … | test -s $@ && kill -HUP $$(cat $@) 2>/dev/null && touch $@ || (mupdf -r 120 $< & echo $$! > $@) |
@@ -8,10 +10,10 @@ | ||
8 | 10 … | |
9 | 11 … | config.ps: |
10 | 12 … | test -s config.ps || cp config.example.ps $@ |
11 | 13 … | |
12 | -cards.pdf: cards.ps config.ps urls | |
13 | - ./gencards.sh > $@ < urls | |
14 … | +cards.pdf: gencards.sh cards.ps config.ps common.ps urls Makefile $(THEME) | |
15 … | + ./gencards.sh $@ $(THEME) < urls | |
14 | 16 … | |
15 | 17 … | clean: |
16 | 18 … | rm -f cards.pdf |
17 | 19 … |
cards.ps | ||
---|---|---|
@@ -3,16 +3,12 @@ | ||
3 | 3 … | %%LanguageLevel: 2 |
4 | 4 … | %%EndComments |
5 | 5 … | %%BeginProlog |
6 | 6 … | |
7 | -/inch {72 mul} def | |
8 | - | |
9 | 7 … | /MarginLeft {.75 inch} def |
10 | 8 … | /MarginBottom {.5 inch} def |
11 | 9 … | /NumRows 5 def |
12 | 10 … | /NumCols 2 def |
13 | -/CardWidth {3.5 inch} def | |
14 | -/CardHeight {2 inch} def | |
15 | 11 … | /GuideSize {.4 inch} def |
16 | 12 … | |
17 | 13 … | /line { |
18 | 14 … | newpath |
@@ -20,33 +16,10 @@ | ||
20 | 16 … | lineto |
21 | 17 … | stroke |
22 | 18 … | } def |
23 | 19 … | |
24 | -/centershow { | |
25 | - dup | |
26 | - stringwidth pop 2 div neg 0 rmoveto | |
27 | - show | |
28 | -} bind def | |
29 | - | |
30 | -/wrapshow { | |
31 | - /height exch def | |
32 | - /len exch def | |
33 | - { | |
34 | - dup length len lt { | |
35 | - show | |
36 | - exit | |
37 | - } { | |
38 | - dup % str str | |
39 | - 0 len getinterval % str strstart | |
40 | - dup show | |
41 | - stringwidth pop neg height neg rmoveto | |
42 | - dup length len sub len exch getinterval | |
43 | - } ifelse | |
44 | - } loop | |
45 | -} def | |
46 | - | |
47 | 20 … | /urlsfile (%stdin) (r) file def |
48 | -/url 180 string def | |
21 … | +/urlstr 180 string def | |
49 | 22 … | |
50 | 23 … | /DrawGuides { |
51 | 24 … | gsave |
52 | 25 … | .125 setlinewidth |
@@ -92,103 +65,21 @@ | ||
92 | 65 … | |
93 | 66 … | grestore |
94 | 67 … | } def |
95 | 68 … | |
96 | -/DrawEPS { | |
97 | - /filename exch def | |
98 | - /z exch def | |
99 | - /bottom exch def | |
100 | - /left exch def | |
101 | - save | |
102 | - left bottom translate | |
103 | - z z scale | |
104 | - /showpage { } def | |
105 | - filename run | |
106 | - | |
107 | - % see PLRM.pdf page 732 | |
108 | - 0 setgray | |
109 | - 0 setlinecap | |
110 | - 1 setlinewidth | |
111 | - 0 setlinejoin | |
112 | - 10 setmiterlimit | |
113 | - [ ] 0 setdash newpath | |
114 | - /languagelevel where { | |
115 | - pop languagelevel 1 ne { | |
116 | - false setstrokeadjust | |
117 | - false setoverprint | |
118 | - } if | |
119 | - } if | |
120 | - | |
121 | - %/Dict_Count countdictstack def | |
122 | - %/Op_Count count def | |
123 | - %begin | |
124 | - | |
125 | - %end | |
126 | - %count | |
127 | - restore | |
128 | -} def | |
129 | - | |
130 | -/DrawCardFront { | |
69 … | +/DrawCardFrontWrap { | |
131 | 70 … | gsave |
132 | - urlsfile url readline { | |
133 | - /url1 exch def | |
134 | - | |
135 | - /LiberationSans 16 selectfont | |
136 | - (Secure Scuttlebutt Network) | |
137 | - 126 117 moveto centershow | |
138 | - | |
139 | - /LiberationSans 13 selectfont | |
140 | - (Invitation Link:) | |
141 | - 126 96 moveto centershow | |
142 | - | |
143 | - currentrgbcolor | |
144 | - 0 0 1 setrgbcolor | |
145 | - /LiberationMono 14 selectfont | |
146 | - .25 inch 1 inch moveto | |
147 | - url1 | |
148 | - 25 14 wrapshow | |
149 | - setrgbcolor | |
150 | - | |
151 | - /w 48 def | |
152 | - /z 1.5 def | |
153 | - 126 w z mul 2 div sub | |
154 | - 12 | |
155 | - z | |
156 | - (small-hermes-hearts-0.eps) DrawEPS | |
157 | - | |
71 … | + urlsfile urlstr readline { | |
72 … | + /url exch def | |
73 … | + DrawCardFront | |
158 | 74 … | /drewsome true def |
159 | 75 … | } if |
160 | 76 … | grestore |
161 | 77 … | } def |
162 | 78 … | |
163 | -/DrawCardBack { | |
79 … | +/DrawCardBackWrap { | |
164 | 80 … | gsave |
165 | - | |
166 | - /LiberationSans 12 selectfont | |
167 | - 16 117 moveto | |
168 | - pub_name show | |
169 | - | |
170 | - /LiberationMono 8 selectfont | |
171 | - pub_id | |
172 | - 16 102 moveto | |
173 | - 27 10 wrapshow | |
174 | - | |
175 | - /LiberationSans 12 selectfont | |
176 | - 16 68 moveto | |
177 | - op_name show | |
178 | - | |
179 | - /LiberationMono 8 selectfont | |
180 | - op_id | |
181 | - 16 53 moveto | |
182 | - 27 10 wrapshow | |
183 | - | |
184 | - 180 62 1 3 div | |
185 | - (rainbow-hermies-strong-border.eps) DrawEPS | |
186 | - | |
187 | - /LiberationSans 10 selectfont | |
188 | - 12 16 moveto | |
189 | - (decentralized - peer-to-peer - off-grid - open source) show | |
190 | - | |
81 … | + DrawCardBack | |
191 | 82 … | grestore |
192 | 83 … | } def |
193 | 84 … | |
194 | 85 … | currentpagedevice /PageSize get dup |
@@ -206,11 +97,11 @@ | ||
206 | 97 … | %NumCols { |
207 | 98 … | % DrawCard |
208 | 99 … | % CardWidth 0 translate |
209 | 100 … | %} repeat |
210 | - DrawCardFront | |
101 … | + DrawCardFrontWrap | |
211 | 102 … | CardWidth 0 translate |
212 | - DrawCardBack | |
103 … | + DrawCardBackWrap | |
213 | 104 … | CardWidth 0 translate |
214 | 105 … | NumCols CardWidth mul neg CardHeight neg translate |
215 | 106 … | } repeat |
216 | 107 … | 0 NumRows CardHeight mul neg translate |
gencards.sh | ||
---|---|---|
@@ -1,3 +1,3 @@ | ||
1 | 1 … | #!/bin/sh |
2 | 2 … | cd "$(dirname "$0")" |
3 | -exec gs -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=- -f config.ps -f cards.ps | |
3 … | +exec gs -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="${1?output.pdf}" -f config.ps -f common.ps -f "${2?theme.pdf}" -f cards.ps |
common.ps | ||
---|---|---|
@@ -1,0 +1,66 @@ | ||
1 … | +%!PS-Adobe-3.0 | |
2 … | +%%Title: some shared code | |
3 … | +%%LanguageLevel: 2 | |
4 … | +%%EndComments | |
5 … | +%%BeginProlog | |
6 … | + | |
7 … | +/inch {72 mul} def | |
8 … | +/CardWidth {3.5 inch} def | |
9 … | +/CardHeight {2 inch} def | |
10 … | + | |
11 … | +/centershow { | |
12 … | + dup | |
13 … | + stringwidth pop 2 div neg 0 rmoveto | |
14 … | + show | |
15 … | +} bind def | |
16 … | + | |
17 … | +/wrapshow { | |
18 … | + /height exch def | |
19 … | + /len exch def | |
20 … | + { | |
21 … | + dup length len lt { | |
22 … | + show | |
23 … | + exit | |
24 … | + } { | |
25 … | + dup % str str | |
26 … | + 0 len getinterval % str strstart | |
27 … | + dup show | |
28 … | + stringwidth pop neg height neg rmoveto | |
29 … | + dup length len sub len exch getinterval | |
30 … | + } ifelse | |
31 … | + } loop | |
32 … | +} def | |
33 … | + | |
34 … | +/DrawEPS { | |
35 … | + /filename exch def | |
36 … | + /z exch def | |
37 … | + /bottom exch def | |
38 … | + /left exch def | |
39 … | + save | |
40 … | + left bottom translate | |
41 … | + z z scale | |
42 … | + /showpage { } def | |
43 … | + filename run | |
44 … | + | |
45 … | + % see PLRM.pdf page 732 | |
46 … | + 0 setgray | |
47 … | + 0 setlinecap | |
48 … | + 1 setlinewidth | |
49 … | + 0 setlinejoin | |
50 … | + 10 setmiterlimit | |
51 … | + [ ] 0 setdash newpath | |
52 … | + /languagelevel where { | |
53 … | + pop languagelevel 1 ne { | |
54 … | + false setstrokeadjust | |
55 … | + false setoverprint | |
56 … | + } if | |
57 … | + } if | |
58 … | + | |
59 … | + %/Dict_Count countdictstack def | |
60 … | + %/Op_Count count def | |
61 … | + %begin | |
62 … | + | |
63 … | + %end | |
64 … | + %count | |
65 … | + restore | |
66 … | +} def |
themes/original.ps | ||
---|---|---|
@@ -1,0 +1,58 @@ | ||
1 … | +%!PS-Adobe-3.0 | |
2 … | +%%Title: SSB Invitation Cards - cel's original card theme | |
3 … | +%%LanguageLevel: 2 | |
4 … | +%%EndComments | |
5 … | +%%BeginProlog | |
6 … | + | |
7 … | +/DrawCardFront { | |
8 … | + /LiberationSans 16 selectfont | |
9 … | + (Secure Scuttlebutt Network) | |
10 … | + 126 117 moveto centershow | |
11 … | + | |
12 … | + /LiberationSans 13 selectfont | |
13 … | + (Invitation Link:) | |
14 … | + 126 96 moveto centershow | |
15 … | + | |
16 … | + currentrgbcolor | |
17 … | + 0 0 1 setrgbcolor | |
18 … | + /LiberationMono 14 selectfont | |
19 … | + .25 inch 1 inch moveto | |
20 … | + url | |
21 … | + 25 14 wrapshow | |
22 … | + setrgbcolor | |
23 … | + | |
24 … | + /w 48 def | |
25 … | + /z 1.5 def | |
26 … | + 126 w z mul 2 div sub | |
27 … | + 12 | |
28 … | + z | |
29 … | + (small-hermes-hearts-0.eps) DrawEPS | |
30 … | +} def | |
31 … | + | |
32 … | +/DrawCardBack { | |
33 … | + /LiberationSans 12 selectfont | |
34 … | + 16 117 moveto | |
35 … | + pub_name show | |
36 … | + | |
37 … | + /LiberationMono 8 selectfont | |
38 … | + pub_id | |
39 … | + 16 102 moveto | |
40 … | + 27 10 wrapshow | |
41 … | + | |
42 … | + /LiberationSans 12 selectfont | |
43 … | + 16 68 moveto | |
44 … | + op_name show | |
45 … | + | |
46 … | + /LiberationMono 8 selectfont | |
47 … | + op_id | |
48 … | + 16 53 moveto | |
49 … | + 27 10 wrapshow | |
50 … | + | |
51 … | + 180 62 1 3 div | |
52 … | + (rainbow-hermies-strong-border.eps) DrawEPS | |
53 … | + | |
54 … | + /LiberationSans 10 selectfont | |
55 … | + 12 16 moveto | |
56 … | + (decentralized - peer-to-peer - off-grid - open source) show | |
57 … | + | |
58 … | +} def |
Built with git-ssb-web