|
2 | 2 | import sys
|
3 | 3 | import unittest
|
4 | 4 | import warnings
|
| 5 | +import itertools |
5 | 6 |
|
6 | 7 | import pygame
|
7 | 8 | from pygame import draw
|
@@ -7312,8 +7313,8 @@ class to add any draw.arc specific tests to.
|
7312 | 7313 | """
|
7313 | 7314 |
|
7314 | 7315 |
|
7315 |
| -class DrawFloodFillMixin(unittest.TestCase): |
7316 |
| - """Mixin tests for flood fill.""" |
| 7316 | +class DrawFloodFillTest(unittest.TestCase): |
| 7317 | + """Tests for flood fill.""" |
7317 | 7318 |
|
7318 | 7319 | def test_flood_fill(self):
|
7319 | 7320 | """Ensures flood fill fills with solid color"""
|
@@ -7356,6 +7357,37 @@ def test_flood_pattern(self):
|
7356 | 7357 | for pt in [(0, 0), (0, 1), (1, 0), (1, 1)]:
|
7357 | 7358 | self.assertEqual(surf.get_at(pt), pattern.get_at(pt), pt)
|
7358 | 7359 |
|
| 7360 | + def test_flood_circle(self): |
| 7361 | + """Ensures flood fill doesn't overdraw""" |
| 7362 | + surf = pygame.Surface((100, 100)) |
| 7363 | + surf.fill((0, 0, 0)) |
| 7364 | + pygame.draw.circle(surf, (255,0,255), (50,50), 40, 2) |
| 7365 | + pygame.draw.flood_fill(surf, (255,255,255), (10, 50)) |
| 7366 | + |
| 7367 | + surf2 = pygame.Surface((100, 100)) |
| 7368 | + surf2.fill((0, 0, 0)) |
| 7369 | + pygame.draw.circle(surf2, (255,255,255), (50,50), 40, 2) |
| 7370 | + |
| 7371 | + for pt in itertools.product(range(100), range(100)): |
| 7372 | + self.assertEqual(surf.get_at(pt), surf2.get_at(pt)) |
| 7373 | + |
| 7374 | + surf = pygame.Surface((100, 100)) |
| 7375 | + surf.fill((0, 0, 0)) |
| 7376 | + pygame.draw.circle(surf, (255,0,255), (50,50), 40, 1) |
| 7377 | + # fill outside of circle white |
| 7378 | + pygame.draw.flood_fill(surf, (255,255,255), (1,1)) |
| 7379 | + # fill inside red |
| 7380 | + pygame.draw.flood_fill(surf, (255,0,0), (50,50)) |
| 7381 | + |
| 7382 | + surf2 = pygame.Surface((100, 100)) |
| 7383 | + surf2.fill((255,255,255)) |
| 7384 | + # draw filled circle red |
| 7385 | + pygame.draw.circle(surf2, (255,0,0), (50,50), 40) |
| 7386 | + # fill circle hot pink |
| 7387 | + pygame.draw.circle(surf2, (255,0,255), (50,50), 40, 1) |
| 7388 | + |
| 7389 | + for pt in itertools.product(range(100), range(100)): |
| 7390 | + self.assertEqual(surf.get_at(pt), surf2.get_at(pt)) |
7359 | 7391 |
|
7360 | 7392 | ### Draw Module Testing #######################################################
|
7361 | 7393 |
|
|
0 commit comments