def test_pygame2_mask_Mask_draw(self): # __doc__ (as of 2008-11-03) for pygame2.mask.Mask.draw: # Mask.draw (mask, x, y) -> None # # Draws the passed Mask onto the Mask. # # This performs a bitwise OR operation upon the calling Mask. The # passed mask's start offset for the draw operation will be the x and # y offset passed to the method. m = Mask (100, 100) self.assertEqual(m.count, 0) m.fill() self.assertEqual(m.count, 10000) m2 = Mask (10,10) m2.fill() m.erase (m2, (50, 50)) self.assertEqual(m.count, 9900) m.invert() self.assertEqual(m.count, 100) m.draw(m2, (0,0)) self.assertEqual(m.count, 200) m.clear() self.assertEqual(m.count, 0)
def test_pygame2_mask_Mask_count(self): # __doc__ (as of 2008-11-03) for pygame2.mask.Mask.count: # Gets the amount of bits in the Mask. m = Mask (10, 10) for x in range (10): for y in range (10): m.set_at (x, y) self.assertEqual (m.count, 100) m.clear () self.assertEqual (m.count, 0)
def test_convolve__with_output(self): """checks that convolution modifies only the correct portion of the output""" m = random_mask((10,10)) k = Mask((2,2)) k.set_at((0,0)) o = Mask((50,50)) test = Mask((50,50)) m.convolve(k,o) test.draw(m,(1,1)) self.assertMaskEquals(o, test) o.clear() test.clear() m.convolve(k,o, (10,10)) test.draw(m,(11,11)) self.assertMaskEquals(o, test)
def test_drawing (self): """ Test fill, clear, invert, draw, erase """ m = Mask((100,100)) self.assertEqual(m.count, 0) m.fill() self.assertEqual(m.count, 10000) m2 = Mask((10,10)) m2.fill() m.erase(m2, (50,50)) self.assertEqual(m.count, 9900) m.invert() self.assertEqual(m.count, 100) m.draw(m2, (0,0)) self.assertEqual(m.count, 200) m.clear() self.assertEqual(m.count, 0)