Make more tweaks

Best commit message. Ever.
master
LEdoian 3 years ago
parent 4fca06fcdf
commit 2ee3fd0ba0

@ -13,17 +13,28 @@ colors = {
BORDERCOLOR = (64,64,64)
W = 1900
H = 1000
CELLSIZE = 7
CELLBORDER = 1
CELLMARGIN = 1
W = 1920
H = 1080
CELLSIZE = 4
CELLBORDER = 0
CELLMARGIN = 2
CELLOFFSET = CELLSIZE + 2*CELLBORDER + CELLMARGIN
COLUMNS = W // CELLOFFSET
ROWS = H // CELLOFFSET
CELLS = COLUMNS * ROWS
def get_symb(hist):
## Majority:
#symb, _count = max(hist.items(), key=lambda x: x[1])
#return symb
# The worst:
order = ['-', '/', '*', '?', '+']
for ch in order:
if ch in hist:
return ch
class Visualisation:
def __init__(self, fn):
pygame.init()
@ -40,9 +51,8 @@ class Visualisation:
for cid in range(CELLS):
start = cid * sqsz
end = (cid + 1) * sqsz
hist = self.mapfile.get_hist(start, end).items()
# Majority
symb, _count = max(hist, key=lambda x: x[1])
hist = self.mapfile.get_hist(start, end)
symb = get_symb(hist)
color = colors[symb]
line = cid // COLUMNS
@ -51,6 +61,10 @@ class Visualisation:
rect = pygame.Rect(col * CELLOFFSET + CELLBORDER, line * CELLOFFSET + CELLBORDER, CELLSIZE+2*CELLBORDER, CELLSIZE+2*CELLBORDER)
pygame.draw.rect(self.disp, color, rect)
pygame.draw.rect(self.disp, BORDERCOLOR, rect, width=CELLBORDER)
if CELLBORDER != 0: pygame.draw.rect(self.disp, BORDERCOLOR, rect, width=CELLBORDER)
pygame.display.flip()
def reload(self):
self.mapfile.load()
self.draw()

@ -1,9 +1,13 @@
#!/bin/python3
import ddresc_visu.draw as v
from time import sleep
visu = v.Visualisation('/mnt/TAP9701/2021-08-11_Pm_ddresc_mapfile')
FILE = '/mnt/TAP9701/2021-08-11_Pm_ddresc_mapfile'
visu = v.Visualisation(FILE)
visu.draw()
def redraw():
visu.reload()
import time
time.sleep(10)
while True:
redraw()
sleep(5)

Loading…
Cancel
Save