Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/canvas/IconColor.py
blob: 042e27adb9e100af67d906be8655a448c76df8fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import random

from sugar.canvas import Colors

def is_valid(fill_color):
	return Colors.table.has_key(fill_color)

class IconColor:
	def __init__(self, fill_color=None):
		if fill_color == None:
			n = int(random.random() * (len(Colors.table) - 1))
			fill_color = Colors.table.keys()[n]
		else:
			if fill_color[0] == '#':
				fill_color = fill_color.upper()
			else:
				fill_color = fill_color.lower()
			if not Colors.table.has_key(fill_color):
				raise RuntimeError("Specified fill color %s is not allowed." % fill_color)
		self._fill_color = fill_color

	def get_stroke_color(self):
		return Colors.table[self._fill_color]

	def get_fill_color(self):
		return self._fill_color