Move colour definitions into constants
authorNeil <neil@dip.sun.ac.za>
Sat, 10 Sep 2016 09:54:15 +0000 (11:54 +0200)
committerNeil <neil@dip.sun.ac.za>
Sat, 10 Sep 2016 09:54:15 +0000 (11:54 +0200)
tabakrolletjie/constants.py
tabakrolletjie/lights.py

index 66150336c4e0120bcadf741ac5a8c154e132c77c..5529b60693245f2ce269588263dc422194c6b6e7 100644 (file)
@@ -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),
+}
index 3c25188db77a944ab70c3fa1b9f706c79c345f7d..119a13a3c46c545512499f87807d7feda2dc70e0 100644 (file)
@@ -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)