-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageGen.py
More file actions
61 lines (43 loc) · 2.05 KB
/
Copy pathImageGen.py
File metadata and controls
61 lines (43 loc) · 2.05 KB
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
import PIL
from PIL import Image, ImageOps
import CompleteMaterializer
from parameters.StyleGuides import complete_style_guide as csg
class ImageGen:
def __init__(self, city, art_style):
self.city = city
self.art_style = art_style
self.cm = CompleteMaterializer.CompleteMaterializer(city, art_style)
# NONE ASSIGNS FOR LATER
self.MAP_topological = None
self.background_color = None
self.IMG_background = None
self.IMG_final = None
self.IMG_render = None
self.background()
self.generate()
self.render()
self.post_process()
self.metadata()
def background(self):
background_name = csg.art_style_guide[self.art_style]['background']
self.background_color = csg.palette_style_guide[background_name]
self.IMG_background = PIL.Image.new('RGBA', (csg.xs, csg.ys), self.background_color)
def generate(self):
self.cm.generator.generate()
self.MAP_topological = self.cm.generator.return_map()
def render(self):
self.cm.renderer.render(self.MAP_topological)
self.IMG_render = self.cm.renderer.return_img()
def post_process(self):
self.IMG_background.paste(self.IMG_render, mask=self.IMG_render)
self.IMG_final = self.IMG_background.resize((csg.x, csg.y), resample=PIL.Image.ANTIALIAS)
if self.art_style == 'Signature':
roundel, empty = PIL.Image.open("color_lib/withoutText.png").resize((csg.x, csg.y)), PIL.Image.new('RGBA', (csg.x, csg.y), (0, 0, 0, 0))
empty.paste(roundel, mask=ImageOps.invert(self.IMG_final.convert("L")))
self.IMG_final.paste(roundel, mask=empty)
def metadata(self):
self.cm.metadata.add_art_attributes(art_style=self.art_style)
self.cm.metadata.add_gen_attributes(num_stations=self.cm.generator.get_station_count(),
num_interchanges=self.cm.generator.get_interchange_count())
def ex_nihilo_res(self):
return self.IMG_final, self.cm.metadata.meta_dict