當前位置: 首頁>>代碼示例>>Python>>正文


Python Loader.load_image方法代碼示例

本文整理匯總了Python中lib.loader.Loader.load_image方法的典型用法代碼示例。如果您正苦於以下問題:Python Loader.load_image方法的具體用法?Python Loader.load_image怎麽用?Python Loader.load_image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lib.loader.Loader的用法示例。


在下文中一共展示了Loader.load_image方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from lib.loader import Loader [as 別名]
# 或者: from lib.loader.Loader import load_image [as 別名]
    def __init__(self):
        self.screen = pygame.display.set_mode((800, 600),1)
        pygame.display.set_caption("PaintBrush simple demo v1.0 - Press space to clear paper")
        
        loader = Loader()
                        
        self.brush = PaintBrush(self.screen)
        self.brush.set_brush(loader.load_image("brush_6.png", True))
        self.brush.set_follow_angle(True)
        self.brush.set_color(pygame.Color("Blue"))
        self.brush.set_alpha(0.2)

        self.screen.fill((255,255,255))
開發者ID:MounikaArkala,項目名稱:txstateprojects,代碼行數:15,代碼來源:SimpleDemo.py

示例2: __init__

# 需要導入模塊: from lib.loader import Loader [as 別名]
# 或者: from lib.loader.Loader import load_image [as 別名]
    def __init__(self):
        self.screen = pygame.display.set_mode((800, 600),1)
        pygame.display.set_caption("Music Painter")
        pygame.init()
        loader = Loader()
        self.canvas = Canvas(800, 600)				
        self.brush = PaintBrush(self.screen)
        self.brush.set_brush(loader.load_image("brush_6.png", True))
        self.brush.set_follow_angle(True)
        self.brush.set_color(pygame.Color("Blue"))
        self.brush.set_alpha(0.2)

        self.screen.fill((255,255,255))
開發者ID:tswast,項目名稱:soundbrush,代碼行數:15,代碼來源:soundbrush.py

示例3: AdvancedDemo

# 需要導入模塊: from lib.loader import Loader [as 別名]
# 或者: from lib.loader.Loader import load_image [as 別名]
class AdvancedDemo(object):
    def __init__(self):
        self.screen = pygame.display.set_mode((800, 600),1)
        pygame.display.set_caption("PaintBrush advanced demo v1.1")
        
        self.loader = Loader()
        
        self.simple_pal = self.loader.load_image("simple.png",False)
        self.advanced_pal = self.loader.load_image("advanced.png",False)
        self.simple = True
        
        self.knob = self.loader.load_image("knob.png",True)
        self.knob_rect = self.knob.get_rect()
        self.knob_rect.topleft = (14,215)
        
        self.back = self.loader.load_image("back.png", False)

        self.help = self.loader.load_image("help.png", True)
                        
        self.b1 = self.loader.load_image("brush_1.png", True) 
        self.b2 = self.loader.load_image("brush_2.png", True) 
        self.b3 = self.loader.load_image("brush_3.png", True) 
        self.b4 = self.loader.load_image("brush_4.png", True) 
        self.b5 = self.loader.load_image("brush_5.png", True) 
        self.b6 = self.loader.load_image("brush_6.png", True) 
        self.b7 = self.loader.load_image("brush_7.png", True)
        self.b8 = self.loader.load_image("brush_8.png", True)
        self.b9 = self.loader.load_image("brush_9.png", True)
        self.cur_color = pygame.Color(0,0,0)
        
        self.paper_rect = pygame.Rect(127,12,659,574)
        self.paper = (pygame.Surface(self.paper_rect.size,1)).convert()
        self.paper.fill((255,255,255))
        self.painting = False
        self.undo_cache = []
        
        self.pal_rect = pygame.Rect(12,12,101,200)
        
        self.brush_rect = pygame.Rect(12,231,101,355)
        self.brush_rects = [] 
        self.brush_rects.append(pygame.Rect(12,231,101,200))
        self.brush_rects.append(pygame.Rect(12,332,50,50))
        self.brush_rects.append(pygame.Rect(63,332,50,50))
        self.brush_rects.append(pygame.Rect(12,332+51*1,50,50))
        self.brush_rects.append(pygame.Rect(63,332+51*1,50,50))
        self.brush_rects.append(pygame.Rect(12,332+51*2,50,50))
        self.brush_rects.append(pygame.Rect(63,332+51*2,50,50))
        self.brush_rects.append(pygame.Rect(12,332+51*3,50,50))
        self.brush_rects.append(pygame.Rect(63,332+51*3,50,50))
        self.brush_rects.append(pygame.Rect(12,332+51*4,50,50))
        self.brush_rects.append(pygame.Rect(63,332+51*4,50,50))
        
        self.brush = PaintBrush(self.paper)
        
        self.set_brush(2)

    def save_paper(self):
        self.undo_cache.append(self.paper.copy())
        self.undo_cache = self.undo_cache[-30:]

    def undo_paper(self):
        if len(self.undo_cache):
            p = self.undo_cache.pop()
            self.paper.blit(p,(0,0))

    def set_color(self,c):
        self.cur_color = c
        self.brush.set_color(c)
        
    def set_alpha(self,a):
        if a <= 0.0:
            a = 0.005
            x = 14
        elif a >= 1.0:
            a = 1.0
            x = 97
        else:
            x = int(round(14.0+83.0*a))
        self.brush.set_alpha(a)
        self.knob_rect.left = x

    def set_brush(self,idx):
        if idx == 0:
            self.brush.set_brush(self.b1)
            self.brush.set_space(5.0)
            self.brush.set_color(self.cur_color)
            self.set_alpha(1.0)
        elif idx == 1:
            self.brush.set_brush(self.b2)
            self.brush.set_space(2.0)
            self.brush.set_color(self.cur_color)
            self.set_alpha(1.0)
        elif idx == 2:
            self.brush.set_brush(self.b3)
            self.brush.set_space(1.0)
            self.brush.set_color(self.cur_color)
            self.set_alpha(1.0)
        elif idx == 3:
            self.brush.set_brush(self.b4)
            self.brush.set_space(1.0)
#.........這裏部分代碼省略.........
開發者ID:MounikaArkala,項目名稱:txstateprojects,代碼行數:103,代碼來源:AdvancedDemo.py

示例4: __init__

# 需要導入模塊: from lib.loader import Loader [as 別名]
# 或者: from lib.loader.Loader import load_image [as 別名]
 def __init__(self):
     loader = Loader()
     self.stars = []
     for i in range(1,6):
         self.stars.append(loader.load_image("star%d.png" % i, True))
     self.anims = []
開發者ID:gianasista,項目名稱:playground,代碼行數:8,代碼來源:Memory.py


注:本文中的lib.loader.Loader.load_image方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。