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


Python pygame.BLEND_ADD屬性代碼示例

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


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

示例1: mix_circles

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def mix_circles(self):
        for i in range(3):
            self.rgb_g[i] = self.board.ships[i].grid_y
        self.update_sliders()
        self.canv[3].fill(self.col_k)
        ct = self.canvas_center
        radius = 9 * self.board.scale
        radius2 = 5 * self.board.scale
        x = 1 * self.board.scale
        rect = [[ct[0], ct[1] - x], [ct[0] - x, ct[1] + x], [ct[0] + x, ct[1] + x]]
        for i in range(3):
            pygame.draw.circle(self.canv[i], self.rgbx3[i], rect[i], radius, 0)
            self.canv[3].blit(self.canv[i], [0, 0], special_flags=pygame.BLEND_ADD)

        pygame.draw.circle(self.canv[3], self.picked, ct, radius2, 0)

        self.canvas.painting = self.canv[3].copy()
        self.canvas.update_me = True 
開發者ID:imiolek-ireneusz,項目名稱:eduActiv8,代碼行數:20,代碼來源:game054.py

示例2: update

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def update(self, board):
        if self.update_me:
            Unit.update(self, board)
            if len(self.img_src) > 0:
                self.image.blit(self.img, self.img_pos)
                if self.tint_color is not None:
                    self.image.fill(self.tint_color, special_flags=pygame.BLEND_ADD)
            if self.unit_id == board.active_ship and self.outline is True:
                lines = [[0, 0], [self.grid_w * board.scale - 2, 0],
                         [self.grid_w * board.scale - 2, self.grid_h * board.scale - 2],
                         [0, self.grid_h * board.scale - 2]]
                pygame.draw.lines(self.image, (255, 200, 200), True, lines)
            if hasattr(self, "door_outline") and self.door_outline is True:
                self.set_outline(self.perm_outline_color, self.perm_outline_width)
            if self.perm_outline:
                self.draw_outline()
            self.draw_check_marks() 
開發者ID:imiolek-ireneusz,項目名稱:eduActiv8,代碼行數:19,代碼來源:board.py

示例3: load_images

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def load_images(self, rev):
        self.rev = rev
        self.img_pos = (0, 0)
        self.img_1 = pygame.image.load(os.path.join('res', 'images', "info_bar", "mask", self.img_src_1)).convert_alpha()
        self.img_1.fill(self.panel.mainloop.cl.info_buttons_col, special_flags=pygame.BLEND_ADD)
        self.img_2 = pygame.image.load(os.path.join('res', 'images', "info_bar", "mask", self.img_src_2)).convert_alpha()
        self.img_2.fill(self.panel.mainloop.cl.info_buttons_col, special_flags=pygame.BLEND_ADD)
        self.img_4 = pygame.image.load(
            os.path.join('res', 'images', "info_bar", "decor", self.img_src_2)).convert_alpha()

        if self.img_src_3 != "":
            self.img_3 = pygame.image.load(
                os.path.join('res', 'images', "info_bar", self.img_src_3)).convert_alpha()
        if rev:
            self.img_1 = pygame.transform.flip(self.img_1, 1, 0)
            self.img_2 = pygame.transform.flip(self.img_2, 1, 0)
            self.img_4 = pygame.transform.flip(self.img_4, 1, 0)

        self.img = self.img_2
        self.hasimg = True
        self.update() 
開發者ID:imiolek-ireneusz,項目名稱:eduActiv8,代碼行數:23,代碼來源:info_bar.py

示例4: load_images

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def load_images(self):
        self.bg_tint_color = ex.hsv_to_rgb(self.wnd.mainloop.cl.color_sliders[5][0] * 16, 255, 100)
        if len(self.img_src1) > 0:
            self.img_pos = (0, 0)
            try:
                self.img1 = pygame.image.load(os.path.join('res', 'images', "dialog",  self.img_src1)).convert_alpha()
                self.img3 = pygame.image.load(os.path.join('res', 'images', "dialog", "dialog_bg_n.png")).convert_alpha()
                self.img3.fill(self.bg_tint_color, special_flags=pygame.BLEND_ADD)

                self.img4 = pygame.image.load(os.path.join('res', 'images', "dialog", "dialog_bg_h.png")).convert_alpha()
                self.img4.fill(self.bg_tint_color, special_flags=pygame.BLEND_ADD)

                self.active_img = self.img1
            except:
                pass
        self.update() 
開發者ID:imiolek-ireneusz,項目名稱:eduActiv8,代碼行數:18,代碼來源:dialogwnd.py

示例5: test_blend

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def test_blend(self):
        bitsizes = [8, 16, 24, 32]
        blends = ['BLEND_ADD',
                  'BLEND_SUB',
                  'BLEND_MULT',
                  'BLEND_MIN',
                  'BLEND_MAX']
        for bitsize in bitsizes:
            surf = self._make_surface(bitsize)
            comp = self._make_surface(bitsize)
            for blend in blends:
                self._fill_surface(surf)
                self._fill_surface(comp)
                comp.blit(surf, (3, 0),
                          special_flags=getattr(pygame, blend))
                surf.blit(surf, (3, 0),
                          special_flags=getattr(pygame, blend))
                self._assert_same(surf, comp) 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:20,代碼來源:surface_test.py

示例6: blit

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def blit(self):
        return self.game.screen.blit(self.image, self.rect, special_flags=pygame.BLEND_ADD) 
開發者ID:kidscancode,項目名稱:pygame_tutorials,代碼行數:4,代碼來源:particles.py

示例7: mix_circles

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def mix_circles(self):
        for i in range(3):
            self.rgb_g[i] = self.board.ships[i].grid_y
        self.update_sliders()
        self.canv[3].fill(self.col_k)
        ct = self.canvas_center
        radius = 9 * self.board.scale
        x = 1 * self.board.scale
        rect = [[ct[0], ct[1] - x], [ct[0] - x, ct[1] + x], [ct[0] + x, ct[1] + x]]
        for i in range(3):
            pygame.draw.circle(self.canv[i], self.rgbx3[i], rect[i], radius, 0)
            self.canv[3].blit(self.canv[i], [0, 0], special_flags=pygame.BLEND_ADD)
        self.canvas.painting = self.canv[3].copy()
        self.canvas.update_me = True 
開發者ID:imiolek-ireneusz,項目名稱:eduActiv8,代碼行數:16,代碼來源:game053.py

示例8: get_tinted_img

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def get_tinted_img(self, tint_color):
        tinted_img = self.img.copy()
        tinted_img.fill(tint_color, special_flags=pygame.BLEND_ADD)
        return tinted_img 
開發者ID:imiolek-ireneusz,項目名稱:eduActiv8,代碼行數:6,代碼來源:universal.py

示例9: blit

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def blit(self):
        flags = pg.BLEND_ADD
        flags = pg.BLEND_RGBA_ADD
        return self.game.game_surface.blit(self.image, self.rect, special_flags=flags) 
開發者ID:kidscancode,項目名稱:gamedev,代碼行數:6,代碼來源:particles.py

示例10: test_fill_keyword_args

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def test_fill_keyword_args(self):
        """Ensure fill() accepts keyword arguments."""
        color = (1, 2, 3, 255)
        area = (1, 1, 2, 2)
        s1 = pygame.Surface((4, 4), 0, 32)
        s1.fill(special_flags=pygame.BLEND_ADD, color=color, rect=area)

        self.assertEqual(s1.get_at((0, 0)), (0, 0, 0, 255))
        self.assertEqual(s1.get_at((1, 1)), color)

    ######################################################################## 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:13,代碼來源:surface_test.py

示例11: test_blit_keyword_args

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def test_blit_keyword_args(self):
        color = (1, 2, 3, 255)
        s1 = pygame.Surface((4, 4), 0, 32)
        s2 = pygame.Surface((2, 2), 0, 32)
        s2.fill((1, 2, 3))
        s1.blit(special_flags=BLEND_ADD, source=s2,
                dest=(1, 1), area=s2.get_rect())
        self.assertEqual(s1.get_at((0, 0)), (0, 0, 0, 255))
        self.assertEqual(s1.get_at((1, 1)), color) 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:11,代碼來源:surface_test.py

示例12: todo_test_blit

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def todo_test_blit(self):
        # __doc__ (as of 2008-08-02) for pygame.surface.Surface.blit:

          # Surface.blit(source, dest, area=None, special_flags = 0): return Rect
          # draw one image onto another
          #
          # Draws a source Surface onto this Surface. The draw can be positioned
          # with the dest argument. Dest can either be pair of coordinates
          # representing the upper left corner of the source. A Rect can also be
          # passed as the destination and the topleft corner of the rectangle
          # will be used as the position for the blit. The size of the
          # destination rectangle does not effect the blit.
          #
          # An optional area rectangle can be passed as well. This represents a
          # smaller portion of the source Surface to draw.
          #
          # An optional special flags is for passing in new in 1.8.0: BLEND_ADD,
          # BLEND_SUB, BLEND_MULT, BLEND_MIN, BLEND_MAX new in 1.8.1:
          # BLEND_RGBA_ADD, BLEND_RGBA_SUB, BLEND_RGBA_MULT, BLEND_RGBA_MIN,
          # BLEND_RGBA_MAX BLEND_RGB_ADD, BLEND_RGB_SUB, BLEND_RGB_MULT,
          # BLEND_RGB_MIN, BLEND_RGB_MAX With other special blitting flags
          # perhaps added in the future.
          #
          # The return rectangle is the area of the affected pixels, excluding
          # any pixels outside the destination Surface, or outside the clipping
          # area.
          #
          # Pixel alphas will be ignored when blitting to an 8 bit Surface.
          # special_flags new in pygame 1.8.

        self.fail() 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:33,代碼來源:surface_test.py

示例13: test_blit_blend_big_rect

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def test_blit_blend_big_rect(self):
        """ test that an oversized rect works ok.
        """
        color = (1, 2, 3, 255)
        area = (1, 1, 30, 30)
        s1 = pygame.Surface((4, 4), 0, 32)
        r = s1.fill(special_flags=pygame.BLEND_ADD, color=color, rect=area)

        self.assertEqual(pygame.Rect((1, 1, 3, 3)), r)
        self.assertEqual(s1.get_at((0, 0)), (0, 0, 0, 255))
        self.assertEqual(s1.get_at((1, 1)), color)

        black = pygame.Color("black")
        red = pygame.Color("red")
        self.assertNotEqual(black, red)

        surf = pygame.Surface((10, 10), 0, 32)
        surf.fill(black)
        subsurf = surf.subsurface(pygame.Rect(0, 1, 10, 8))
        self.assertEqual(surf.get_at((0, 0)), black)
        self.assertEqual(surf.get_at((0, 9)), black)

        subsurf.fill(red, (0, -1, 10, 1), pygame.BLEND_RGB_ADD)
        self.assertEqual(surf.get_at((0, 0)), black)
        self.assertEqual(surf.get_at((0, 9)), black)

        subsurf.fill(red, (0, 8, 10, 1), pygame.BLEND_RGB_ADD)
        self.assertEqual(surf.get_at((0, 0)), black)
        self.assertEqual(surf.get_at((0, 9)), black) 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:31,代碼來源:surface_test.py

示例14: test_fill_blend

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def test_fill_blend(self):
        destinations = [self._make_surface(8),
                        self._make_surface(16),
                        self._make_surface(16, srcalpha=True),
                        self._make_surface(24),
                        self._make_surface(32),
                        self._make_surface(32, srcalpha=True)]
        blend = [('BLEND_ADD', (0, 25, 100, 255),
                  lambda a, b: min(a + b, 255)),
                 ('BLEND_SUB', (0, 25, 100, 255),
                  lambda a, b: max(a - b, 0)),
                 ('BLEND_MULT', (0, 7, 100, 255),
                  lambda a, b: (a * b) // 256),
                 ('BLEND_MIN', (0, 255, 0, 255), min),
                 ('BLEND_MAX', (0, 255, 0, 255), max)]

        for dst in destinations:
            dst_palette = [dst.unmap_rgb(dst.map_rgb(c))
                           for c in self._test_palette]
            for blend_name, fill_color, op in blend:
                fc = dst.unmap_rgb(dst.map_rgb(fill_color))
                self._fill_surface(dst)
                p = []
                for dc in dst_palette:
                    c = [op(dc[i], fc[i]) for i in range(3)]
                    if dst.get_masks()[3]:
                        c.append(dc[3])
                    else:
                        c.append(255)
                    c = dst.unmap_rgb(dst.map_rgb(c))
                    p.append(c)
                dst.fill(fill_color, special_flags=getattr(pygame, blend_name))
                self._assert_surface(dst, p, ", %s" % blend_name) 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:35,代碼來源:surface_test.py

示例15: test_fill

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import BLEND_ADD [as 別名]
def test_fill(self):
        screen = pygame.display.set_mode((640, 480))

        # Green and blue test pattern
        screen.fill((0, 255, 0), (0, 0, 320, 240))
        screen.fill((0, 255, 0), (320, 240, 320, 240))
        screen.fill((0, 0, 255), (320, 0, 320, 240))
        screen.fill((0, 0, 255), (0, 240, 320, 240))

        # Now apply a clip rect, such that only the left side of the
        # screen should be effected by blit opperations.
        screen.set_clip((0, 0, 320, 480))

        # Test fills with each special flag, and additionaly without any.
        screen.fill((255, 0, 0, 127), (160, 0, 320, 30), 0)
        screen.fill((255, 0, 0, 127), (160, 30, 320, 30), pygame.BLEND_ADD)
        screen.fill((0, 127, 127, 127), (160, 60, 320, 30), pygame.BLEND_SUB)
        screen.fill((0, 63, 63, 127), (160, 90, 320, 30), pygame.BLEND_MULT)
        screen.fill((0, 127, 127, 127), (160, 120, 320, 30), pygame.BLEND_MIN)
        screen.fill((127, 0, 0, 127), (160, 150, 320, 30), pygame.BLEND_MAX)
        screen.fill((255, 0, 0, 127), (160, 180, 320, 30), pygame.BLEND_RGBA_ADD)
        screen.fill((0, 127, 127, 127), (160, 210, 320, 30), pygame.BLEND_RGBA_SUB)
        screen.fill((0, 63, 63, 127), (160, 240, 320, 30), pygame.BLEND_RGBA_MULT)
        screen.fill((0, 127, 127, 127), (160, 270, 320, 30), pygame.BLEND_RGBA_MIN)
        screen.fill((127, 0, 0, 127), (160, 300, 320, 30), pygame.BLEND_RGBA_MAX)
        screen.fill((255, 0, 0, 127), (160, 330, 320, 30), pygame.BLEND_RGB_ADD)
        screen.fill((0, 127, 127, 127), (160, 360, 320, 30), pygame.BLEND_RGB_SUB)
        screen.fill((0, 63, 63, 127), (160, 390, 320, 30), pygame.BLEND_RGB_MULT)
        screen.fill((0, 127, 127, 127), (160, 420, 320, 30), pygame.BLEND_RGB_MIN)
        screen.fill((255, 0, 0, 127), (160, 450, 320, 30), pygame.BLEND_RGB_MAX)

        # Update the display so we can see the results
        pygame.display.flip()

        # Compare colors on both sides of window
        for y in range(5, 480,  10):
            self.assertEqual(screen.get_at((10, y)), screen.get_at((330, 480 - y))) 
開發者ID:wistbean,項目名稱:fxxkpython,代碼行數:39,代碼來源:surface_test.py


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