Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/graphics/xocolor.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sugar/graphics/xocolor.py')
-rw-r--r--src/sugar/graphics/xocolor.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/sugar/graphics/xocolor.py b/src/sugar/graphics/xocolor.py
index beb9565..92a61a4 100644
--- a/src/sugar/graphics/xocolor.py
+++ b/src/sugar/graphics/xocolor.py
@@ -204,6 +204,7 @@ colors = [
['#BCCDFF', '#AC32FF'], \
]
+
def _parse_string(color_string):
if color_string == 'white':
return ['#ffffff', '#414141']
@@ -216,10 +217,13 @@ def _parse_string(color_string):
else:
return None
+
def is_valid(color_string):
return (_parse_string(color_string) != None)
+
class XoColor:
+
def __init__(self, color_string=None):
if color_string == None or not is_valid(color_string):
n = int(random.random() * (len(colors) - 1))
@@ -242,6 +246,7 @@ class XoColor:
def to_string(self):
return '%s,%s' % (self.stroke, self.fill)
+
if __name__ == "__main__":
import sys
import re