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

performance opt. speedup

parent 4b237b35
No related branches found
No related tags found
No related merge requests found
......@@ -79,19 +79,38 @@ class PILGL(GraphicsLayer):
self.window_root = None
self.window_open = False
self.firstFrame = True
self.old_background_image = (None, None, None)
self.create_layers()
def build_background_map(self, dTargets):
self.background_grid = np.zeros(shape=(self.width, self.height))
for x in range(self.width):
for y in range(self.height):
distance = int(np.ceil(np.sqrt(self.width ** 2.0 + self.height ** 2.0)))
for rc in dTargets:
r = rc[1]
c = rc[0]
d = int(np.floor(np.sqrt((x - r) ** 2 + (y - c) ** 2)))
distance = min(d, distance)
self.background_grid[x][y] = distance
x = self.old_background_image
rebuild = False
if x[0] is None:
rebuild = True
else:
if len(x[0]) != len(dTargets):
rebuild = True
else:
if x[0] != dTargets:
rebuild = True
if x[1] != self.width:
rebuild = True
if x[2] != self.height:
rebuild = True
if rebuild:
self.background_grid = np.zeros(shape=(self.width, self.height))
for x in range(self.width):
for y in range(self.height):
distance = int(np.ceil(np.sqrt(self.width ** 2.0 + self.height ** 2.0)))
for rc in dTargets:
r = rc[1]
c = rc[0]
d = int(np.floor(np.sqrt((x - r) ** 2 + (y - c) ** 2)))
distance = min(d, distance)
self.background_grid[x][y] = distance
self.old_background_image = (dTargets, self.width, self.height)
def rgb_s2i(self, sRGB):
""" convert a hex RGB string like 0091ea to 3-tuple of ints """
......
......@@ -70,7 +70,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b9ba3ece379e463184ad5217c1f4c289",
"model_id": "9d466178f2f04a33b5589de583a565b7",
"version_major": 2,
"version_minor": 0
},
......
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