File: mktiles

package info (click to toggle)
gfpoken 1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,944 kB
  • sloc: ansic: 2,984; sh: 1,446; makefile: 125
file content (243 lines) | stat: -rwxr-xr-x 4,827 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/bin/bash
# Make tile pictures for GFingerPoken
# Copyright 2005-2007  Bas Wijnen <wijnen@debian.org>
#
# This file is part of Gfingerpoken.
#
# Gfingerpoken is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Gfingerpoken is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


set -e

export HOME="`mktemp -d`"
export GIMP2_DIRECTORY="$HOME/gimp"
mkdir --parents $GIMP2_DIRECTORY

num_tiles=33
tile_size=32

if [ ! -d png ] ; then mkdir png ; fi

gimp --verbose -i -d -f -c -b - << EOF
(let*
	(
		(image (car (gimp-file-load 1 "`dirname "$0"`/mirror.xcf"
				"`dirname "$0"`/mirror.xcf")))
		(layers (cadr (gimp-image-get-layers image)))
		(expansion 0)
		(collapse 1)
		(rotation 2)
		(move 3)
		(rotator 4)
		(axial 5)
		(sink 6)
		(block 7)
		(half 8)
		(normal 9)
		(bg 10)
		(numlayers 11)
	)
	(define (use layer) (vector-ref layers layer))
	(define (set layer value)
		'("new value for layer" layer value)
		(vector-set! layers layer value)
	)
	(define (show layer) (gimp-drawable-set-visible (use layer) 1))
	(define (hide layer) (gimp-drawable-set-visible (use layer) 0))
	(define (save name)
		(let* (
				(saver (car (gimp-image-duplicate image)))
				(dummy 0)
				(savelayer 0))
			(gimp-image-undo-disable saver)
			(set! dummy (car (gimp-layer-copy (car
				(gimp-image-get-active-layer saver)) 1)))
			(gimp-image-add-layer saver dummy -1)
			(gimp-layer-set-opacity dummy 0)
			(set! savelayer (car (gimp-image-merge-visible-layers
				saver 0)))
			(gimp-file-save 1 saver savelayer name name)
			(gimp-image-delete saver)
		)
	)
	(define (unfloat)
		(let* ((float (car (gimp-image-get-floating-sel image))))
			(cond ((>= float 0) (gimp-floating-sel-anchor float)))
		)
	)
	(define (turn layer amount)
		(set layer (car (gimp-drawable-transform-rotate-simple
				(use layer) amount 1 0 0 0)))
		(unfloat)
	)
	(define (turncw layer) (turn layer 0))
	(define (turnccw layer) (turn layer 2))
	(define (mirror layer)
		(set layer (car (gimp-drawable-transform-flip-simple
				(use layer) 0 1 0 0)))
		(unfloat)
	)
	(let* ((i 0))
		(while (< i numlayers)
			(hide i)
			(let* ((mask (car (gimp-layer-get-mask (use i)))))
				(cond ((>= mask 0) 
					(gimp-layer-remove-mask (use i) 0)
				))
			)
			(set! i (+ i 1))
		)
	)

	(show bg)
	(save "png/00_bg.png")

	(show normal)
	(save "png/01_normal.png")

	(turncw normal)
	(save "png/02_normal.png")

	(turnccw normal)
	(show rotation)
	(save "png/03_flip2.png")

	(hide bg)
	(save "png/gfpoken.png")
	(show bg)

	(turncw normal)
	(save "png/04_flip2.png")

	(hide rotation)
	(turnccw normal)
	(show collapse)
	(save "png/05_flip4.png")

	(hide collapse)
	(show expansion)
	(hide normal)
	(show block)
	(save "png/06_flip4.png")

	(hide expansion)
	(show collapse)
	(hide block)
	(show normal)
	(turncw normal)
	(turncw collapse)
	(save "png/07_flip4.png")

	(hide collapse)
	(turnccw collapse)
	(hide normal)
	(turnccw normal)
	(show expansion)
	(show block)
	(turncw expansion)
	(save "png/08_flip4.png")

	(hide expansion)
	(save "png/09_block.png")

	(show sink)
	(hide block)
	(save "png/10_sink.png")

	(hide sink)
	(show axial)
	(save "png/11_axial.png")

	(turncw axial)
	(save "png/12_axial.png")

	(turnccw axial)
	(show rotation)
	(save "png/13_axial2.png")

	(turncw axial)
	(save "png/14_axial2.png")

	(hide axial)
	(hide rotation)
	(show rotator)
	(save "png/15_rotator.png")

	(mirror rotator)
	(save "png/16_rotator.png")

	(mirror rotator)
	(show rotation)
	(save "png/17_rotator2.png")

	(mirror rotator)
	(save "png/18_rotator2.png")

	(hide rotator)
	(hide rotation)
	(show half)
	(save "png/19_half.png")

	(turncw half)
	(turncw half)
	(save "png/20_half.png")

	(turncw half)
	(save "png/21_half.png")

	(turncw half)
	(turncw half)
	(save "png/22_half.png")

	(show rotation)
	(turnccw half)
	(save "png/23_half4.png")

	(turncw half)
	(save "png/24_half4.png")

	(turncw half)
	(save "png/25_half4.png")

	(turncw half)
	(save "png/26_half4.png")

	(mirror rotation)
	(turnccw half)
	(save "png/27_half4.png")

	(turnccw half)
	(save "png/28_half4.png")

	(turnccw half)
	(save "png/29_half4.png")

	(turnccw half)
	(save "png/30_half4.png")

	(hide half)
	(show normal)
	(hide rotation)
	(show move)
	(save "png/31_move.png")

	(turncw normal)
	(save "png/32_move.png")

	(gimp-image-delete image)
)
(gimp-quit 1)
EOF

rm -r "$HOME"