From 3ac42866682cf389fecc0d4f089f4db07095dcd9 Mon Sep 17 00:00:00 2001 From: David Raison Date: Sat, 30 Aug 2014 17:24:11 +0200 Subject: [PATCH] Moved color surface away --- interface/hud.py | 10 ++-------- support/colors.py | 1 - support/operations.py | 8 ++++++++ 3 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 support/operations.py diff --git a/interface/hud.py b/interface/hud.py index 4f04e70..99d2c0f 100644 --- a/interface/hud.py +++ b/interface/hud.py @@ -3,6 +3,7 @@ import os, pygame from pygame.locals import * from support.colors import * +from support import operations class Hud: @@ -29,7 +30,7 @@ class Hud: timesurface = pygame.Surface((200, 20)) hourglass = pygame.image.load(os.path.join('img', 'hourglass.png')).convert_alpha() hourglass = pygame.transform.scale(hourglass, (15, 18)) - self.color_surface(hourglass, WHITE) + operations.color_surface(hourglass, WHITE) time = self.font.render(str(time), 1, WHITE) timesurface.blit(hourglass, (0, 0)) timesurface.blit(time, (40, 0)) @@ -37,10 +38,3 @@ class Hud: def draw_fps(self, fps): return self.font.render('fps: ' + str(fps), 10, RED) - - def color_surface(self,surface, color): - red, green, blue = color - arr = pygame.surfarray.pixels3d(surface) - arr[:,:,0] = red - arr[:,:,1] = green - arr[:,:,2] = blue diff --git a/support/colors.py b/support/colors.py index d6f6c16..a21a54b 100644 --- a/support/colors.py +++ b/support/colors.py @@ -124,4 +124,3 @@ WHITE=(255,255,255) BLACK=(0,0,0) #-----------End of colors-----------# - diff --git a/support/operations.py b/support/operations.py new file mode 100644 index 0000000..97b8f89 --- /dev/null +++ b/support/operations.py @@ -0,0 +1,8 @@ +import pygame + +def color_surface(surface, color): + red, green, blue = color + arr = pygame.surfarray.pixels3d(surface) + arr[:,:,0] = red + arr[:,:,1] = green + arr[:,:,2] = blue