9
9
__maintainer__ = "Harsha Rani"
10
10
__email__ = "hrani@ncbs.res.in"
11
11
__status__ = "Development"
12
- __updated__ = "Jan 29 2019"
12
+ __updated__ = "Mar 11 2019"
13
13
14
14
import moose
15
15
import numpy as np
@@ -47,13 +47,13 @@ def getColor(iteminfo):
47
47
"""
48
48
textcolor = moose .element (iteminfo ).textColor
49
49
bgcolor = moose .element (iteminfo ).color
50
-
51
50
if (textcolor == '' ): textcolor = 'green'
52
51
53
52
if (bgcolor == '' ): bgcolor = 'orange'
54
53
55
54
if (textcolor == bgcolor ):
56
55
textcolor = getRandColor ()
56
+
57
57
textcolor = colorCheck (textcolor )
58
58
bgcolor = colorCheck (bgcolor )
59
59
# if moose.exists(iteminfo):
@@ -71,8 +71,7 @@ def colorCheck(fc_bgcolor):
71
71
fc_bgcolor = fc_bgcolor
72
72
elif fc_bgcolor .isdigit ():
73
73
""" color is int a map from int to r,g,b triplets from pickled color map file """
74
- tc = int (fc_bgcolor )
75
- tc = tc * 2
74
+ tc = (int (fc_bgcolor ))* 2
76
75
if tc < len (colorMap ):
77
76
pickledColor = colorMap [tc ]
78
77
else :
@@ -83,10 +82,16 @@ def colorCheck(fc_bgcolor):
83
82
fc_bgcolor = validColorcheck (fc_bgcolor )
84
83
85
84
else :
86
- for r in ['[' ,']' ]:
85
+ for r in ['[' ,']' , '(' , ')' ]:
87
86
fc_bgcolor = fc_bgcolor .replace (r ,"" )
88
- fc_bgcolor = '#%02x%02x%02x' % (eval (fc_bgcolor ))
89
-
87
+ fc_bgcolor = fc_bgcolor .split ("," )
88
+ c = 0
89
+ hexlist = "#"
90
+ for n in fc_bgcolor :
91
+ if c < 3 :
92
+ hexlist = hexlist + str ("%02x" % int (n ))
93
+ c = c + 1 ;
94
+ fc_bgcolor = hexlist
90
95
return (fc_bgcolor )
91
96
92
97
def validColorcheck (color ):
0 commit comments