Exemplo n.º 1
0
    def test_pygame2_base_Rect_clip(self):

        # __doc__ (as of 2008-10-17) for pygame2.base.Rect.clip:

        # Rect.clip (Rect) -> Rect
        # 
        # Crops a rectangle inside another.
        # 
        # Returns a new rectangle that is cropped to be completely
        # inside the argument Rect. If the two rectangles do not overlap
        # to begin with, a Rect with 0 size is returned. Thus it returns
        # the area, in which both rects overlap.
        r1 = Rect( 1, 2, 3, 4 )
        self.assertEqual( Rect( 1, 2, 2, 2 ), r1.clip( Rect(0,0,3,4) ) )
        self.assertEqual( Rect( 2, 2, 2, 4 ), r1.clip( Rect(2,2,10,20) ) )
        self.assertEqual( Rect(2,3,1,2), r1.clip( Rect(2,3,1,2) ) )
        self.assertEqual( (0,0), r1.clip(Rect (20,30,5,6)).size )
        self.assertEqual( r1, r1.clip( Rect(r1) ),
                          "r1 does not clip an identical rect to itself" )