def draw(self): self.bg = DISPLAY.subsurface(self).copy() clipxy = DISPLAY.get_clip() DISPLAY.set_clip(self) gfxdraw.box(DISPLAY,self,BGCOLOR) x,y = self.itemsrect.topleft if self.index != None and not (1 << self.index)&self._exc: gfxdraw.box(DISPLAY,self.hlRect,BGHIGHTLIGHT) gfxdraw.rectangle(DISPLAY,self.hlRect,BORDER_HL) x += self.lineheight/3 for idx,item in enumerate(self.itemslist): isExc = (1 << idx)&self._exc isStr = isinstance(item,str) text = FONT.render(item if isStr else item.label,1,FGLOWLIGHT if isExc else FGCOLOR) if not isStr: self.arrowRect.topright = self.itemsrect.right-self.lineheight/3,y DISPLAY.blit(FONT.render(Arrow,1,FGLOWLIGHT if isExc else FGCOLOR),self.arrowRect) r = DISPLAY.blit(text,(x,y)) y += self.lineheight gfxdraw.vline(DISPLAY,self.left,self.top,self.bottom-1,BORDER_LEFT) gfxdraw.hline(DISPLAY,self.left,self.right-1,self.top,BORDER_LEFT) gfxdraw.vline(DISPLAY,self.right-1,self.top+1,self.bottom-1,BORDER_RIGHT) gfxdraw.hline(DISPLAY,self.left+1,self.right-1,self.bottom-1,BORDER_RIGHT) DISPLAY.set_clip(clipxy) return self
def _update_left_menu(self, epoch, timestep, rewards): self.left_menu = pygame.Surface(self.left_menu_shape, pygame.SRCALPHA, 32).convert_alpha() # Top info about epoch and timestep self.left_menu.blit(self.text_render('Epoch'), (30, 10)) self.left_menu.blit(self.text_render('Timestep'), (150, 10)) self.left_menu.blit(self.value_render(str(epoch)), (100, 10)) self.left_menu.blit(self.value_render(str(timestep)), (250, 10)) # Last reward surface #last_rewards_surface = self.draw_surface_rewards(rewards) # Loads curve surface loads_curve_surface = self.draw_surface_loads_curves() # Relative thermal limits curves rtl_curves_surface = self.draw_surface_relative_thermal_limits() # Number of overflowed lines curves n_overflows_surface = self.draw_surface_n_overflows() gfxdraw.vline(self.left_menu, self.left_menu_shape[0] - 1, 0, self.left_menu_shape[1], (128, 128, 128)) #self.left_menu.blit(last_rewards_surface, (0, 50)) self.left_menu.blit(loads_curve_surface, (0, 50)) self.left_menu.blit(rtl_curves_surface, (0, 380)) self.left_menu.blit(n_overflows_surface, (0, 560))
def draw_world_borders(): top = int((c.world.top_left[0] - c.player.center[1])*zoom + screensize[1]/2) left = int((c.world.top_left[1] - c.player.center[0])*zoom + screensize[0]/2) bottom = int((c.world.bottom_right[0] - c.player.center[1])*zoom + screensize[1]/2) right = int((c.world.bottom_right[1] - c.player.center[0])*zoom + screensize[0]/2) if (top >= 0): gfxdraw.hline(screen, 0, screensize[0], top, (0,0,0)) if (bottom <= screensize[1]): gfxdraw.hline(screen, 0, screensize[0], bottom, (0,0,0)) if (left >= 0): gfxdraw.vline(screen, left, 0, screensize[1], (0,0,0)) if (right <= screensize[0]): gfxdraw.vline(screen, right, 0, screensize[1], (0,0,0))
def draw(self): DISPLAY.blit(self.bg,self.rect) gfxdraw.box(DISPLAY,self.rect,BGCOLOR) gfxdraw.vline(DISPLAY,self.rect.left,self.rect.top,self.rect.bottom-1,BORDER_LEFT) gfxdraw.hline(DISPLAY,self.rect.left,self.rect.right-1,self.rect.top,BORDER_LEFT) gfxdraw.vline(DISPLAY,self.rect.right-1,self.rect.top+1,self.rect.bottom-1,BORDER_RIGHT) gfxdraw.hline(DISPLAY,self.rect.left+1,self.rect.right-1,self.rect.bottom-1,BORDER_RIGHT) x = self.rect.x + self.lineheigth/3 if self.index > -1: gfxdraw.box(DISPLAY,self.rects[self.index].inflate(-2,-2),BGHIGHTLIGHT) for item in self.menuboxlist: x = DISPLAY.blit(FONT.render(item.label,1,FGCOLOR),(x,self.rect.y)).right+self.lineheigth return self.rect
def draw(self): DISPLAY.blit(self.bg,self.rect) gfxdraw.box(DISPLAY,self.rect,BGCOLOR) gfxdraw.vline(DISPLAY,self.rect.left,self.rect.top,self.rect.bottom-1,BORDER_LEFT) gfxdraw.hline(DISPLAY,self.rect.left,self.rect.right-1,self.rect.top,BORDER_LEFT) gfxdraw.vline(DISPLAY,self.rect.right-1,self.rect.top+1,self.rect.bottom-1,BORDER_RIGHT) gfxdraw.hline(DISPLAY,self.rect.left+1,self.rect.right-1,self.rect.bottom-1,BORDER_RIGHT) x = self.rect.x + self.lineheigth/3 if self.mouse_in or self: gfxdraw.box(DISPLAY,self.rect.inflate(-2,-2),BGHIGHTLIGHT) clipxy = DISPLAY.get_clip() DISPLAY.set_clip(self.rect.inflate(-self.lineheigth/3*2,-2)) DISPLAY.blit(FONT.render(self.menu.label,1,FGCOLOR),(x,self.rect.y)) DISPLAY.set_clip(clipxy) return self.rect
def draw(bgcolor,fgcolor,topleftcolor,bottomrightcolor): gfxdraw.box(DISPLAY,self,bgcolor) gfxdraw.vline(DISPLAY,self.left,self.top,self.bottom-1,topleftcolor) gfxdraw.hline(DISPLAY,self.left,self.right-1,self.top,topleftcolor) gfxdraw.vline(DISPLAY,self.right-1,self.top+1,self.bottom-1,bottomrightcolor) gfxdraw.hline(DISPLAY,self.left+1,self.right-1,self.bottom-1,bottomrightcolor) clipxy = DISPLAY.get_clip() DISPLAY.set_clip(self.inflate(-2,-2)) if self.type == SWITCH: label = FONT.render(self.label if not self.switch else self.switchlabel,1,fgcolor) else: label = FONT.render(self.label,1,fgcolor) DISPLAY.blit(label,label.get_rect(center=self.center)) DISPLAY.set_clip(clipxy)
def drawScoreboard(self): # Frame gfxdraw.vline(self.renderSurface, viewConst.GameSize[0], 0, viewConst.GameSize[1], viewConst.sbColor) for i in range(1, modelConst.PlayerNum): gfxdraw.hline(self.renderSurface, viewConst.GameSize[0], viewConst.ScreenSize[0], viewConst.GameSize[1] // modelConst.PlayerNum * i, viewConst.sbColor) # Team Names pos = [(viewConst.GameSize[0] + viewConst.GameSize[1] // modelConst.PlayerNum, viewConst.GameSize[1] // modelConst.PlayerNum * i + viewConst.GameSize[1] // (modelConst.PlayerNum * 8)) for i in range(modelConst.PlayerNum)] for i, player in enumerate(self.model.player_list): color = viewConst.aliveTeamColor if player.is_alive else viewConst.deadTeamColor teamName = self.teamNameFont.render(player.name, True, color) self.renderSurface.blit(teamName, pos[i]) # Team Scores pos = [(x, y + viewConst.GameSize[1] // 32) for x, y in pos] for i, player in enumerate(self.model.player_list): color = viewConst.Color_Black teamScore = self.teamScoreFont.render( str(self.model.score_list[player.index]), True, color) self.renderSurface.blit(teamScore, pos[i]) # Team Balls pos = [(viewConst.GameSize[0] + viewConst.GameSize[1] // (modelConst.PlayerNum * 2), viewConst.GameSize[1] // (modelConst.PlayerNum * 2) * i) for i in range(1, modelConst.PlayerNum * 2, 2)] radius = int(viewConst.GameSize[1] // (modelConst.PlayerNum * 2) * 0.7) for i, player in enumerate(self.model.player_list): if self.model.have_scoreboard[i]: ballPos = tuple([ x + random.randint(-5, 5) for x in pos[i] ]) if self.model.bombtimer[i] != -1 else pos[i] if self.model.bombtimer[i] == modelConst.bombtime - 1: self.vibrationSound.play() gfxdraw.filled_circle(self.renderSurface, *ballPos, radius, player.color) # Team Player Lengths for i, player in enumerate(self.model.player_list): length = str(len(player.body_list)) if player.is_alive else '0' color = viewConst.teamLengthColor if self.model.have_scoreboard[ i] else viewConst.Color_Black teamLength = self.teamLengthFont.render(length, True, color) self.blit_at_center(self.renderSurface, teamLength, pos[i])
def drawRoundRect(surface, x, y, width, height, bevelsize, color): gfxdraw.hline(surface, x + bevelsize, (x + width) - bevelsize, y, color) gfxdraw.hline(surface, x + bevelsize, (x + width) - bevelsize, y + height, color) gfxdraw.vline(surface, x, y + bevelsize, (y + height) - bevelsize, color) gfxdraw.vline(surface, x + width, y + bevelsize, (y + height) - bevelsize, color) gfxdraw.arc(surface, x + bevelsize, y + bevelsize, bevelsize, 180, 270, color) gfxdraw.arc(surface, x + width - bevelsize, y + bevelsize, bevelsize, 270, 360, color) gfxdraw.arc(surface, x + bevelsize, y + height - bevelsize, bevelsize, 90, 180, color) gfxdraw.arc(surface, x + width - bevelsize, y + height - bevelsize, bevelsize, 0, 90, color)
def draw_man(i): if i == 1: draw.vline(scr, 500, 350, 450, (255, 255, 255)) elif i == 2: draw.aacircle(scr, 500, 320, 20, (255, 255, 255)) elif i == 3: draw.hline(scr, 490, 450, 380, (255, 255, 255)) elif i == 4: draw.hline(scr, 510, 550, 380, (255, 255, 255)) elif i == 5: draw.line(scr, 490, 450, 460, 500, (255, 255, 255)) elif i == 6: draw.line(scr, 510, 450, 540, 500, (255, 255, 255)) py.display.update() return
def render(self): scr = pygame.display.get_surface() res = self.app.config['screen'] if self.bg: gfxdraw.box(scr, ((0, 0), res), self.bg) x = (self.x + self.app.context.offset_x) % self.size y = (self.y + self.app.context.offset_y) % self.size while x < res[0]: gfxdraw.vline(scr, x, 0, res[1], self.fg) x += self.size while y < res[1]: gfxdraw.hline(scr, 0, res[0], y, self.fg) y += self.size
def getSurface(self, trim=True): SCREEN = pygame.Surface((self.width, 2*self.amplitude)) poly = pygame.Surface((self.width, self.amplitude)) points = self.amplitude * self.points if trim: points += np.ones_like(self.points) points *= self.get_gaussian(self.width / 2., 1, 4 / self.width)(np.arange(self.width)) for x in range(self.width): y = points[x] gfxdraw.pixel(poly, x, int(y), self.color + (int(255 * (y - int(y))),)) if y >= 1: gfxdraw.vline(poly, x, 0, int(y) - 1, self.color + (255,)) SCREEN.blit(pygame.transform.flip(poly, False, True), (0, 0)) SCREEN.blit(poly, (0, self.amplitude)) return SCREEN
def drawStars(self): for s in self.stars: gfxdraw.vline(screen,s[0], s[1] - 2 - self.starExt, s[1] + 2 + self.starExt, (220,220,220)) gfxdraw.hline(screen, s[0] - 2 - self.starExt, s[0] + 2 + self.starExt, s[1], (220,220,220)) gfxdraw.filled_circle(screen,s[0],s[1],1+self.starExt,(255,255,255)) self.starFrame += 1 if self.starFrame > 10: self.starFrame = 0 if self.starFrame > 5: self.starExt = 1 else: self.starExt = 0
def _update_topology(self, scenario_id, date, relative_thermal_limits, lines_por, lines_service_status, prods, loads, rewards, are_substations_changed, game_over): self.topology_layout = pygame.Surface(self.topology_layout_shape, pygame.SRCALPHA, 32).convert_alpha() self.nodes_surface = pygame.Surface(self.topology_layout_shape, pygame.SRCALPHA, 32).convert_alpha() self.injections_surface = pygame.Surface(self.topology_layout_shape, pygame.SRCALPHA, 32).convert_alpha() self.lines_surface = pygame.Surface(self.topology_layout_shape, pygame.SRCALPHA, 32).convert_alpha() gfxdraw.vline(self.topology_layout, 0, 0, self.left_menu_shape[1], (20, 20, 20)) # Lines self.draw_surface_lines(relative_thermal_limits, lines_por, lines_service_status) lines_surf = self.draw_surface_lines2(relative_thermal_limits, lines_por, lines_service_status) self.topology_layout.blit(lines_surf, (0, 0)) arrow_surf = self.draw_surface_arrows(relative_thermal_limits, lines_por, lines_service_status) self.topology_layout.blit(arrow_surf, (0, 0)) # Injections if rewards is not None: last_rewards_surface = self.draw_surface_rewards(rewards) self.last_rewards_surface = last_rewards_surface # Legend #legend_surface = self.draw_surface_legend() # Nodes self.draw_surface_nodes(scenario_id, date, prods, loads, are_substations_changed, cascading_result_frame=rewards is not None) #self.topology_layout.blit(self.lines_surface, (0, 0)) self.topology_layout.blit(self.last_rewards_surface, (600, 1) if self.grid_case != 14 else (690, 50)) #self.topology_layout.blit(legend_surface, (1, 470)) self.topology_layout.blit(self.nodes_surface, (0, 0)) # Print a game over message if game has been lost if game_over: game_over_surface = self.draw_plot_game_over() self.topology_layout.blit(game_over_surface, (300, 200))
def vline(self, x, y1, y2, color): """y軸に平行な直線を描画します. Parameters ---------- x : int 直線のx座標. y1 : int 直線の始点のy座標. y2 : int 直線の終点のy座標. color : tuple of int 描画に使用される色を指定します. """ return gfx.vline(self.pg.screen, x, y1, y2, color)
def draw_compases(self): """ Dibuja las lineas divisorias de los compases """ # posicion del eje x del primer compas pos_x = 420 # tamanho de la barra del compas tam = 64 pos_y = 82 # desplazamiento hacia abajo desp_y = 176 # primeras lineas dibujar.vline(self.screen, 50, pos_y, 322, Color.BLACK) for i in range(4): dibujar.vline(self.screen, pos_x + i * 210, pos_y, pos_y + desp_y + tam, Color.BLACK) pos_y = 418 for i in range(3): dibujar.vline(self.screen, pos_x + i * 210, pos_y, pos_y + desp_y + tam, Color.BLACK) dibujar.vline(self.screen, 50, pos_y, 656, Color.BLACK) # rayas finales dibujar.vline(self.screen, pos_x + 3 * 208, pos_y, pos_y + desp_y + tam, Color.BLACK) for i in range(4): dibujar.vline(self.screen, pos_x + 3 * 210 + i, pos_y, pos_y + desp_y + tam, Color.BLACK)
def pantalla_refresh(sf): global pts,mpts global xbw,xdev global fq,fqc,bw global modelabel,bwlabel,fqlabel1,fqlabel2 global ftqc, numx global maxfill_enable, maxpts_enable, refreshfq global azoom, base global fft_sf,top_sf global sq,xsq,asq,smval,smvaladj,possq,sqstate global frame, count global menusf, stereosf a = FFTANCHO/2 # media pantalla pleft = fqlabel1.get_size()[0]/2 + fqlabel2.get_size()[0]/2 fft_sf.fill(BGCOLOR) # Borra BW Más rapido que reescribir. # PINTA ESCALA for x in range(12): # Escala FFT y = int(FFTALTO - (x*(FFTALTO/12))*azoom) + base if y > 0 : pgd.hline(fft_sf,0,FFTANCHO,y,ESCCOLOR) lb = ftdev1.render(str((12-x)*-10), 0, ESCCOLOR,BGCOLOR) # pinta db text fft_sf.blit(lb, (0,y-10)) # Pinta db label # Pinta BW if nobaile: txdev = FFTANCHO/2; else: txdev = xdev txbw = 2*xbw tcodo = txdev - txbw/2 if not nobaile or (nobaile and (frame % 10) > 4 ): # parapedea dev si introscan if tmode != "FM W" and tmode != "FM ST": # WFM no tiene ancho de banda if tmode == "USB": txbw /= 2 tcodo = txdev elif tmode == "LSB": txbw /= 2 tcodo = txdev - txbw fft_sf.fill(BWCOLOR2,(tcodo,BWY,txbw,FFTALTO-BWY),0) # Pinta BW pgd.rectangle(fft_sf,(tcodo,BWY,txbw,FFTALTO-BWY),BWCOLOR) pgd.vline(fft_sf,int(txdev),0,FFTALTO,DEVCOLOR) # Pinta linea dev # PINTA MAX if maxpts_enable: # Pintta puntos de max mpts += [(FFTANCHO,FFTALTO),(0,FFTALTO)] pgd.polygon(fft_sf,mpts,MAXCOLOR) # PINTA FILL if fftfill_enable: # Pintta FFT relleno (Más rápido que el fill) for x in pts: pgd.vline(fft_sf,x[0],x[1],FFTALTO,FILLCOLOR) # PINTA FFT pgd.polygon(fft_sf,pts,FGCOLOR) # pinta FFT # PINTA DETECT if detect_enable : # Pinta detector picos for x in dtc : pgd.circle(fft_sf,x[0],x[1],10,DETECTCOLOR) # PINTA DEV text if not nobaile or (nobaile and (frame % 10) > 4): if tmode != "FM W" and tmode != "FM ST": fft_sf.blit(bwlabel, (txdev-bwlabel.get_size()[0]/2,BWY+2)) # Pinta bw label fft_sf.blit(fqlabel1, (txdev-pleft,BWY-22)) # Pinta dev label fft_sf.blit(fqlabel2, (txdev-pleft+fqlabel1.get_size()[0]+4,BWY-20)) fft_sf.blit(modelabel,(txdev-modelabel.get_size()[0]/2,BWY-40)) # Pinta mode label # pinta Sqelch tc = SQCOLOR if not sqstate: tc = (0,200,0) # Si está levantado pinta verde pgd.hline(fft_sf,0,FFTANCHO,xsq+base, tc) fsq = ftdev2.render(' SQ '+str(sq)+ ' ', 0, DEVCOLORHZ,(100,25,25)) fft_sf.blit(fsq, (FFTANCHO-fsq.get_size()[0],xsq-10+base)) # Pinta bw label possq = (FFTANCHO-fsq.get_size()[0]+25,xsq-12+base+12) # Guardo posicion para el botón #pgd.circle(fft_sf,possq[0],possq[1],50,(200,200,200)) #asq = tsq # pinta smeter pgd.box(top_sf,(smx+13,25,sml-28,9),(0,0,0)) pgd.box(top_sf,(smx+13,27,smval*smvaladj,6),(255,50,50)) # PINTA CIFRAS DE FREQ SI HAN CAMBIADO if refreshfq: sp = 4 size = 24 numx = [] # Repinta el indicador de frecuencia txt = format(fqc,'010d') txt = txt[:-9]+'.'+txt[-9:-6]+'.'+txt[-6:-3]+','+txt[-3:] lon = len(txt) anc = 0 for x in range(lon): if txt[x] in ['.',','] : col = BGCOLOR anc = size / 2 else : col = BGFQCCOLOR anc = size px = (TOPANCHO/2) - (lon+sp)*size/2 + (x*(size+sp)) # Calcula posición fqclabel = ftqc.render(txt[x], 1, FQCCOLOR, col) # pinta fqc text top_sf.blit(fqclabel,(px,0)) # blit if txt[x] not in ['.',','] : numx += [px] # Almacena la coordenada del numero # PARPADEA BOTON ROJO IF REC if rec: if frame == FPS/2: pgd.filled_circle(top_sf, smx+sml+TOPALTO/2, TOPALTO/2, TOPALTO/4, BGCOLOR) #Borra botón rojo izquierda smeter if frame == 1: pgd.filled_circle(top_sf, smx+sml+TOPALTO/2, TOPALTO/2, TOPALTO/4, tc) #Pinta botón del color del smeter # Pinta STEREO si STEREO if REAL and tmode == "FM ST": if (sdr.probe_st.level() > 0.5 ): top_sf.blit(stereosf,(250,8)) else: pgd.box(top_sf,(250,0,40,TOPALTO),BGCOLOR) # Pinta BIRDIES for i in birds: fft_sf.blit(fbd, (i+((birdsize-16)/2),FFTALTO-16)) # PINTA MENU IF ANY if mn : mn.refresca() # Flipea/Vuelca la pantalla pg.display.flip() refreshfq = False frame = (frame % FPS) +1 count += 1
def render(self, mode="human"): screen_width = 600 screen_height = 400 world_width = self.max_position - self.min_position scale = screen_width / world_width carwidth = 40 carheight = 20 if self.screen is None: pygame.init() pygame.display.init() self.screen = pygame.display.set_mode((screen_width, screen_height)) if self.clock is None: self.clock = pygame.time.Clock() self.surf = pygame.Surface((screen_width, screen_height)) self.surf.fill((255, 255, 255)) pos = self.state[0] xs = np.linspace(self.min_position, self.max_position, 100) ys = self._height(xs) xys = list(zip((xs - self.min_position) * scale, ys * scale)) pygame.draw.aalines(self.surf, points=xys, closed=False, color=(0, 0, 0)) clearance = 10 l, r, t, b = -carwidth / 2, carwidth / 2, carheight, 0 coords = [] for c in [(l, b), (l, t), (r, t), (r, b)]: c = pygame.math.Vector2(c).rotate_rad(math.cos(3 * pos)) coords.append( ( c[0] + (pos - self.min_position) * scale, c[1] + clearance + self._height(pos) * scale, ) ) gfxdraw.aapolygon(self.surf, coords, (0, 0, 0)) gfxdraw.filled_polygon(self.surf, coords, (0, 0, 0)) for c in [(carwidth / 4, 0), (-carwidth / 4, 0)]: c = pygame.math.Vector2(c).rotate_rad(math.cos(3 * pos)) wheel = ( int(c[0] + (pos - self.min_position) * scale), int(c[1] + clearance + self._height(pos) * scale), ) gfxdraw.aacircle( self.surf, wheel[0], wheel[1], int(carheight / 2.5), (128, 128, 128) ) gfxdraw.filled_circle( self.surf, wheel[0], wheel[1], int(carheight / 2.5), (128, 128, 128) ) flagx = int((self.goal_position - self.min_position) * scale) flagy1 = int(self._height(self.goal_position) * scale) flagy2 = flagy1 + 50 gfxdraw.vline(self.surf, flagx, flagy1, flagy2, (0, 0, 0)) gfxdraw.aapolygon( self.surf, [(flagx, flagy2), (flagx, flagy2 - 10), (flagx + 25, flagy2 - 5)], (204, 204, 0), ) gfxdraw.filled_polygon( self.surf, [(flagx, flagy2), (flagx, flagy2 - 10), (flagx + 25, flagy2 - 5)], (204, 204, 0), ) self.surf = pygame.transform.flip(self.surf, False, True) self.screen.blit(self.surf, (0, 0)) if mode == "human": pygame.event.pump() self.clock.tick(self.metadata["render_fps"]) pygame.display.flip() if mode == "rgb_array": return np.transpose( np.array(pygame.surfarray.pixels3d(self.screen)), axes=(1, 0, 2) ) else: return self.isopen
def doit(calibrar): global SALIDA global cal,elmax # CLS #sf.fill(BGCOLOR) # Pinta grafica for i in range(10): pgd.hline(sf,0,VEC_SZ,i*50,FONDO) elpaso = (FMAX-FMIN)/(int(VEC_SZ)/50) for i in range(int(VEC_SZ/50)+1): pgd.vline(sf,i*50,0,500,FONDO) #if (i % 3 ) == 0: fs = ft.render(str((FMIN+(elpaso*i))/1e6), 1,FGCOLOR, BGCOLOR) sf.blit(fs, (i*50,505)) #print(str((FMIN+(elpaso*i))/1e6)) for i in np.arange(0,VEC_SZ,RES): # SINTONIZA fq = FMIN+(STEP*i) sdr.set_freq(fq) f2 = int(fq) if fq>50e6: f2 = 125e6-int(fq) if fq>125e6: f2 = int(fq)-125e6 f.write("F"+str(int(f2))+"\n") # ESPERA time.sleep(0.04) ~clk.tick(30) #BORRA EL DATO ANTERIOR #pg.gfxdraw.pixel(sf,i,FFTALTO-int(py[i]),BGCOLOR); pg.draw.rect(sf,BGCOLOR,(i-RES,0,RES,10)); pg.draw.line(sf,BGCOLOR,(i,FFTALTO-int(py[i])),(i+RES,FFTALTO-int(py[i]))); # COJE DATO. EL MAYOR DEL FFT ma = -10000000; for x in sdr.fft_probe.level(): if x > ma: ma = x; #print(ma) t = 5+m.log10(ma) # Usa calibración if cal[i] != 0.0: t = t+ (elmax-cal[i]) if calibrar: cal[i] = t if t > elmax: elmax=t # GUARDA PA LUEGO py[i] = t*FFTK; # PINTA #pg.gfxdraw.pixel(sf,i,FFTALTO-int(py[i]),FGCOLOR); pg.draw.rect(sf,FGCOLOR,(i,0,RES,10)); pg.draw.line(sf,FGCOLOR,(i,FFTALTO-int(py[i])),(i+RES,FFTALTO-int(py[i]))); # Muestra pg.display.flip() for evt in pg.event.get(): if (evt.type == pg.QUIT): SALIDA = True if SALIDA: quit()