From: Neil Date: Sat, 10 Sep 2016 09:54:15 +0000 (+0200) Subject: Move colour definitions into constants X-Git-Tag: tabakrolletjie-v1.0.0~135 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=9fcb41e6949ccb27107eb1a40d16c7d7722f8207;p=tabakrolletjie.git Move colour definitions into constants --- diff --git a/tabakrolletjie/constants.py b/tabakrolletjie/constants.py index 6615033..5529b60 100644 --- a/tabakrolletjie/constants.py +++ b/tabakrolletjie/constants.py @@ -38,3 +38,14 @@ BUFFER = 1024 DEFAULT_VOLUME = 1.0 NO_SOUND = os.environ.get("TABAK_NO_SOUND", "").lower() in ("1", "y", "yes") + +# Color constants +COLOURS = { + "red": (255, 0, 0), + "green": (0, 255, 0), + "blue": (0, 0, 255), + "cyan": (0, 255, 255), + "yellow": (255, 255, 0), + "magenta": (255, 0, 255), + "white": (255, 255, 255), +} diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index 3c25188..119a13a 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -8,7 +8,7 @@ import pygame.draw import pygame.locals as pgl import pygame.rect -from .constants import LIGHT_CATEGORY, FITTINGS_CATEGORY +from .constants import LIGHT_CATEGORY, FITTINGS_CATEGORY, COLOURS from .rays import RayPolyManager from .utils import DetailedTimer from .loader import loader @@ -99,16 +99,6 @@ class LightManager(object): class BaseLight(object): """ Common light functionality. """ - COLOURS = { - "red": (255, 0, 0), - "green": (0, 255, 0), - "blue": (0, 0, 255), - "cyan": (0, 255, 255), - "yellow": (255, 255, 0), - "magenta": (255, 0, 255), - "white": (255, 255, 255), - } - # defaults RAY_MANAGER = RayPolyManager FITTING_IMG = None @@ -165,7 +155,7 @@ class BaseLight(object): return surf def light_colour(self): - light_colour = self.COLOURS[self.colour] + light_colour = COLOURS[self.colour] intensity = int(255 * self.intensity) return light_colour + (intensity,) @@ -211,7 +201,7 @@ class BaseLight(object): def fitting_image(self): if self._fitting_image is None: - fitting_colour = self.COLOURS[self.colour] + fitting_colour = COLOURS[self.colour] self._fitting_image = loader.load_image( "48", self.FITTING_IMG, transform=Multiply(colour=fitting_colour)) @@ -236,7 +226,7 @@ class Lamp(BaseLight): class MultiColourLamp(BaseLight): FITTING_IMG = "lamp.png" - DEFAULT_COLOURS = sorted(BaseLight.COLOURS.keys()) + DEFAULT_COLOURS = sorted(COLOURS.keys()) def __init__(self, **kw): self.colour_cycle = kw.pop("colours", None)