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.
评论列表
文章目录