Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self):
g = self.grid_resolution
self.power = np.zeros((g, g), dtype=np.float32)
# The world is initially cold.
self.temp = self.simulation.ambient_temps(g, g)
pygame.init()
pygame.display.set_caption('HotSpot!')
size = (self.grid_resolution, self.grid_resolution)
self.screen = pygame.display.set_mode(size)
self.surface = pygame.Surface(size)
self.font = pygame.font.Font(None, 26)
try:
self.loop()
except HotSpotQuit:
return
def draw_text(self, text, size, x, y):
# utility function to draw text on screen
font_name = pygame.font.match_font('arial')
font = pygame.font.Font(font_name, size)
text_surface = font.render(text, True, WHITE)
text_rect = text_surface.get_rect()
text_rect.topleft = (x, y)
self.screen.blit(text_surface, text_rect)
def ShowStartInterface(screen, width, height):
screen.fill(BACKGROUNDCOLOR)
tfont = pygame.font.Font('./font/simkai.ttf', width//4)
cfont = pygame.font.Font('./font/simkai.ttf', width//20)
title = tfont.render('拼图游戏', True, RED)
content1 = cfont.render('按H或M或L键开始游戏', True, BLUE)
content2 = cfont.render('H为5*5模式,M为4*4模式,L为3*3模式', True, BLUE)
trect = title.get_rect()
trect.midtop = (width/2, height/10)
crect1 = content1.get_rect()
crect1.midtop = (width/2, height/2.2)
crect2 = content2.get_rect()
crect2.midtop = (width/2, height/1.8)
screen.blit(title, trect)
screen.blit(content1, crect1)
screen.blit(content2, crect2)
pygame.display.update()
while True:
size = None
if upis == True:
tmp_float = float(tmp)
if tmp_float >= UPIS_TEMP_ALERT:
x = LCD_WIDTH-overtemp_icon.get_width()-5
screen.blit(overtemp_icon, (x,y))
else:
x = LCD_WIDTH-5
else:
x = LCD_WIDTH-5
font = pygame.font.Font(filepath(TOPBAR_FONT), TOPBAR_FONTSIZE)
label = font.render(''+cputemp+' C, '+load_average+'%', 1, (green))
screen.blit(label, (x-label.get_width()-5,y))
font = pygame.font.Font(filepath(CLOCK_FONT), CLOCK_FONTSIZE)
label = font.render(clock, 1, (CLOCK_FONTCOLOR))
screen.blit(label, (LCD_WIDTH/2-label.get_width()/2,y))
x = 0 + MARGIN_X
y = y + font.get_height()
font = pygame.font.Font(filepath(MAIN_FONT), PAGETITLE_FONTSIZE)
label = font.render("UnJailPi", 1, (PAGETITLE_FONTCOLOR))
screen.blit(label, (LCD_WIDTH-label.get_width()-MARGIN_X,y))
part1_y = y+font.get_height()+SPACE
if ext_ip != 'null':
if check_tor() == True:
screen.blit(internet_tor_32_logo, (17,65))
else:
if check_vpn("tun0") == True:
screen.blit(internet_vpn_32_logo, (17,65))
pygame.transform.smoothscale(image_surface,
(int(image_width*scale_ratio),
int(image_height*scale_ratio)))
# Přímé vykreslení původního obrázku
display.blit(image_surface, (10, 10))
# Přímé vykreslení zvětšených obrázků
display.blit(horizontally_scaled_image, (170, 10))
display.blit(horizontally_smooth_scaled_image, (170, 90))
display.blit(vertically_scaled_image, (10, 170))
display.blit(vertically_smooth_scaled_image, (90, 170))
display.blit(smooth_scaled_image, (170, 170))
# Načtení fontu (zadává se soubor se jménem fontu a velikost
font = pygame.font.Font("fonts/FreeSans.ttf", 40)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
# Vytvoření obrázku s vykresleným textem
# - první parametr obsahuje řetězec, který se má vykreslit
# - druhý parametr řídí použití antialiasingu
# - třetí parametr volí barvu fontu
font_surface1 = font.render(pygame.transform.get_smoothscale_backend(),
True, WHITE, RED)
# Vykreslení obrázku s nápisem do bufferu
display.blit(font_surface1, (15, 100))
# Hlavní herní smyčka
while True:
def __init__(self, width):
"""
Konstruktor planszy do gry. Przygotowuje okienko gry.
:param width: szerokość w pikselach
"""
self.surface = pygame.display.set_mode((width, width), 0, 32)
pygame.display.set_caption('Tic-tac-toe')
# Przed pisaniem tekstów, musimy zainicjować mechanizmy wyboru fontów PyGame
pygame.font.init()
font_path = pygame.font.match_font('arial')
self.font = pygame.font.Font(font_path, 48)
# tablica znaczników 3x3 w formie listy
self.markers = [None] * 9
def BUTTON(screen, position, text):
bwidth = 310
bheight = 65
left, top = position
pygame.draw.line(screen, (150, 150, 150), (left, top), (left+bwidth, top), 5)
pygame.draw.line(screen, (150, 150, 150), (left, top-2), (left, top+bheight), 5)
pygame.draw.line(screen, (50, 50, 50), (left, top+bheight), (left+bwidth, top+bheight), 5)
pygame.draw.line(screen, (50, 50, 50), (left+bwidth, top+bheight), [left+bwidth, top], 5)
pygame.draw.rect(screen, (100, 100, 100), (left, top, bwidth, bheight))
font_path = os.path.join(Config.get('resources_path'), Config.get('fontfolder'), 'simkai.ttf')
font = pygame.font.Font(font_path, 50)
text_render = font.render(text, 1, (255, 0, 0))
return screen.blit(text_render, (left+50, top+10))
return (255, 255, 255)
else:
return (100, 100, 100)
def set_rect(self):
self.set_rend()
self.rect = self.rend.get_rect()
self.rect.topleft = self.pos
def onClick(self):
try:
self.on_click()
except AttributeError:
pass
options_font = pygame.font.Font(None, option_text_height)
options = {
'prev' : Option("PREV", (10*args.scale + -10*args.scale, args.pixels*args.scale + option_divider_height)),
'save' : Option("SAVE", (10*args.scale + 50*args.scale, args.pixels*args.scale + option_divider_height)),
'next' : Option("NEXT", (10*args.scale + 110*args.scale, args.pixels*args.scale + option_divider_height)),
}
options_divider = pygame.Rect(0, args.pixels*args.scale, window_width, option_divider_height)
windowSurfaceObj.fill(BLUE, options_divider)
################################################################################
def get_addr17_msg_file():
data = []
searching = True
for line in open(args.file):
line = line.strip()
def __init__(self, fona):
self.UPDATE_TIME = 30
self.DEAD = 30
#Setup fona
self.fona = fona
#Define colors
self.WHITE = (255,255,255)
self.BLACK = (0,0,0)
self.dead_bat = False
#Setup fonts
self.font = pygame.font.Font('/home/pi/tyos/fonts/liberation_sans.ttf', 14)
#Setup Battery Persentage Text
self.bat_left = self.font.render('..%', True, self.BLACK, self.WHITE)
self.bat_left_rect = self.bat_left.get_rect()
self.bat_left_rect.centerx = 285
self.bat_left_rect.centery = 15
#Set the Pi clock to the Fona RTC
self.rtc()
#Setup reception/battery clock
self.last_update = time.time()