illume avatar illume committed bc8f95f

Adding a surface.fill test with negative coordinates.

Comments (0)

Files changed (1)

test/surface_test.py

         for pt in test_utils.rect_outer_bounds(fill_rect):
             self.assert_(s1.get_at(pt) != color )
 
+
+
+    def test_fill_negative_coordinates(self):
+
+        # negative coordinates should be clipped by fill, and not draw outside the surface.
+        color = (25, 25, 25, 25)
+        color2 = (20, 20, 20, 25)
+        fill_rect = pygame.Rect(-10, -10, 16, 16)
+        
+        s1 = pygame.Surface((32,32), pygame.SRCALPHA, 32)
+        s1.fill(color, fill_rect)   
+        c = s1.get_at((0,0))
+        self.assertEqual(c, color)
+
+        # make subsurface in the middle.
+        s2 = s1.subsurface((5, 5, 5, 5))
+        s2.fill(color2, (-3, -3, 5, 5))
+        c2 = s1.get_at((4,4))
+        self.assertEqual(c, color)
+
+
+
+
     def test_fill_keyword_args(self):
         color = (1, 2, 3, 255)
         area = (1, 1, 2, 2)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.