forge
Explore
Log in

Don't you dare go Hollow

courier

Clone
★ 0

0 watching0 forksRustAGPL-3.05.3 MiB6d9eeb9Tahinli21 days ago3 commits

art_chars.py463 lines, 17.3 KiBHistoryRawDownload
1import math
2import os
3import sys
4
5import numpy as np
6from PIL import Image
7
8sys.path.insert(0, os.path.dirname(__file__))
9from vox import P, Model, atlas, mat, planks, project, render, save
10
11PREV = '/tmp/claude-1000/-home-tahinli-Documents-Code-Rust/edd994b8-9b3e-47f3-95c7-9404536bd326/scratchpad/chr'
12D = math.radians
13TAU = 2 * math.pi
14ANK = 3.0
15LEG = 10.5
16HIP_Y = 3.0
17ARM_U = 8.5
18ARM_F = 8.0
19N_H, NZ_H = 48, 56
20N_W, NZ_W = 60, 36
21N_C, NZ_C = 48, 36
22BOOT_A = np.array([-1.4, 0.0, -1.6])
23BOOT_B = np.array([3.2, 0.0, -1.6])
24
25n1 = None
26pl = planks()
27MAT_DEFS = {
28 'skin': ('skin', None),
29 'coal': ('coal', None),
30 'hair_gray': ('hair_gray', None),
31 'hair_brown': ('hair_brown', None),
32 'hair_black': ('hair_black', None),
33 'cloth_gray': ('cloth_gray', n1),
34 'cloth_brown': ('cloth_brown', n1),
35 'cloth_navy': ('cloth_navy', n1),
36 'cloth_cream': ('cloth_cream', n1),
37 'cloth_green': ('cloth_green', n1),
38 'cloth_wine': ('cloth_wine', n1),
39 'cloth_black': ('cloth_black', n1),
40 'plaster': ('plaster', n1),
41 'leather': ('leather', None),
42 'metal': ('metal', None),
43 'wood': ('wood', pl),
44 'wood_dark': ('wood_dark', pl),
45 'canvas': ('canvas', n1),
46 'stone': ('stone', n1),
47 'stone_dark': ('stone_dark', n1),
48}
49M = {k: mat(P[r], pt) for k, (r, pt) in MAT_DEFS.items()}
50
51
52def Rz(a):
53 c, s = math.cos(a), math.sin(a)
54 return np.array([[c, -s, 0.0], [s, c, 0.0], [0.0, 0.0, 1.0]])
55
56
57def Ry(a):
58 c, s = math.cos(a), math.sin(a)
59 return np.array([[c, 0.0, s], [0.0, 1.0, 0.0], [-s, 0.0, c]])
60
61
62class Xf:
63 def __init__(self, O=(0, 0, 0), R=None):
64 self.O = np.asarray(O, float)
65 self.R = np.eye(3) if R is None else R
66
67 def p(self, q):
68 return self.O + self.R @ np.asarray(q, float)
69
70 def at(self, O, R):
71 return Xf(self.p(O), self.R @ R)
72
73
74class Fr:
75 def __init__(self, n, nz, yaw, s=1.0):
76 self.m = Model(n, n, nz)
77 self.n = n
78 self.c = np.array([n / 2, n / 2, 0.0])
79 self.Rz = Rz(yaw)
80 self.s = s
81
82 def W(self, p):
83 return self.c + self.s * (self.Rz @ np.asarray(p, float))
84
85 def cap(self, a, b, r, m):
86 self.m.capsule(self.W(a), self.W(b), r * self.s, m)
87
88 def cyl(self, a, b, r, m):
89 self.m.cylinder(self.W(a), self.W(b), r * self.s, m)
90
91 def solid(self, xf, c, h, m, box=False):
92 ctr = self.W(xf.p(c))
93 Rw = self.Rz @ xf.R
94 h = np.asarray(h, float) * self.s
95 ext = np.abs(Rw) @ h if box else np.sqrt(((Rw * h) ** 2).sum(1))
96
97 def fn(X, Y, Z):
98 d = [X - ctr[0], Y - ctr[1], Z - ctr[2]]
99 q = [sum(Rw[i, j] * d[i] for i in range(3)) for j in range(3)]
100 if box:
101 return (abs(q[0]) <= h[0]) & (abs(q[1]) <= h[1]) & (abs(q[2]) <= h[2])
102 return sum((q[j] / h[j]) ** 2 for j in range(3)) <= 1
103
104 self.m._fill(ctr - ext, ctr + ext, fn, m)
105
106 def ell(self, xf, c, r, m):
107 self.solid(xf, c, r, m)
108
109 def box(self, xf, c, h, m):
110 self.solid(xf, c, h, m, True)
111
112
113def finish(fr, n):
114 img, _, origin = render(fr.m)
115 fx, fy = project(n / 2, n / 2, 0, origin)
116 return img, (int(round(fx)), int(round(fy)))
117
118
119def yaw_of(d):
120 a = math.radians((d - 5) * 45)
121 sx, sy = math.cos(a), math.sin(a)
122 wx, wy = (sx - 2 * sy) / 2, (-sx - 2 * sy) / 2
123 return math.atan2(wy, wx)
124
125
126def gait(ph, amp, kmax):
127 if ph is None:
128 return 0.0, 0.0
129 th = D(amp) * math.sin(ph)
130 k = D(5) + (D(kmax) - D(5)) * max(math.cos(ph), 0.0) ** 1.5
131 return th, k
132
133
134def leg_pose(hip, th, k, l):
135 a = np.array([math.sin(th), 0.0, -math.cos(th)])
136 b = np.array([math.sin(th - k), 0.0, -math.cos(th - k)])
137 knee = hip + l * a
138 ankle = knee + l * b
139 drop = l * (math.cos(th) + math.cos(th - k))
140 return knee, ankle, drop
141
142
143def ik(S, T, l1, l2, pole):
144 v = T - S
145 L = float(np.linalg.norm(v))
146 d = min(L, l1 + l2 - 1e-3)
147 u = v / L
148 a = (l1 * l1 - l2 * l2 + d * d) / (2 * d)
149 h = math.sqrt(max(l1 * l1 - a * a, 0.0))
150 perp = pole - S
151 perp = perp - (perp @ u) * u
152 perp = perp / np.linalg.norm(perp)
153 return S + a * u + h * perp
154
155
156STYLES = [
157 dict(mode='swing', amp=22, kmax=35, lean=0, arm=22, hp=0),
158 dict(mode='carry', amp=16, kmax=25, lean=-3, arm=0, hp=0),
159 dict(mode='push', amp=30, kmax=28, lean=12, arm=0, hp=0),
160]
161
162DEFAULT = dict(hair='cloth_gray', vest=None, roll=False, skirt=None, short=False,
163 coat=False, extras=(), scale=1.0, age=False, boots=True, legs='cloth_navy')
164
165LOOKS = {
166 'player': dict(head='cap', hair='cloth_gray', torso='cloth_cream', vest='cloth_brown',
167 sleeve='cloth_cream', legs='cloth_navy', extras=('satchel',)),
168 'gent': dict(head='top', hair='cloth_black', torso='cloth_black', sleeve='cloth_black',
169 legs='cloth_gray', coat=True),
170 'grocer': dict(head='bald', hair='hair_gray', torso='cloth_cream', vest='cloth_brown',
171 sleeve='cloth_cream', roll=True, legs='cloth_brown', extras=('apron',)),
172 'woman': dict(head='bonnet', torso='cloth_wine', sleeve='cloth_wine', legs='cloth_wine',
173 skirt='cloth_wine', boots=False, extras=('shawl',)),
174 'barmaid': dict(head='bun', hair='hair_brown', torso='cloth_green', sleeve='cloth_green',
175 legs='cloth_green', skirt='cloth_green', boots=False, extras=('apron',)),
176 'teacher': dict(head='hair', hair='hair_gray', torso='cloth_brown', sleeve='cloth_brown',
177 legs='cloth_gray', coat=True, extras=('spectacles',)),
178 'old': dict(head='hair', hair='hair_gray', torso='cloth_gray', sleeve='cloth_gray',
179 legs='cloth_black', coat=True, age=True),
180 'worker': dict(head='cap', hair='cloth_brown', torso='cloth_cream', vest='cloth_gray',
181 sleeve='cloth_cream', legs='cloth_brown', extras=('braces',)),
182 'miner': dict(head='helmet', hair='cloth_black', torso='cloth_black', sleeve='cloth_black',
183 legs='cloth_black', extras=('dust',)),
184 'peddler': dict(head='hair', hair='hair_black', torso='cloth_brown', sleeve='cloth_brown',
185 legs='cloth_gray', extras=('pack', 'patch')),
186 'bandit': dict(head='tricorn', hair='cloth_black', torso='cloth_black', sleeve='cloth_black',
187 legs='cloth_navy', coat=True, extras=('scarf',)),
188 'boy': dict(head='cap', hair='cloth_brown', torso='cloth_cream', sleeve='cloth_cream',
189 legs='cloth_brown', short=True, scale=0.68),
190}
191
192
193def human_skel(st, p):
194 thL, kL = gait(p, st['amp'], st['kmax'])
195 thR, kR = gait(None if p is None else p + math.pi, st['amp'], st['kmax'])
196 dL = LEG * (math.cos(thL) + math.cos(thL - kL))
197 dR = LEG * (math.cos(thR) + math.cos(thR - kR))
198 hz = ANK + max(dL, dR)
199 xf = Xf((0, 0, hz), Ry(D(st['lean'])))
200 legs = []
201 for s, th, k in ((1, thL, kL), (-1, thR, kR)):
202 hip = np.array([0.0, s * HIP_Y, hz])
203 knee, ankle, _ = leg_pose(hip, th, k, LEG)
204 legs.append((hip, knee, ankle))
205 arms = []
206 for s in (1, -1):
207 S = xf.p((0, s * 4.8, 9.5))
208 if st['mode'] == 'swing':
209 if p is None:
210 phi, e = D(2.5), D(6)
211 else:
212 phi, e = -s * D(st['arm']) * math.sin(p), D(15)
213 E = S + ARM_U * np.array([math.sin(phi), 0.0, -math.cos(phi)])
214 H = E + ARM_F * np.array([math.sin(phi + e), 0.0, -math.cos(phi + e)])
215 else:
216 if st['mode'] == 'carry':
217 H = np.array([6.0, s * 5.0, hz + 3.0])
218 else:
219 H = np.array([12.0, s * 4.0, hz + 1.0])
220 E = (S + H) / 2 + np.array([0.0, 0.0, -2.0])
221 arms.append((S, E, H))
222 return dict(hz=hz, xf=xf, legs=legs, arms=arms, p=p)
223
224
225def draw_skirt(fr, m, hz, p):
226 sx = 0.5 * math.cos(p) if p is not None else 0.0
227 sy = 0.9 * math.sin(p) if p is not None else 0.0
228 z0, z1, n = 0.8, hz - 0.5, 6
229 for i in range(n):
230 za = z0 + (z1 - z0) * i / n
231 zb = z0 + (z1 - z0) * (i + 1) / n
232 r = 7.2 - 2.9 * ((za + zb) / 2 - z0) / (z1 - z0)
233 fr.cyl((sx, sy, za), (sx, sy, zb), r, m)
234
235
236def draw_head(fr, hx, L):
237 hair = M[L['hair']]
238 kind = L['head']
239 if kind == 'cap':
240 fr.ell(hx, (-1.0, 0, 1.2), (4.3, 4.3, 1.4), hair)
241 fr.cyl(hx.p((0, 0, 2.6)), hx.p((0, 0, 5.1)), 4.6, hair)
242 fr.box(hx, (5.5, 0, 2.4), (1.5, 3.4, 0.3), hair)
243 elif kind == 'top':
244 fr.cyl(hx.p((0, 0, 3.9)), hx.p((0, 0, 4.6)), 5.2, hair)
245 fr.cyl(hx.p((0, 0, 4.5)), hx.p((0, 0, 10.5)), 3.4, hair)
246 elif kind in ('hair', 'bun'):
247 fr.ell(hx, (-0.8, 0, 0.9), (3.8, 3.8, 4.1), hair)
248 if kind == 'bun':
249 fr.ell(hx, (-3.6, 0, 0.3), (1.9, 1.9, 1.9), hair)
250 elif kind == 'bald':
251 fr.ell(hx, (-1.9, 0, 2.8), (2.2, 2.9, 1.6), hair)
252 elif kind == 'bonnet':
253 fr.ell(hx, (-1.6, 0, 0.4), (4.6, 4.6, 4.4), M['plaster'])
254 elif kind == 'helmet':
255 fr.ell(hx, (-0.3, 0, 1.2), (4.0, 3.9, 3.7), M['leather'])
256 fr.box(hx, (3.3, 0, 1.8), (1.5, 3.0, 0.3), M['leather'])
257 elif kind == 'tricorn':
258 fr.ell(hx, (0, 0, 2.8), (3.8, 3.8, 2.2), hair)
259 fr.box(hx, (0, 0, 2.0), (4.8, 4.6, 0.35), hair)
260
261
262def draw_human(fr, L, sk, st):
263 hz, xf, p = sk['hz'], sk['xf'], sk['p']
264 dress = L['skirt'] is not None
265 lg = M[L['legs']]
266 tor = M[L['torso']]
267 sl = M[L['sleeve']]
268 skin = M['skin']
269 ext = L['extras']
270 for hip, knee, ankle in sk['legs']:
271 fr.cap(hip, knee, 2.0, lg)
272 fr.cap(knee, ankle, 1.9, skin if L['short'] else lg)
273 if L['boots'] and not dress:
274 fr.cap(ankle + BOOT_A, ankle + BOOT_B, 1.4, M['leather'])
275 fr.ell(Xf((0, 0, hz)), (0, 0, 1.0), (3.4, 4.6, 2.8), M[L['skirt']] if dress else lg)
276 if dress:
277 draw_skirt(fr, M[L['skirt']], hz, p)
278 fr.ell(xf, (0, 0, 7.0), (3.6, 5.0, 7.0), tor)
279 if L['coat']:
280 fr.ell(xf, (-0.3, 0, -3.0), (3.9, 5.2, 5.8), tor)
281 if L['vest']:
282 fr.ell(xf, (0, 0, 6.8), (3.8, 5.2, 5.8), M[L['vest']])
283 if 'shawl' in ext:
284 fr.ell(xf, (0.3, 0, 11.0), (4.6, 6.9, 2.8), M['cloth_cream'])
285 if 'satchel' in ext:
286 fr.box(xf, (-0.5, 6.9, 0.8), (1.8, 1.1, 3.0), M['leather'])
287 fr.cap(xf.p((2.4, -5.8, 10.8)), xf.p((3.8, 0, 6.0)), 0.6, M['leather'])
288 fr.cap(xf.p((3.8, 0, 6.0)), xf.p((2.4, 5.8, 1.5)), 0.6, M['leather'])
289 if 'braces' in ext:
290 for s in (1, -1):
291 fr.cap(xf.p((3.0, s * 3.4, -1.0)), xf.p((0, s * 5.6, 10.8)), 0.45, M['leather'])
292 fr.cap(xf.p((0, s * 5.6, 10.8)), xf.p((-3.0, s * 3.4, -1.0)), 0.45, M['leather'])
293 if 'patch' in ext:
294 fr.box(xf, (0.5, 5.5, 3.0), (1.5, 0.4, 1.4), M['cloth_cream'])
295 fr.box(xf, (0.5, -5.2, 6.0), (1.2, 0.4, 1.2), M['cloth_gray'])
296 if 'pack' in ext:
297 fr.box(xf, (-5.6, 0, 6.5), (2.3, 4.6, 5.0), M['canvas'])
298 if 'apron' in ext:
299 fr.box(xf, (5.3 if dress else 4.4, 0, 2.5), (0.7, 4.3, 4.6), M['plaster'])
300 for S, E, H in sk['arms']:
301 fr.cap(S, E, 1.6, sl)
302 fr.cap(E, H, 1.5, skin if L['roll'] else sl)
303 fr.cap(H, H, 1.4, skin)
304 fr.cap(xf.p((0, 0, 10.0)), xf.p((0, 0, 12.6)), 1.5, skin)
305 hp = D(st['hp'])
306 hx = xf.at(np.array([0.0, 0.0, 12.0]) + Ry(hp) @ np.array([0.0, 0.0, 6.0]), Ry(hp))
307 fr.ell(hx, (0, 0, 0), (4.2, 4.2, 4.8), skin)
308 for y in (1.25, -1.25):
309 fr.box(hx, (4.1, y, -0.2), (0.45, 0.45, 0.45), M['coal'])
310 fr.box(hx, (4.3, 0, -0.9), (0.4, 0.35, 0.4), skin)
311 draw_head(fr, hx, L)
312 if 'spectacles' in ext:
313 fr.box(hx, (4.3, 1.7, 0.0), (0.3, 0.6, 0.5), M['metal'])
314 fr.box(hx, (4.3, -1.7, 0.0), (0.3, 0.6, 0.5), M['metal'])
315 fr.box(hx, (4.4, 0, 0.3), (0.25, 1.0, 0.15), M['metal'])
316 if 'dust' in ext:
317 fr.box(hx, (3.8, 2.4, -1.6), (0.5, 0.7, 0.7), M['coal'])
318 fr.box(hx, (3.8, -2.4, -1.6), (0.5, 0.7, 0.7), M['coal'])
319 if 'scarf' in ext:
320 fr.box(hx, (3.8, 0, -2.4), (1.0, 3.6, 1.2), M['cloth_wine'])
321
322
323def human_frame(look, pose, d, col):
324 L = dict(DEFAULT)
325 L.update(look)
326 st = dict(STYLES[pose])
327 if L['age']:
328 st['amp'] *= 0.7
329 st['kmax'] *= 0.8
330 st['arm'] *= 0.6
331 st['lean'] += 18
332 st['hp'] = 12
333 fr = Fr(N_H, NZ_H, yaw_of(d), L['scale'])
334 p = None if col == 0 else TAU * (col - 1) / 8
335 sk = human_skel(st, p)
336 if pose == 1:
337 fr.box(Xf(), (8.0, 0.0, sk['hz'] + 6.0), (6.0, 5.0, 4.0), M['plaster'])
338 draw_human(fr, L, sk, st)
339 return finish(fr, N_H)
340
341
342def build_human(look):
343 rows = []
344 for pose in range(3):
345 for d in range(8):
346 rows.append([human_frame(look, pose, d, c) for c in range(9)])
347 return atlas(rows)
348
349
350def wolf_frame(d, col):
351 fr = Fr(N_W, NZ_W, yaw_of(d))
352 trot = col > 0
353 p = TAU * (col - 1) / 6 if trot else None
354 phB = None if p is None else p + math.pi
355 legs_spec = [(10.0, 2.5, p), (10.0, -2.5, phB), (-10.0, 2.5, phB), (-10.0, -2.5, p)]
356 gaits = [gait(ph, 25, 40) for _, _, ph in legs_spec]
357 drops = [7.0 * (math.cos(th) + math.cos(th - k)) for th, k in gaits]
358 hz = 0.9 + max(drops)
359 zc = hz + 0.9
360 body = M['stone']
361 dark = M['stone_dark']
362 fr.ell(Xf(), (0, 0, zc), (15.0, 5.0, 5.5), body)
363 for (x, y, _), (th, k) in zip(legs_spec, gaits):
364 hip = np.array([x, y, hz])
365 knee, ankle, _ = leg_pose(hip, th, k, 7.0)
366 fr.cap(hip, knee, 1.1, body)
367 fr.cap(knee, ankle, 0.9, dark)
368 fr.cap(ankle + np.array([-0.5, 0, 0]), ankle + np.array([1.5, 0, 0]), 0.9, dark)
369 sh = -1.0 if trot else 0.0
370 fr.cap((-14.0, 0, zc + 1.0), (-18.5, 0, zc - 1.5), 2.0, body)
371 fr.cap((-18.5, 0, zc - 1.5), (-21.0, 0, zc - 3.5), 1.6, body)
372 fr.cap((12.0, 0, zc + 1.5), (15.5, 0, zc + 4.0 + sh), 2.6, body)
373 fr.ell(Xf(), (17.5, 0, zc + 4.5 + sh), (3.6, 2.7, 2.7), body)
374 fr.cap((19.5, 0, zc + 4.0 + sh), (24.5, 0, zc + 3.4 + sh), 1.3, dark)
375 for s in (1, -1):
376 fr.cap((16.5, s * 1.4, zc + 6.8 + sh), (16.0, s * 1.3, zc + 9.2 + sh), 0.8, dark)
377 fr.box(Xf(), (20.2, s * 1.4, zc + 4.6 + sh), (0.35, 0.35, 0.35), M['coal'])
378 return finish(fr, N_W)
379
380
381def wheel(fr, y, phi):
382 C = np.array([0.0, y, 10.6])
383 iron, wood = M['metal'], M['wood']
384 pts = [C + 9.2 * np.array([math.cos(TAU * k / 16), 0.0, math.sin(TAU * k / 16)]) for k in range(16)]
385 for k in range(16):
386 fr.cap(pts[k], pts[(k + 1) % 16], 0.9, iron)
387 for k in range(6):
388 t = phi + TAU * k / 6
389 u = np.array([math.cos(t), 0.0, math.sin(t)])
390 fr.cap(C + 1.5 * u, C + 8.3 * u, 0.55, wood)
391 fr.cyl(C + np.array([0.0, -1.2, 0.0]), C + np.array([0.0, 1.2, 0.0]), 1.9, iron)
392
393
394def cart_frame(d, col, loaded):
395 fr = Fr(N_C, NZ_C, yaw_of(d))
396 I = Xf()
397 wood, dark, canvas, cream = M['wood'], M['wood_dark'], M['canvas'], M['cloth_cream']
398 phi = D(15 * col)
399 for y in (-11.5, 11.5):
400 wheel(fr, y, phi)
401 fr.cyl((0, -11.5, 10.6), (0, 11.5, 10.6), 0.9, M['metal'])
402 fr.box(I, (0, 0, 15.5), (14.0, 10.0, 1.0), wood)
403 fr.box(I, (13.25, 0, 19.0), (0.75, 10.0, 3.0), wood)
404 fr.box(I, (-13.25, 0, 19.0), (0.75, 10.0, 3.0), wood)
405 for s in (-1, 1):
406 fr.box(I, (0, s * 9.25, 19.0), (13.0, 0.75, 3.0), wood)
407 fr.cap((-13.5, 3.0 * s, 17.0), (-19.0, 3.0 * s, 24.0), 0.9, wood)
408 fr.cyl((-19.0, -3.0, 24.0), (-19.0, 3.0, 24.0), 1.0, wood)
409 if not loaded:
410 fr.cyl((-6.0, -9.0, 19.0), (-6.0, 9.0, 19.0), 2.6, canvas)
411 else:
412 fr.box(I, (-5.0, -2.0, 21.0), (5.0, 4.5, 4.5), dark)
413 fr.box(I, (7.0, -3.0, 20.0), (4.0, 5.0, 3.5), canvas)
414 fr.box(I, (7.0, -3.0, 23.9), (4.2, 0.45, 0.5), cream)
415 fr.box(I, (7.0, -3.0, 23.9), (0.45, 5.2, 0.5), cream)
416 fr.box(I, (-5.0, -2.0, 27.0), (3.5, 3.5, 1.5), canvas)
417 fr.box(I, (-5.0, -2.0, 28.6), (3.6, 0.4, 0.4), cream)
418 fr.ell(I, (-9.0, 6.0, 19.5), (3.6, 3.0, 3.0), canvas)
419 return finish(fr, N_C)
420
421
422def on_bg(img):
423 bg = Image.new('RGBA', img.size, (206, 200, 186, 255))
424 bg.alpha_composite(img.convert('RGBA'))
425 return bg.convert('RGB')
426
427
428def write_sheet(name, out, cell, grid, origin):
429 save(name, out, origin, cell=cell, grid=grid, group='chars')
430 on_bg(out.resize((out.width * 3, out.height * 3), Image.NEAREST)).save(os.path.join(PREV, 'sheet_%s.png' % name))
431
432
433def main():
434 os.makedirs(PREV, exist_ok=True)
435 player = None
436 for name, look in LOOKS.items():
437 out, cell, grid, origin = build_human(look)
438 write_sheet(name, out, cell, grid, origin)
439 if name == 'player':
440 player = (out, cell)
441 out, cell, grid, origin = atlas([[wolf_frame(d, c) for c in range(7)] for d in range(8)])
442 write_sheet('wolf', out, cell, grid, origin)
443 out, cell, grid, origin = atlas([[cart_frame(d, c, ld) for c in range(4)]
444 for ld in (0, 1) for d in range(8)])
445 write_sheet('cart', out, cell, grid, origin)
446
447 out, (cw, ch) = player
448 def crop(r, c):
449 return out.crop((c * cw, r * ch, (c + 1) * cw, (r + 1) * ch))
450 walk = Image.new('RGBA', (8 * cw, 2 * ch), (0, 0, 0, 0))
451 for j, d in enumerate((3, 5)):
452 for i in range(8):
453 walk.paste(crop(d, i + 1), (i * cw, j * ch))
454 on_bg(walk.resize((walk.width * 4, walk.height * 4), Image.NEAREST)).save(os.path.join(PREV, 'walk.png'))
455 poses = Image.new('RGBA', (9 * cw, 2 * ch), (0, 0, 0, 0))
456 for j, r in enumerate((8 + 4, 16 + 4)):
457 for i in range(9):
458 poses.paste(crop(r, i), (i * cw, j * ch))
459 on_bg(poses.resize((poses.width * 4, poses.height * 4), Image.NEAREST)).save(os.path.join(PREV, 'poses.png'))
460
461
462if __name__ == '__main__':
463 main()