python类gfxdraw()的实例源码

gfxdraw_test.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_pie(self):
        """pie(surface, x, y, r, start, end, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x = 45
        y = 40
        r = 30
        start = 0  # +x direction, including (x + r, y)
        end = 90   # -y direction, but not (x, y + r) (?)
        fg_test_points = [(x, y),
                          (x + 1, y),
                          (x, y + 1),
                          (x + r, y)]
        bg_test_points = [(x - 1, y),
                          (x, y - 1),
                          (x - 1, y - 1),
                          (x + 1, y + 1),
                          (x + r + 1, y),
                          (x + r, y - 1),
                          (x, y + r)]
        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.pie(surf, x, y, r, start, end, 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)
gfxdraw_test.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_polygon(self):
        """polygon(surface, points, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        points = [(10, 80), (10, 15), (92, 25), (92, 80)]
        fg_test_points = (points +
                          [(points[0][0], points[0][1] - 1),
                           (points[0][0] + 1, points[0][1]),
                           (points[3][0] - 1, points[3][1]),
                           (points[3][0], points[3][1] - 1),
                           (points[2][0], points[2][1] + 1)])
        bg_test_points = [(points[0][0] - 1, points[0][1]),
                          (points[0][0], points[0][1] + 1),
                          (points[0][0] - 1, points[0][1] + 1),
                          (points[0][0] + 1, points[0][1] - 1),
                          (points[3][0] + 1, points[3][1]),
                          (points[3][0], points[3][1] + 1),
                          (points[3][0] + 1, points[3][1] + 1),
                          (points[3][0] - 1, points[3][1] - 1),
                          (points[2][0] + 1, points[2][1]),
                          (points[2][0] - 1, points[2][1] + 1),
                          (points[1][0] - 1, points[1][1]),
                          (points[1][0], points[1][1] - 1),
                          (points[1][0] - 1, points[1][1] - 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.polygon(surf, points, 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)
gfxdraw_test.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_aapolygon(self):
        """aapolygon(surface, points, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        points = [(10, 80), (10, 15), (92, 25), (92, 80)]
        fg_test_points = (points +
                          [(points[0][0], points[0][1] - 1),
                           (points[0][0] + 1, points[0][1]),
                           (points[3][0] - 1, points[3][1]),
                           (points[3][0], points[3][1] - 1),
                           (points[2][0], points[2][1] + 1)])
        bg_test_points = [(points[0][0] - 1, points[0][1]),
                          (points[0][0], points[0][1] + 1),
                          (points[0][0] - 1, points[0][1] + 1),
                          (points[0][0] + 1, points[0][1] - 1),
                          (points[3][0] + 1, points[3][1]),
                          (points[3][0], points[3][1] + 1),
                          (points[3][0] + 1, points[3][1] + 1),
                          (points[3][0] - 1, points[3][1] - 1),
                          (points[2][0] + 1, points[2][1]),
                          (points[2][0] - 1, points[2][1] + 1),
                          (points[1][0] - 1, points[1][1]),
                          (points[1][0], points[1][1] - 1),
                          (points[1][0] - 1, points[1][1] - 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.aapolygon(surf, points, 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)
gfxdraw_test.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_filled_polygon(self):
        """filled_polygon(surface, points, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        points = [(10, 80), (10, 15), (92, 25), (92, 80)]
        fg_test_points = (points +
                          [(points[0][0], points[0][1] - 1),
                           (points[0][0] + 1, points[0][1]),
                           (points[0][0] + 1, points[0][1] - 1),
                           (points[3][0] - 1, points[3][1]),
                           (points[3][0], points[3][1] - 1),
                           (points[3][0] - 1, points[3][1] - 1),
                           (points[2][0], points[2][1] + 1),
                           (points[2][0] - 1, points[2][1] + 1)])
        bg_test_points = [(points[0][0] - 1, points[0][1]),
                          (points[0][0], points[0][1] + 1),
                          (points[0][0] - 1, points[0][1] + 1),
                          (points[3][0] + 1, points[3][1]),
                          (points[3][0], points[3][1] + 1),
                          (points[3][0] + 1, points[3][1] + 1),
                          (points[2][0] + 1, points[2][1]),
                          (points[1][0] - 1, points[1][1]),
                          (points[1][0], points[1][1] - 1),
                          (points[1][0] - 1, points[1][1] - 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_polygon(surf, points, 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)
gfxdraw_test.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_textured_polygon(self):
        """textured_polygon(surface, points, texture, tx, ty): return None"""
        w, h = self.default_size
        fg = self.foreground_color
        bg = self.background_color
        tx = 0
        ty = 0
        texture = pygame.Surface((w + tx, h + ty), 0, 24)
        texture.fill(fg, (0, 0, w, h))
        points = [(10, 80), (10, 15), (92, 25), (92, 80)]
        # Don't know how to really check this as boarder points may
        # or may not be included in the textured polygon.
        fg_test_points = [(points[1][0] + 30, points[1][1] + 40)]
        bg_test_points = [(points[0][0] - 1, points[0][1]),
                          (points[0][0], points[0][1] + 1),
                          (points[0][0] - 1, points[0][1] + 1),
                          (points[3][0] + 1, points[3][1]),
                          (points[3][0], points[3][1] + 1),
                          (points[3][0] + 1, points[3][1] + 1),
                          (points[2][0] + 1, points[2][1]),
                          (points[1][0] - 1, points[1][1]),
                          (points[1][0], points[1][1] - 1),
                          (points[1][0] - 1, points[1][1] - 1)]
        for surf in self.surfaces[1:]:
            fg_adjusted = surf.unmap_rgb(surf.map_rgb(fg))
            bg_adjusted = surf.unmap_rgb(surf.map_rgb(bg))
            pygame.gfxdraw.textured_polygon(surf, points, texture, -tx, -ty)
            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)

        # Alpha blit to 8 bits-per-pixel surface forbidden.
        texture = pygame.Surface(self.default_size, SRCALPHA, 32)
        self.failUnlessRaises(ValueError,
                              pygame.gfxdraw.textured_polygon,
                              self.surfaces[0],
                              points,
                              texture, 0, 0)
game.py 文件源码 项目:LD35 作者: raffitz 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def renderstar(targetsurface,star):
    pygame.gfxdraw.pixel(targetsurface,int(star[0] + gamewidth//2 - px),int(star[1] + gameheight//2 + py),(star[2],star[2],star[2]))
game.py 文件源码 项目:AlphaBubble 作者: laurenssam 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def draw(self):
            pygame.gfxdraw.filled_circle(DISPLAYSURF, self.rect.centerx, self.rect.centery, self.radius, self.color)
            pygame.gfxdraw.aacircle(DISPLAYSURF, self.rect.centerx, self.rect.centery, self.radius, GRAY)
pieplate02.py 文件源码 项目:MVP2 作者: critterandguitari 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def draw(screen, mvp):
    global count
    #if mvp.half_note: 
    #    screen.fill((0,0,0))

    if True:
        count += 1  
        if count > mvp.knob4:
            count = 0
            screen.fill((0,0,0))

        x=random.randrange(0,700)
        y=random.randrange(0,400)
        pierad=random.randrange(10,) #radius
        arcstart=random.randrange(0,360)
        arcend=random.randrange(0, 360-arcstart)
        coloralpha=mvp.knob3/4
#        size = mvp.knob2
        color = (random.randrange(0,255), random.randrange(0,255), random.randrange(0,255), coloralpha)
#        width = mvp.knob1 // 50
#        if width == 0 : width = 1
#        if width > size : width = size 
        nestrange=mvp.knob1/8
        fanrange=mvp.knob2/10
        count=0
        for i in range(nestrange):
            count = i
            arcstart=random.randrange(0,360)
            arcend=random.randrange(0, 360-arcstart)
            for i in range(fanrange):
                pygame.gfxdraw.pie(screen, screen.get_width()/2, screen.get_height()/2, screen.get_height() - (count*screen.get_height()/nestrange), arcstart + i*fanrange, arcend - i*fanrange, color)

                #pygame.gfxdraw.pie(screen, screen.get_width()/2, screen.get_height()/2, (nestrange-count)*, arcstart + i*fanrange, arcend - i*fanrange, color)
#            time.sleep(.05)
            pygame.display.flip() #updates the display surface
        #screen.fill((0,0,0))
#        pygame.gfxdraw.pie(screen, x, y, pierad, 5, 50, color)
#        pygame.draw.circle(screen,color,[x,y],size, 0)
#        pygame.gfxdraw.aacircle(screen, x, y, size, color)

#pgyame.gfxdraw.pie(surface, x, y, radius, arcstart, arcend, color): return None
halftun.py 文件源码 项目:MVP2 作者: critterandguitari 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def draw(screen, mvp):

    if mvp.note_on:
        x=random.randrange(0,700)
        y=random.randrange(0,400)
        pierad=random.randrange(10,) #radius
        arcstart=random.randrange(0,360)
        arcend=random.randrange(0, 360-arcstart)
        coloralpha=mvp.knob3/4
#       size = mvp.knob2
        color = (random.randrange(0,255), random.randrange(0,255), random.randrange(0,255), coloralpha)
#       width = mvp.knob1 // 50
#       if width == 0 : width = 1
#       if width > size : width = size 
        nestrange=mvp.knob1/8
        fanrange=mvp.knob2/10
        count=0
        for i in range(nestrange):
            count = i
            arcstart=random.randrange(0,360)
            arcend=random.randrange(0, 360-arcstart)
            for i in range(fanrange):
                pygame.gfxdraw.pie(screen, screen.get_width()/2, screen.get_height(), screen.get_height() - (count*screen.get_height()/nestrange), arcstart + i*fanrange, arcend - i*fanrange, color)
                #pygame.gfxdraw.pie(screen, screen.get_width()/2, screen.get_height()/2, (nestrange-count)*, arcstart + i*fanrange, arcend - i*fanrange, color)
            pygame.display.flip() #updates the display surface





#pgyame.gfxdraw.pie(surface, x, y, radius, arcstart, arcend, color): return None
serious-pies-random-color.py 文件源码 项目:MVP2 作者: critterandguitari 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def draw(screen, mvp):

    global count
    if mvp.note_on:

        count += 1  
        if count > mvp.knob3:
            count = 0
            screen.fill((0,0,0))

        #if count > mvp.knob3 //
        x=random.randrange(0,700)
        y=random.randrange(0,400)
        pierad=random.randrange(10,100) #radius
        arcstart=random.randrange(0,360)
        arcend=random.randrange(0, 360-arcstart)
        size = mvp.knob2
        #color = (random.randrange(254,255), random.randrange(100,255), random.randrange(0,255))

        #color = pygame.Color(random.randrange(0,255), random.randrange(0,255), random.randrange(0,255), (float(mvp.knob4) / 1024) * 100)
        coloralpha=mvp.knob4/4
#        size = mvp.knob2
        color = (random.randrange(0,255), random.randrange(0,255), random.randrange(0,255), coloralpha)
        #color.hsva = ((float(mvp.knob4) / 1024) * 360, 100, 100, (float(mvp.knob4) / 1024) * 100)


        fillrange=mvp.knob1/10
        for i in range(fillrange):
            pygame.gfxdraw.pie(screen, x, y, size, arcstart + i*2, arcend - i*2, color)

#       pygame.gfxdraw.pie(screen, x, y, pierad, 5, 50, color)
#        pygame.draw.circle(screen,color,[x,y],size, 0)
#        pygame.gfxdraw.aacircle(screen, x, y, size, color)
#        pygame.gfxdraw.filled_circle(screen, x, y, size, color)

#pgyame.gfxdraw.pie(surface, x, y, radius, arcstart, arcend, color): return None
serious-pies.py 文件源码 项目:MVP2 作者: critterandguitari 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def draw(screen, mvp):

    global count
    if mvp.note_on:

        count += 1  
        if count > mvp.knob3:
            count = 0
            screen.fill((0,0,0))

        #if count > mvp.knob3 //
        x=random.randrange(0,700)
        y=random.randrange(0,400)
        pierad=random.randrange(10,100) #radius
        arcstart=random.randrange(0,360)
        arcend=random.randrange(0, 360-arcstart)
        size = mvp.knob2
        #color = (random.randrange(254,255), random.randrange(100,255), random.randrange(0,255))

        color = pygame.Color(random.randrange(0,255), random.randrange(0,255), random.randrange(0,255), 10)
#        size = mvp.knob2
        color.hsva = ((float(mvp.knob4) / 1024) * 360, 100, 100, 10)


        fillrange=mvp.knob1/10
        for i in range(fillrange):
            pygame.gfxdraw.pie(screen, x, y, size, arcstart + i*2, arcend - i*2, color)

#       pygame.gfxdraw.pie(screen, x, y, pierad, 5, 50, color)
#        pygame.draw.circle(screen,color,[x,y],size, 0)
#        pygame.gfxdraw.aacircle(screen, x, y, size, color)
#        pygame.gfxdraw.filled_circle(screen, x, y, size, color)

#pgyame.gfxdraw.pie(surface, x, y, radius, arcstart, arcend, color): return None
.py 文件源码 项目:MVP2 作者: critterandguitari 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def draw(screen, mvp):
    global count
    #if mvp.half_note: 
    #    screen.fill((0,0,0))

    if True:
        count += 1  
        if count > mvp.knob4:
            count = 0
            screen.fill((0,0,0))

        x=random.randrange(0,700)
        y=random.randrange(0,400)
        pierad=random.randrange(10,) #radius
        arcstart=random.randrange(0,360)
        arcend=random.randrange(0, 360-arcstart)
        coloralpha=mvp.knob3/4
#        size = mvp.knob2
        color = (random.randrange(0,255), random.randrange(0,255), random.randrange(0,255), coloralpha)
#        width = mvp.knob1 // 50
#        if width == 0 : width = 1
#        if width > size : width = size 
        nestrange=mvp.knob1/8
        fanrange=mvp.knob2/10
        count=0
        for i in range(nestrange):
            count = i
            arcstart=random.randrange(0,360)
            arcend=random.randrange(0, 360-arcstart)
            for i in range(fanrange):
                pygame.gfxdraw.pie(screen, screen.get_width()/2, screen.get_height()/2, screen.get_height() - (count*screen.get_height()/nestrange), arcstart + i*fanrange, arcend - i*fanrange, color)

                #pygame.gfxdraw.pie(screen, screen.get_width()/2, screen.get_height()/2, (nestrange-count)*, arcstart + i*fanrange, arcend - i*fanrange, color)
#            time.sleep(.05)
            pygame.display.flip() #updates the display surface
        #screen.fill((0,0,0))
#        pygame.gfxdraw.pie(screen, x, y, pierad, 5, 50, color)
#        pygame.draw.circle(screen,color,[x,y],size, 0)
#        pygame.gfxdraw.aacircle(screen, x, y, size, color)

#pgyame.gfxdraw.pie(surface, x, y, radius, arcstart, arcend, color): return None
pieplate.py 文件源码 项目:MVP2 作者: critterandguitari 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def draw(screen, mvp):

    global count
    if True:

        count += 1  
        if count > mvp.knob3:
            count = 0
            screen.fill((0,0,0))

        #if count > mvp.knob3 //
        x=random.randrange(0,700)
        y=random.randrange(0,400)
        pierad=random.randrange(10,100) #radius
        arcstart=random.randrange(0,360)
        arcend=random.randrange(0, 360-arcstart)
        size = mvp.knob2
        color = (random.randrange(0,255), random.randrange(0,255), random.randrange(0,255))


        fillrange=mvp.knob1/10
        for i in range(fillrange):
            pygame.gfxdraw.pie(screen, x, y, size, arcstart + i*2, arcend - i*2, color)

#       pygame.gfxdraw.pie(screen, x, y, pierad, 5, 50, color)
#        pygame.draw.circle(screen,color,[x,y],size, 0)
#        pygame.gfxdraw.aacircle(screen, x, y, size, color)
#        pygame.gfxdraw.filled_circle(screen, x, y, size, color)

#pgyame.gfxdraw.pie(surface, x, y, radius, arcstart, arcend, color): return None
trig-squares.py 文件源码 项目:MVP2 作者: critterandguitari 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def square(screen):
    x = random.randrange(0,screen.get_width())
    y = random.randrange(0,screen.get_height())
    color = (random.randrange(0,255), random.randrange(0,255), random.randrange(0,255))
    #pygame.draw.line(screen, color, [x, y], [x,y+100 ], 100)
    #pygame.draw.rect(screen, color, [x, y, x+100,y+100 ], 10)
    pygame.gfxdraw.box(screen, [x, y, x+100,y+100 ], color)
gfxdraw_test.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_pixel(self):
        """pixel(surface, x, y, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        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.pixel(surf, 2, 2, fg)
            for x in range(1, 4):
                for y in range(1, 4):
                    if x == 2 and y == 2:
                        self.check_at(surf, (x, y), fg_adjusted)
                    else:
                        self.check_at(surf, (x, y), bg_adjusted)
gfxdraw_test.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_rectangle(self):
        """rectangle(surface, rect, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        rect = pygame.Rect(10, 15, 55, 62)
        rect_tuple = tuple(rect)
        fg_test_points = [rect.topleft,
                          (rect.right - 1, rect.top),
                          (rect.left, rect.bottom - 1),
                          (rect.right - 1, rect.bottom - 1)]
        bg_test_points = [(rect.left - 1, rect.top - 1),
                          (rect.left + 1, rect.top + 1),
                          (rect.right, rect.top - 1),
                          (rect.right - 2, rect.top + 1),
                          (rect.left - 1, rect.bottom),
                          (rect.left + 1, rect.bottom - 2),
                          (rect.right, rect.bottom),
                          (rect.right - 2, rect.bottom - 2)]
        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.rectangle(surf, rect, 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)
            surf.fill(bg)
            pygame.gfxdraw.rectangle(surf, rect_tuple, 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)
gfxdraw_test.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_circle(self):
        """circle(surface, x, y, r, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x = 45
        y = 40
        r = 30
        fg_test_points = [(x, y - r),
                          (x, y + r),
                          (x - r, y),
                          (x + r, y)]
        bg_test_points = [(x, y),
                          (x, y - r + 1),
                          (x, y - r - 1),
                          (x, y + r + 1),
                          (x, y + r - 1),
                          (x - r - 1, y),
                          (x - r + 1, y),
                          (x + r + 1, y),
                          (x + r - 1, y)]
        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.circle(surf, x, y, r, 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)
gfxdraw_test.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_arc(self):
        """arc(surface, x, y, r, start, end, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x = 45
        y = 40
        r = 30
        start = 0  # +x direction, but not (x + r, y) (?)
        end = 90   # -y direction, including (x, y + r)
        fg_test_points = [(x, y + r), (x + r, y + 1)]
        bg_test_points = [(x, y),
                          (x, y - r),
                          (x - r, y),
                          (x, y + r + 1),
                          (x, y + r - 1),
                          (x - 1, y + r),
                          (x + r + 1, y),
                          (x + r - 1, y),
                          (x + r, y)]
        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.arc(surf, x, y, r, start, end, 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)
gfxdraw_test.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_aacircle(self):
        """aacircle(surface, x, y, r, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x = 45
        y = 40
        r = 30
        fg_test_points = [(x, y - r),
                          (x, y + r),
                          (x - r, y),
                          (x + r, y)]
        bg_test_points = [(x, y),
                          (x, y - r + 1),
                          (x, y - r - 1),
                          (x, y + r + 1),
                          (x, y + r - 1),
                          (x - r - 1, y),
                          (x - r + 1, y),
                          (x + r + 1, y),
                          (x + r - 1, y)]
        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.aacircle(surf, x, y, r, 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)
gfxdraw_test.py 文件源码 项目:AIFun 作者: Plottel 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_filled_circle(self):
        """filled_circle(surface, x, y, r, color): return None"""
        fg = self.foreground_color
        bg = self.background_color
        x = 45
        y = 40
        r = 30
        fg_test_points = [(x, y - r),
                          (x, y - r + 1),
                          (x, y + r),
                          (x, y + r - 1),
                          (x - r, y),
                          (x - r + 1, y),
                          (x + r, y),
                          (x + r - 1, y),
                          (x, y)]
        bg_test_points = [(x, y - r - 1),
                          (x, y + r + 1),
                          (x - r - 1, y),
                          (x + r + 1, y)]
        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_circle(surf, x, y, r, 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)


问题


面经


文章

微信
公众号

扫码关注公众号