-
Notifications
You must be signed in to change notification settings - Fork 3
/
example-square.py
executable file
·62 lines (47 loc) · 1.67 KB
/
example-square.py
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
#!/usr/bin/env python3
from TDS import *
from sys import argv
# Simple example that takes a number from the
# command line and creates a tileset to produce a square
# of that size
# Usage: ./example-square 20
# Handle command line input
if argv.__len__() == 1:
square_len = 10
elif argv.__len__() == 2:
square_len = int(argv[1])
else:
print("Invalid command line arguments")
exit(1)
# Create TAS
tas = TAS()
# "Constants"
dead_glue = Glue("", 0)
blank_tile = Tile("Fill Tile", [255, 255, 255])
# Create side glues
glue_parent = Glue("Side", 2)
glues = []
for index in range(square_len):
glues.append(glue_parent.create_child("_" + str(index)))
seed_tile = Tile.create_compass("Seed", [255, 0, 0],
northGlue=glues[0],
eastGlue=glues[0],
southGlue=dead_glue,
westGlue=dead_glue)
# Create side and bottom tiles
side_tiles = []
bottom_tiles = []
for index in range(1, square_len):
side_tiles.append(seed_tile.create_child("-side-" + str(index),
northGlue=blank_glue,
eastGlue=glues[index],
westGlue=glues[index - 1]))
# Bottom tiles are just side tiles but rotated clockwise 90
# and flipped, so create it as such
bottom_tiles.append(side_tiles[index - 1].rotate(1).vert_flip(inPlace=False))
# Add tiles to TAS
for tile in side_tiles + bottom_tiles + [seed_tile]:
tas.addTile(tile)
tas.addTile(blank_tile, "fill")
# Write out the resultant assembly to a file
tas.printToFile("example-square.tds")