Переглянути джерело

add: VPU_live4.py font rotate 0,90,180,270 (output)

micha 12 годин тому
батько
коміт
7a1220cae6
1 змінених файлів з 35 додано та 6 видалено
  1. 35 6
      vpu/vpu_live4.py

+ 35 - 6
vpu/vpu_live4.py

@@ -1815,6 +1815,7 @@ def grab(x=55,y=55,w=60,h=60):
         crop = pygame.Surface((w,h))
         crop.blit(sub, (0,0))
     except ValueError as e:
+        #cprint("grab():",e,x,y,w,h,color="red")
         pass
         
     return crop
@@ -1903,6 +1904,7 @@ def read_wall_pix(init=0):
 read_wall_pix(init=1)
 
 def reshape2(GRID,GRID_OUT,_x,_y,name="GRID_Z"): 
+    global W_ANG
     _w = 16
     _h = 16
     from_x_min = INPUT_START_POS_X 
@@ -1942,11 +1944,18 @@ def reshape2(GRID,GRID_OUT,_x,_y,name="GRID_Z"):
                 ang = 180
             elif _a > 180 and _a <= 270:
                 ang = 270
-            target_x=40+(_wall[4]-1)*_w
-            target_y=60+(_wall[5]-1)*_h
+            x_k = _wall[4]
+            y_k = _wall[5]
+            target_x=40+(x_k-1)*_w
+            target_y=60+(y_k-1)*_h
             sub = grab(from_x,from_y,_w,_h)
+            key="{}:{}".format(x_k,y_k)
+
+            W_ANG[key] = ang
+            
 
             if sub:
+                #sub = grab(from_x,from_y,_w,_h)
                 sub = pygame.transform.rotate(sub,ang)
                 window.blit(sub,(target_x,target_y))
         except Exception as e:
@@ -1965,7 +1974,7 @@ def reload_grid():
     except Exception as e:
         cprint("Except: grid re init",e,color="red")
 
-
+W_ANG = {}
 def draw_kachel_nr(): #GRID,_x=0,_y=0):
     if not NR:
         return
@@ -1977,10 +1986,27 @@ def draw_kachel_nr(): #GRID,_x=0,_y=0):
         OUT_COUNT = len(CFG_OUT)
 
         for j in range(8*OUT_COUNT): # COLUMS / SPALTEN | |
-            pygame.draw.rect(window,[10,20,10],[40+_x+2,60+_y+2,14,9]) #background
+            #pygame.draw.rect(window,[10,20,10],[40+_x+2,60+_y+2,14,9]) #background
+            pygame.draw.rect(window,[10,20,10],[6,6,14,9]) #background
             _j=j 
-            fr = font12.render("{}:{}".format(_j+1,i+1) ,1, (200,200,55))
-            window.blit(fr,(40+_x+2,60+_y+2))
+            key="{}:{}".format(_j+1,i+1) 
+            fr = font12.render(key,1, (200,200,55))
+            window.blit(fr,(6,6))
+            #window.blit(fr,(40+_x+2,60+_y+2))
+
+            ang = W_ANG.get(key,0)
+            sub = grab(6,6,14,9)
+            if sub: # rotate nr label
+                sub = pygame.transform.rotate(sub,ang)
+                if ang == 270: # pos compensation
+                    window.blit(sub,(40+_x+6,60+_y+1))
+                elif ang == 180:# pos compensation
+                    window.blit(sub,(40+_x+1,60+_y+6))
+                else:
+                    window.blit(sub,(40+_x+1,60+_y+1))
+
+            #if ang != 0:
+            #    print("W_ANG",key,ang)
             _x+=16 # pix
         _y +=16 # pix
 
@@ -2114,6 +2140,9 @@ def draw_all_video(VIDEO):
         if k in count:
             #video1.select_video(count[k])
 
+            if type(count[k]) is str:
+                cprint("ERR count[k] is str not int !")
+                continue
             play_nr = int(count[k]/10)
             if play_nr != video1._media_nr:
                 print( "+ + + +  + + + + + + +", play_nr , video1._media_nr ,str(video1))