コード例 #1
0
ファイル: elmo-display.py プロジェクト: nv1t/freeElmo
def toggle_fullscreen(image, screen, fullscreen, image_res):
    if fullscreen:
        screen = pygame.display.set_mode(screen_res, RESIZABLE)
        fullscreen = False 
    else:
        try:
            screen = pygame.display.set_mode(image_res, FULLSCREEN)
            fullscreen = True
        except:
            string = "\n   Can't change to fullscreen.\n   No video mode isn't large enough for the image resolution.   "
            #calculating the box size
            temp_font_size = int((screen.get_size()[0]/12)/2)
            temp_width = temp_font_size * 7
            temp_height = temp_font_size * 0.9
            #print the boy on the screen
            fits=False
            rendered_text = False
            while not fits:
                try:            
                    textRect = pygame.Rect((0, 0, temp_width, temp_height))
                    textRect.centerx = screen.get_rect().centerx
                    rendered_text = render_textrect(string, pygame.font.SysFont("", temp_font_size), textRect, LGRAY, DGRAY, 0)
                    fits = True
                except:
                    temp_font_size = temp_font_size - 1
                    if temp_font_size == 0: fits = True            
            if rendered_text:
                screen.blit(rendered_text, textRect)    
            pygame.display.update()
            time.sleep(2)
            fullscreen = False
    return [screen, fullscreen]  
コード例 #2
0
ファイル: elmo-display.py プロジェクト: nv1t/freeElmo
def draw_help(screen, screen_size, version, font, color_background, color_font):
    #define string to display 
    my_string = """\n
                Help\n
                Quit: Ctrl+Q, Alt+F4, Escape\n
                Display Help: Ctrl+H, F1  
                Exit Help: Ctrl+H, F1, Escape\n
                Show/Hide Interface: Crtl+I\n
                Toggle Fullscreen: Ctrl+F
                Rotate Image 180 Degree: Ctrl+T"""
                   #Rotate Image 90 Degree: Ctrl+R\n
    my_string += """\n
                Save Image: Ctrl+S\n\n
                Camera options:\n
                Zoom in start/stop: Ctrl+C
                Zoom out start/stop: Ctrl+V\n
                Reset Brightness: Ctrl+G 
                Brightness up start/stop: Ctrl+D
                Brightness down start/stop: Ctrl+X\n
                Autofocus: Ctrl+A
                Macrofocus start/stop: Ctrl+E
                Widefocus start/stop: Ctrl+W\n
                Image Quality UP: Crtl+U
                Image Quality Down: Crtl+Z\n\n
                Free ELMO - Version """+version+"""
                (c)2013 nuit & McSumo"""
    #define resolution of the rectangle
    height = screen_size[1] * 0.9
    width= (height/5)*4
    font_size = int((height/13)/2)
    #create rectangle
    textRect = pygame.Rect((0, 0, width, height))
    #set rectangle position to middle of the screen
    textRect.centerx = screen.get_rect().centerx
    textRect.centery = screen.get_rect().centery   
    fits = False
    while not fits:
        try:
            #render the text for the rectangle
            rendered_text = render_textrect(my_string, pygame.font.SysFont(font, font_size), textRect, color_font, color_background, 0)
            fits = True
        except:
            font_size = font_size - 1
            if font_size == 1:
                fits = True
    if rendered_text:
        screen.blit(rendered_text, textRect)
    return screen
コード例 #3
0
ファイル: elmo-display.py プロジェクト: nv1t/freeElmo
         buttons = draw_interface(screen, screen.get_size(), buttons, error_no_elmo, basic_font, DGRAY, LGRAY)
     #display error massage when no image is delivered
     if error_no_image:
         string = "\n  Can't get a new image.  "
         #calculating the box size
         temp_font_size = int((screen.get_size()[0]/12)/2)
         temp_width = temp_font_size * 3
         temp_height = temp_font_size * 0.75
         #print the boy on the screen
         fits=False
         rendered_text = False
         while not fits:
             try:
                 textRect = pygame.Rect((0, 0, temp_width, temp_height))
                 textRect.centerx = screen.get_rect().centerx
                 rendered_text = render_textrect(string, pygame.font.SysFont(basic_font, temp_font_size-1), textRect, LGRAY, DGRAY, 0)
                 fits = True
             except:
                 temp_font_size = temp_font_size - 1
                 if temp_font_size == 0: fits = True
         if rendered_text:
             screen.blit(rendered_text, textRect)        
 
 if error_no_elmo == True or image == None:
     if screen_res == None:
         screen_res = [480, 320]
     screen = pygame.display.set_mode(screen_res,RESIZABLE)
     pygame.display.set_caption(str("ERROR!!! - Free ELMO Version " + version)) #set msg of the window
     #define string to display
     error_string = ""
     if error_no_elmo: