Beispiel #1
0
    def test_fit(self):

        # __doc__ (as of 2008-08-02) for pygame.rect.Rect.fit:

          # Rect.fit(Rect): return Rect
          # resize and move a rectangle with aspect ratio
          # 
          # Returns a new rectangle that is moved and resized to fit another.
          # The aspect ratio of the original Rect is preserved, so the new
          # rectangle may be smaller than the target in either width or height.

        r = Rect(10, 10, 30, 30)

        r2 = Rect(30, 30, 15, 10)

        f = r.fit(r2)
        self.assertTrue(r2.contains(f))
        
        f2 = r2.fit(r)
        self.assertTrue(r.contains(f2))
Beispiel #2
0
    def test_fit(self):

        # __doc__ (as of 2008-08-02) for pygame.rect.Rect.fit:

        # Rect.fit(Rect): return Rect
        # resize and move a rectangle with aspect ratio
        #
        # Returns a new rectangle that is moved and resized to fit another.
        # The aspect ratio of the original Rect is preserved, so the new
        # rectangle may be smaller than the target in either width or height.

        r = Rect(10, 10, 30, 30)

        r2 = Rect(30, 30, 15, 10)

        f = r.fit(r2)
        self.assertTrue(r2.contains(f))

        f2 = r2.fit(r)
        self.assertTrue(r.contains(f2))
Beispiel #3
0
 def test_contains( self ):
     r = Rect( 1, 2, 3, 4 )
     
     self.assertTrue( r.contains( Rect( 2, 3, 1, 1 ) ),
                      "r does not contain Rect(2,3,1,1)" )
     self.assertTrue( r.contains( Rect(r) ),
                      "r does not contain the same rect as itself" )
     self.assertTrue( r.contains( Rect(2,3,0,0) ),
                      "r does not contain an empty rect within its bounds" )
     self.assertFalse( r.contains( Rect(0,0,1,2) ),
                  "r contains Rect(0,0,1,2)" )
     self.assertFalse( r.contains( Rect(4,6,1,1) ),
                  "r contains Rect(4,6,1,1)" )
     self.assertFalse( r.contains( Rect(4,6,0,0) ),
                  "r contains Rect(4,6,0,0)" )
Beispiel #4
0
    def test_contains(self):
        r = Rect(1, 2, 3, 4)

        self.assertTrue(r.contains(Rect(2, 3, 1, 1)),
                        "r does not contain Rect(2,3,1,1)")
        self.assertTrue(r.contains(Rect(r)),
                        "r does not contain the same rect as itself")
        self.assertTrue(r.contains(Rect(2, 3, 0, 0)),
                        "r does not contain an empty rect within its bounds")
        self.assertFalse(r.contains(Rect(0, 0, 1, 2)),
                         "r contains Rect(0,0,1,2)")
        self.assertFalse(r.contains(Rect(4, 6, 1, 1)),
                         "r contains Rect(4,6,1,1)")
        self.assertFalse(r.contains(Rect(4, 6, 0, 0)),
                         "r contains Rect(4,6,0,0)")