Esempio n. 1
0
    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)
Esempio n. 2
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)
Esempio n. 3
0
    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)