当前位置: 首页>>代码示例>>Python>>正文


Python pygame.gfxdraw方法代码示例

本文整理汇总了Python中pygame.gfxdraw方法的典型用法代码示例。如果您正苦于以下问题:Python pygame.gfxdraw方法的具体用法?Python pygame.gfxdraw怎么用?Python pygame.gfxdraw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygame的用法示例。


在下文中一共展示了pygame.gfxdraw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw_bounds

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def draw_bounds(screen,origin,screensize,angles):
    n_az = len(angles)
    radius = int(screensize[1]*.5)-10
    width = int(2)
    color = BLUE
    x, y, r = origin[0], origin[1], radius
    boundary = pygame.gfxdraw.aacircle(screen, x, y, r, color)
    #boundary = pygame.draw.circle(screen, color, origin, radius, width)

    # draw a bunch of lines
    radian_sweep = 2*math.pi / n_az
    radian_start = -0.5*radian_sweep
    for i in range(n_az):               # draw a bunch of bounds
        rad = radian_start + i*radian_sweep
        startpos = origin
        endpos = (int(origin[0]-radius*math.sin(rad)), int(origin[1]+radius*math.cos(rad)))
        pygame.draw.line(screen, color, startpos, endpos)
    return 
开发者ID:drscotthawley,项目名称:panotti,代码行数:20,代码来源:headgames.py

示例2: draw_bars

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def draw_bars(self, surface, rect):
        #pygame.draw.rect(surface, 
        width, height = rect.size
        
        color1 = self.color
        color2 = (0, 80, 110, 128)
        color3 = (255, 190, 50, 255)
        
        points = []
        
        for x, size in zip(range(25, width-15, 50), self.points):
            points.append( (x, size) )
            
        import pygame.gfxdraw
        
        for p1, p2 in zip(points, points[1:]):
            pygame.gfxdraw.line(surface, *p1, *p2, color2)
        
        for x, y in points:
            pygame.draw.rect(surface, color3, (x-2, y-2, 4, 4), 0) 
            #pygame.gfxdraw.circle(surface, color1, (x, y), 10, 1) 
            pygame.gfxdraw.aacircle(surface, x, y, 10, color1) 
开发者ID:furas,项目名称:python-examples,代码行数:24,代码来源:main.py

示例3: main

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def main():
    pygame.init()
    screen = pygame.display.set_mode((500,500))
    screen.fill((255, 0, 0))
    s = pygame.Surface(screen.get_size(), pygame.SRCALPHA, 32)
    pygame.draw.line(s, (0,0,0), (250, 250), (250+200,250))

    width = 1
    for a_radius in range(width):
        radius = 200
        pygame.gfxdraw.aacircle(s, 250, 250, radius-a_radius, (0, 0, 0))

    screen.blit(s, (0, 0))
    pygame.display.flip()
    try:
        while 1:
            event = pygame.event.wait()
            if event.type == pygame.QUIT:
                break
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE or event.unicode == 'q':
                    break
            pygame.display.flip()
    finally:
        pygame.quit() 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:27,代码来源:aacircle.py

示例4: test_hline

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def test_hline(self):
        """hline(surface, x1, x2, y, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        startx = 10
        stopx = 80
        y = 50
        fg_test_points = [(startx, y), (stopx, y), ((stopx - startx) // 2, y)]
        bg_test_points = [(startx - 1, y), (stopx + 1, y),
                          (startx, y - 1), (startx, y + 1),
                          (stopx, y - 1), (stopx, y + 1)]
        for surf in self.surfaces:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.hline(surf, startx, stopx, y, fg)
            for posn in fg_test_points:
                self.check_at(surf, posn, fg_adjusted)
            for posn in bg_test_points:
                self.check_at(surf, posn, bg_adjusted) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:21,代码来源:gfxdraw_test.py

示例5: test_vline

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def test_vline(self):
        """vline(surface, x, y1, y2, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x = 50
        starty = 10
        stopy = 80
        fg_test_points = [(x, starty), (x, stopy), (x, (stopy - starty) // 2)]
        bg_test_points = [(x, starty - 1), (x, stopy + 1),
                          (x - 1, starty), (x + 1, starty),
                          (x - 1, stopy), (x + 1, stopy)]
        for surf in self.surfaces:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.vline(surf, x, starty, stopy, fg)
            for posn in fg_test_points:
                self.check_at(surf, posn, fg_adjusted)
            for posn in bg_test_points:
                self.check_at(surf, posn, bg_adjusted) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:21,代码来源:gfxdraw_test.py

示例6: test_line

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def test_line(self):
        """line(surface, x1, y1, x2, y2, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x1 = 10
        y1 = 15
        x2 = 92
        y2 = 77
        fg_test_points = [(x1, y1), (x2, y2)]
        bg_test_points = [(x1 - 1, y1), (x1, y1 - 1), (x1 - 1, y1 - 1),
                          (x2 + 1, y2), (x2, y2 + 1), (x2 + 1, y2 + 1)]
        for surf in self.surfaces:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.line(surf, x1, y1, x2, y2, fg)
            for posn in fg_test_points:
                self.check_at(surf, posn, fg_adjusted)
            for posn in bg_test_points:
                self.check_at(surf, posn, bg_adjusted) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:21,代码来源:gfxdraw_test.py

示例7: test_trigon

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def test_trigon(self):
        """trigon(surface, x1, y1, x2, y2, x3, y3, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x1 = 10
        y1 = 15
        x2 = 92
        y2 = 77
        x3 = 20
        y3 = 60
        fg_test_points = [(x1, y1), (x2, y2), (x3, y3)]
        bg_test_points = [(x1 - 1, y1 - 1),
                          (x2 + 1, y2 + 1),
                          (x3 - 1, y3 + 1),
                          (x1 + 10, y1 + 30)]
        for surf in self.surfaces:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.trigon(surf, x1, y1, x2, y2, x3, y3, fg)
            for posn in fg_test_points:
                self.check_at(surf, posn, fg_adjusted)
            for posn in bg_test_points:
                self.check_at(surf, posn, bg_adjusted) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:25,代码来源:gfxdraw_test.py

示例8: test_filled_trigon

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def test_filled_trigon(self):
        """filled_trigon(surface, x1, y1, x2, y2, x3, y3, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x1 = 10
        y1 = 15
        x2 = 92
        y2 = 77
        x3 = 20
        y3 = 60
        fg_test_points = [(x1, y1), (x2, y2), (x3, y3),
                          (x1 + 10, y1 + 30)]
        bg_test_points = [(x1 - 1, y1 - 1),
                          (x2 + 1, y2 + 1),
                          (x3 - 1, y3 + 1)]
        for surf in self.surfaces:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.filled_trigon(surf, x1, y1, x2, y2, x3, y3, fg)
            for posn in fg_test_points:
                self.check_at(surf, posn, fg_adjusted)
            for posn in bg_test_points:
                self.check_at(surf, posn, bg_adjusted) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:25,代码来源:gfxdraw_test.py

示例9: test_bezier

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def test_bezier(self):
        """bezier(surface, points, steps, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        points = [(10, 50), (25, 15), (60, 80), (92, 30)]
        fg_test_points = [points[0], points[3]]
        bg_test_points = [(points[0][0] - 1, points[0][1]),
                          (points[3][0] + 1, points[3][1]),
                          (points[1][0], points[1][1] + 3),
                          (points[2][0], points[2][1] - 3)]
        for surf in self.surfaces:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.bezier(surf, points, 30, fg)
            for posn in fg_test_points:
                self.check_at(surf, posn, fg_adjusted)
            for posn in bg_test_points:
                self.check_at(surf, posn, bg_adjusted) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:20,代码来源:gfxdraw_test.py

示例10: test_aatrigon

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def test_aatrigon(self):
        """aatrigon(surface, x1, y1, x2, y2, x3, y3, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x1 = 10
        y1 = 15
        x2 = 92
        y2 = 77
        x3 = 20
        y3 = 60
        fg_test_points = [(x1, y1), (x2, y2), (x3, y3)]
        bg_test_points = [(x1 - 1, y1 - 1),
                          (x2 + 1, y2 + 1),
                          (x3 - 1, y3 + 1),
                          (x1 + 10, y1 + 30)]
        for surf in self.surfaces:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.aatrigon(surf, x1, y1, x2, y2, x3, y3, fg)
            for posn in fg_test_points:
                self.check_not_at(surf, posn, bg_adjusted)
            for posn in bg_test_points:
                self.check_at(surf, posn, bg_adjusted) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:25,代码来源:gfxdraw_test.py

示例11: set_progress

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def set_progress(self, percent, caption = ""):
        for event in pygame.event.get():
            if event.type == 12 and self.abortable:
                pygame.quit()
                import sys
                sys.exit()
        if caption:
            pygame.display.set_caption(caption)
        self.progress = percent
        self.surface.fill(self.bg)
        self.rect.width = self.progress*self.scale
        pygame.gfxdraw.box(self.surface, self.rect, self.fg)
        pygame.display.update(self.rect) 
开发者ID:Berserker66,项目名称:omnitool,代码行数:15,代码来源:loadbar.py

示例12: _helper

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def _helper(surf, color, rect, r):
    for x, y in [(rect[0] + r, rect[1] + r),
                 (rect[0] + rect[2] - r - 1, rect[1] + r),
                 (rect[0] + r, rect[1] + rect[3] - r - 1),
                 (rect[0] + rect[2] - r - 1, rect[1] + rect[3] - r - 1)]:
        pygame.gfxdraw.aacircle(surf, x, y, r, color)
        pygame.gfxdraw.filled_circle(surf, x, y, r, color)
    
    pygame.draw.rect(surf, color, (rect[0] + r, rect[1], rect[2] - 2*r, rect[3]))
    pygame.draw.rect(surf, color, (rect[0], rect[1] + r, rect[2], rect[3] - 2*r)) 
开发者ID:ankith26,项目名称:My-PyChess,代码行数:12,代码来源:utils.py

示例13: draw

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def draw(self, surface):
        self._render()

        if len(self._polygon_pos) > 2:
            gfxdraw.filled_polygon(surface, self._polygon_pos, self._background_color)

        if self.mouse_enabled and self._backbox:
            pygame.draw.rect(surface, self._font_selected_color, self._backbox_rect, 1)
            pygame.draw.polygon(surface, self._font_selected_color, self._backbox_pos)

        surface.blit(self._surface,
                     (self._rect.topleft[0] + self._offsetx,
                      self._rect.topleft[1] + self._offsety)) 
开发者ID:ppizarror,项目名称:pygame-menu,代码行数:15,代码来源:menubar.py

示例14: draw_head

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def draw_head(screen,origin,screensize):
    color=DARKGREY
    cx, cy, scale  = origin[0],origin[1], int(screensize[1]/4)
    headsize = (int(scale*2/3),scale)
    rx, ry = int(headsize[0]/2), int(headsize[1]/2)

    #ears
    color=BLACK
    earw, earh = scale/10, scale/4
    earrx, earry = int(scale/20), int(scale/8)
    pygame.gfxdraw.filled_ellipse(screen, cx-rx, cy, earrx, earry, color)
    pygame.gfxdraw.aaellipse(screen, cx-rx, cy, earrx, earry, color)
    pygame.gfxdraw.filled_ellipse(screen, cx+rx, cy, earrx, earry, color)
    pygame.gfxdraw.aaellipse(screen, cx+rx, cy, earrx, earry, color)


    # head proper
    color = DARKGREY

    headbox = (cx-headsize[0]/2, int(cy-scale/2), headsize[0], headsize[1])
    pygame.gfxdraw.filled_ellipse(screen, cx, cy, rx, ry, color)
    pygame.gfxdraw.aaellipse(screen, cx, cy, rx, ry, color)
    #head = pygame.draw.ellipse(screen, color, headbox)
    #nose
    noserad = int(scale/15)
    nose = pygame.draw.circle(screen, color, (cx,int(headbox[1]+noserad/4)), noserad  )
    return 
开发者ID:drscotthawley,项目名称:panotti,代码行数:29,代码来源:headgames.py

示例15: draw_gfxcircle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import gfxdraw [as 别名]
def draw_gfxcircle(self, x, y):
        p = self.pixel_size
        w_x = int(x * p + self.pixel_size / 2)
        w_y = int((self.height - 1 - y) * p + self.pixel_size / 2)
        r = int(self.pixel_size / 4)
        color = self.pixels[self.index(x, y)]
        pygame.gfxdraw.aacircle(self.screen, w_x, w_y, r, color)
        pygame.gfxdraw.filled_circle(self.screen, w_x, w_y, r, color) 
开发者ID:jayniz,项目名称:unicorn-hat-sim,代码行数:10,代码来源:__init__.py


注:本文中的pygame.gfxdraw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。