Skip to content

Commit 7012bdf

Browse files
more interesting cases for flood fill tests
1 parent 7047eca commit 7012bdf

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

test/draw_test.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import unittest
44
import warnings
5+
import itertools
56

67
import pygame
78
from pygame import draw
@@ -7312,8 +7313,8 @@ class to add any draw.arc specific tests to.
73127313
"""
73137314

73147315

7315-
class DrawFloodFillMixin(unittest.TestCase):
7316-
"""Mixin tests for flood fill."""
7316+
class DrawFloodFillTest(unittest.TestCase):
7317+
"""Tests for flood fill."""
73177318

73187319
def test_flood_fill(self):
73197320
"""Ensures flood fill fills with solid color"""
@@ -7356,6 +7357,37 @@ def test_flood_pattern(self):
73567357
for pt in [(0, 0), (0, 1), (1, 0), (1, 1)]:
73577358
self.assertEqual(surf.get_at(pt), pattern.get_at(pt), pt)
73587359

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))
73597391

73607392
### Draw Module Testing #######################################################
73617393

0 commit comments

Comments
 (0)