pixelarray_test.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Projects 作者: it2school 项目源码 文件源码
def test_compare(self):
        # __doc__ (as of 2008-06-25) for pygame.pixelarray.PixelArray.compare:

          # PixelArray.compare (array, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray
          # Compares the PixelArray with another one.

        w = 10
        h = 20
        size = w, h
        sf = pygame.Surface (size, 0, 32)
        ar = pygame.PixelArray (sf)
        sf2 = pygame.Surface (size, 0, 32)
        self.assertRaises (TypeError, ar.compare, sf2)
        ar2 = pygame.PixelArray (sf2)
        ar3 = ar.compare (ar2)
        self.assert_ (isinstance (ar3, pygame.PixelArray))
        self.assertEqual (ar3.shape, size)
        sf2.fill (pygame.Color ('white'))
        self.assert_surfaces_equal (sf2, ar3.surface)
        del ar3
        r = pygame.Rect (2, 5, 6, 13)
        sf.fill (pygame.Color ('blue'), r)
        sf2.fill (pygame.Color ('red'))
        sf2.fill (pygame.Color ('blue'), r)
        ar3 = ar.compare (ar2)
        sf.fill (pygame.Color ('white'), r)
        self.assert_surfaces_equal (sf, ar3.surface)

        # FINISH ME!
        # Test other bit depths, slices, and distance != 0.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号