diff gamelib/imagecache.py @ 159:7bb8d9d6858a

Darken center of game over splash screen to make text legible.
author Simon Cross <hodgestar@gmail.com>
date Thu, 03 Sep 2009 22:00:28 +0000
parents f20dd3dcb118
children 7e556ef40100
line wrap: on
line diff
--- a/gamelib/imagecache.py	Thu Sep 03 21:50:49 2009 +0000
+++ b/gamelib/imagecache.py	Thu Sep 03 22:00:28 2009 +0000
@@ -56,8 +56,9 @@
 
 # modifiers
 
-from pygame.locals import BLEND_RGBA_MULT
+from pygame.locals import BLEND_RGBA_MULT, BLEND_MULT
 NIGHT_COLOUR = (100.0, 100.0, 200.0, 255.0)
+DARKEN_COLOUR = (100.0, 100.0, 100.0, 255.0)
 
 def convert_to_night(image):
     """Convert a day tile to a night tile."""
@@ -70,9 +71,20 @@
     right_facing_image = pygame.transform.flip(right_facing_image, 1, 0)
     return right_facing_image
 
+def darken_center(image):
+    darkened = image.copy()
+    w, h = darkened.get_size()
+    w, h = int(w*0.5), int(h*0.5)
+    x, y = int(w*0.5), int(h*0.5)
+    overlay = pygame.Surface((w, h))
+    overlay.fill(DARKEN_COLOUR)
+    darkened.blit(overlay, (x,y), None, BLEND_MULT)
+    return darkened
+
 # globals
 
 cache = ImageCache()
 cache.register_modifier("night", convert_to_night)
 cache.register_modifier("right_facing", convert_to_right_facing)
+cache.register_modifier("darken_center", darken_center)
 load_image = cache.load_image