Skip to content
Snippets Groups Projects
Commit 4b237b35 authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

rendering landscape

parent 14d8d966
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,7 @@ class GraphicsLayer(object): ...@@ -68,7 +68,7 @@ class GraphicsLayer(object):
def get_cmap(self, *args, **kwargs): def get_cmap(self, *args, **kwargs):
return plt.get_cmap(*args, **kwargs) return plt.get_cmap(*args, **kwargs)
def setRailAt(self, row, col, binTrans, iTarget=None, isSelected=False): def setRailAt(self, row, col, binTrans, iTarget=None, isSelected=False, rail_grid=None):
""" Set the rail at cell (row, col) to have transitions binTrans. """ Set the rail at cell (row, col) to have transitions binTrans.
The target argument can contain the index of the agent to indicate The target argument can contain the index of the agent to indicate
that agent's target is at that cell, so that a station can be that agent's target is at that cell, so that a station can be
......
...@@ -316,12 +316,18 @@ class PILSVG(PILGL): ...@@ -316,12 +316,18 @@ class PILSVG(PILGL):
"Scenery/Laubbaume_C.svg", "Scenery/Laubbaume_C.svg",
"Scenery/Nadelbaume_A.svg", "Scenery/Nadelbaume_A.svg",
"Scenery/Nadelbaume_B.svg", "Scenery/Nadelbaume_B.svg",
"Scenery/Bergwelt_B.svg", "Scenery/Bergwelt_B.svg"
# "Scenery/Bergwelt_C_Teil_1_links.svg", ]
# "Scenery/Bergwelt_C_Teil_2_rechts.svg",
# "Scenery/Bergwelt_A_Teil_1_links.svg", dSceneryFilesDim2 = [
# "Scenery/Bergwelt_A_Teil_2_mitte.svg", "Scenery/Bergwelt_C_Teil_1_links.svg",
# "Scenery/Bergwelt_A_Teil_3_rechts.svg", "Scenery/Bergwelt_C_Teil_2_rechts.svg"
]
dSceneryFilesDim3 = [
"Scenery/Bergwelt_A_Teil_3_rechts.svg",
"Scenery/Bergwelt_A_Teil_2_mitte.svg",
"Scenery/Bergwelt_A_Teil_1_links.svg"
] ]
imgBg = self.pilFromSvgFile('svg', "Background_Light_green.svg") imgBg = self.pilFromSvgFile('svg', "Background_Light_green.svg")
...@@ -332,6 +338,18 @@ class PILSVG(PILGL): ...@@ -332,6 +338,18 @@ class PILSVG(PILGL):
img = Image.alpha_composite(imgBg, img) img = Image.alpha_composite(imgBg, img)
self.dScenery.append(img) self.dScenery.append(img)
self.dSceneryDim2 = []
for sFile in dSceneryFilesDim2:
img = self.pilFromSvgFile('svg', sFile)
img = Image.alpha_composite(imgBg, img)
self.dSceneryDim2.append(img)
self.dSceneryDim3 = []
for sFile in dSceneryFilesDim3:
img = self.pilFromSvgFile('svg', sFile)
img = Image.alpha_composite(imgBg, img)
self.dSceneryDim3.append(img)
def loadRailSVGs(self): def loadRailSVGs(self):
""" Load the rail SVG images, apply rotations, and store as PIL images. """ Load the rail SVG images, apply rotations, and store as PIL images.
""" """
...@@ -437,7 +455,7 @@ class PILSVG(PILGL): ...@@ -437,7 +455,7 @@ class PILSVG(PILGL):
return dPil return dPil
def setRailAt(self, row, col, binTrans, iTarget=None, isSelected=False): def setRailAt(self, row, col, binTrans, iTarget=None, isSelected=False, rail_grid=None):
if binTrans in self.dPilRail: if binTrans in self.dPilRail:
pilTrack = self.dPilRail[binTrans] pilTrack = self.dPilRail[binTrans]
if iTarget is not None: if iTarget is not None:
...@@ -447,18 +465,18 @@ class PILSVG(PILGL): ...@@ -447,18 +465,18 @@ class PILSVG(PILGL):
if self.background_grid[col][row] < 4: if self.background_grid[col][row] < 4:
a = int(self.background_grid[col][row]) a = int(self.background_grid[col][row])
a = a % len(self.dBuildings) a = a % len(self.dBuildings)
if (col + row) % 10 > 7: if (col + row + col * row) % 13 > 11:
pilTrack = self.dScenery[0] pilTrack = self.dScenery[a % len(self.dScenery)]
else: else:
if (col + row + col * row) % 3 == 0: if (col + row + col * row) % 3 == 0:
a = (a + (col + row + col * row)) % len(self.dBuildings) a = (a + (col + row + col * row)) % len(self.dBuildings)
pilTrack = self.dBuildings[a] pilTrack = self.dBuildings[a]
elif (self.background_grid[col][row] > 4) or ((col ** 3 + row ** 2 + col * row) % 10 == 0): elif (self.background_grid[col][row] > 4) or ((col ** 3 + row ** 2 + col * row) % 10 == 0):
a = int(self.background_grid[col][row]) - 4 a = int(self.background_grid[col][row]) - 4
a = (a + (col + row + col * row + col ** 3 + row ** 4)) % len(self.dScenery) a2 = (a + (col + row + col * row + col ** 3 + row ** 4))
if (col + row + col * row) % 10 > 2: if a2 % 17 > 11:
a = 0 a = a2
pilTrack = self.dScenery[a] pilTrack = self.dScenery[a % len(self.dScenery)]
self.drawImageRC(pilTrack, (row, col)) self.drawImageRC(pilTrack, (row, col))
else: else:
......
...@@ -655,7 +655,7 @@ class RenderTool(object): ...@@ -655,7 +655,7 @@ class RenderTool(object):
target = None target = None
isSelected = False isSelected = False
self.gl.setRailAt(r, c, binTrans, iTarget=target, isSelected=isSelected) self.gl.setRailAt(r, c, binTrans, iTarget=target, isSelected=isSelected, rail_grid=env.rail.grid)
self.gl.build_background_map(dTargets) self.gl.build_background_map(dTargets)
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "3b19147d4ed04d7ea0fdeff8acea20a6", "model_id": "b9ba3ece379e463184ad5217c1f4c289",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
......
File added
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment