all_names(): Return just the unique names of rgb colors
This commit is contained in:
parent
ad678af89b
commit
8be2594a24
|
@ -40,6 +40,8 @@ class ColorDB:
|
|||
# key is name, value is (red, green, blue)
|
||||
self.__byname = {}
|
||||
#
|
||||
# all unique names (non-aliases). built-on demand
|
||||
self.__allnames = None
|
||||
while 1:
|
||||
line = fp.readline()
|
||||
if not line:
|
||||
|
@ -102,6 +104,15 @@ class ColorDB:
|
|||
nearest_name = name
|
||||
return nearest_name
|
||||
|
||||
def all_names(self):
|
||||
# sorted
|
||||
if not self.__allnames:
|
||||
self.__allnames = []
|
||||
for name, aliases in self.__byrgb.values():
|
||||
self.__allnames.append(name)
|
||||
self.__allnames.sort()
|
||||
return self.__allnames
|
||||
|
||||
|
||||
class RGBColorDB(ColorDB):
|
||||
_re = re.compile(
|
||||
|
|
Loading…
Reference in New Issue