SHOW:
|
|
- or go back to the newest paste.
1 | from feature_server.scripts.avx import AVX | |
2 | import json | |
3 | from pyspades.common import make_color | |
4 | ||
5 | def rotate_all(dct, fm, to): | |
6 | amt = (to - fm) % 4 | |
7 | if amt == 0: | |
8 | rot = lambda t: t | |
9 | elif amt == 1: | |
10 | rot = lambda t: (-t[1], t[0]) + t[2:] | |
11 | elif amt == 2: | |
12 | rot = lambda t: (-t[0], -t[1]) + t[2:] | |
13 | elif amt == 3: | |
14 | rot = lambda t: ( t[1], -t[0]) + t[2:] | |
15 | if isinstance(dct, dict): | |
16 | dct = dct.iteritems() | |
17 | for k,v in dct: | |
18 | yield rot(k), v | |
19 | ||
20 | def shift_origin(dct, new_origin): | |
21 | new_origin = tuple(new_origin) | |
22 | shift = lambda tpl: tuple(a-b for a,b in zip(tpl, new_origin)) | |
23 | if isinstance(dct, dict): | |
24 | dct = dct.iteritems() | |
25 | for k,v in dct: | |
26 | yield shift(k), v | |
27 | ||
28 | def build(px, py, structure, default_color): | |
29 | if isinstance(structure, dict): | |
30 | structure = structure.iteritems() | |
31 | pz = int(hmap.get(px,py)*63) | |
32 | for xyz, color in structure: | |
33 | x, y, z = xyz | |
34 | x, y, z = x + px, y + py, z + pz | |
35 | - | vxl.set_point(x, y, z, color or default_color) |
35 | + | vxl.set_point(x, y, z, make_color(*(color or default_color))) |
36 | - | #if color is none, use default_color |
36 | + | |
37 | penis_settings = json.load(open('./qb/penis.avx.txt', 'r')) | |
38 | penis = AVX.fromfile('./qb/penis.avx').tosparsedict() | |
39 | penis = dict(shift_origin(penis, penis_settings['origin'])) | |
40 | ||
41 | for x in xrange(0, bmap.width): | |
42 | for y in xrange(0, bmap.height): | |
43 | if bmap.get_repeat(x, y) is hill_biome: | |
44 | left, top, right, bottom = bmap.rect_of_point(x,y) | |
45 | for ct in xrange(random.randint(1,3)): | |
46 | build(random.randint(left,right) | |
47 | , random.randint(top,bottom) | |
48 | , rotate_all(penis, 0, random.randint(0,3)) #rotate it different every time | |
49 | , (255,0,216)) |