Beispiel #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)
Beispiel #2
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)
Beispiel #3
0
    def todo_test_pygame2_mask_Mask_erase(self):

        # __doc__ (as of 2008-11-03) for pygame2.mask.Mask.erase:

        # Mask.erase (mask, x, y) -> None
        # 
        # Erases the passed Mask from the Mask.
        # 
        # This performs a bitwise NAND operation upon the calling Mask.
        # The passed mask's start offfset for the erase operation will
        # be the x and y offset passed to the method.
        
        m1 = Mask (10, 10)
        m1.fill ()
        m2 = Mask (10, 10)
        m2.fill ()
 
        m1.erase (m2, 0, 0)
        self.assertEqual (m1.count, 0)

        m1.fill ()
        m1.erase (m2, 1, 1)
        self.assertEqual (m1.count, 19)

        m1.fill ()
        m1.erase (m2, 2, 0)
        self.assertEqual (m1.count, 20)

        m1.fill ()
        m1.erase (m2, 0, 10)
        self.assertEqual (m1.count, 100)
        m1.fill ()
        m1.erase (m2, 10, 0)
        self.assertEqual (m1.count, 100)

        m1.fill ()
        m1.erase (m2, -1, 0)
        self.assertEqual (m1.count, 10)
        m1.fill ()
        m1.erase (m2, 0, -1)
        self.assertEqual (m1.count, 10)