@@ -91,6 +91,24 @@ NodeArray.prototype = {
91
91
let key = obj . key ;
92
92
if ( ! key )
93
93
return null ;
94
+
95
+ if ( 'color.rgb' in obj && 3 == obj [ 'color.rgb' ] . length ) {
96
+ let rgb = obj [ 'color.rgb' ] ;
97
+ let hsl = Raphael . rgb2hsl ( { r :rgb [ 0 ] , g :rgb [ 1 ] , b :rgb [ 2 ] } ) ;
98
+ obj . hue = hsl . h ;
99
+ }
100
+ else if ( 'color.hue' in obj ) {
101
+ let hue = obj [ 'color.hue' ] ;
102
+ if ( Array . isArray ( hue ) )
103
+ obj . hue = hue [ 0 ] ;
104
+ else
105
+ obj . hue = hue ;
106
+ if ( obj . hue > 1 ) {
107
+ // constrain and normalize
108
+ obj . hue = ( obj . hue & 0xFFFFFF ) / 0xFFFFFF ;
109
+ }
110
+ }
111
+
94
112
if ( key in this . contents ) {
95
113
let prop , existing = this . contents [ key ] ;
96
114
let updated = false ;
@@ -109,23 +127,7 @@ NodeArray.prototype = {
109
127
if ( this . obj_type == 'device' ) {
110
128
obj . signals = new NodeArray ( 'signal' , this . cb_func ) ;
111
129
112
- if ( 'color.rgb' in obj && 3 == obj [ 'color.rgb' ] . length ) {
113
- let rgb = obj [ 'color.rgb' ] ;
114
- let hsl = Raphael . rgb2hsl ( { r :rgb [ 0 ] , g :rgb [ 1 ] , b :rgb [ 2 ] } ) ;
115
- obj . hue = hsl . h ;
116
- }
117
- else if ( 'color.hue' in obj ) {
118
- let hue = obj [ 'color.hue' ] ;
119
- if ( 1 == hue . length )
120
- obj . hue = hue ;
121
- else
122
- obj . hue = hue [ 0 ] ;
123
- if ( obj . hue > 1 ) {
124
- // constrain and normalize
125
- obj . hue = ( obj . hue & 0xFFFFFF ) / 0xFFFFFF ;
126
- }
127
- }
128
- else {
130
+ if ( ! ( 'hue' in obj ) || obj . hue == 'undefined' ) {
129
131
// create hue hash
130
132
hueHash = function ( str ) {
131
133
var hash = 0 , i , chr ;
0 commit comments