@@ -16,35 +16,20 @@ var Colorscale = require('../components/colorscale');
16
16
var colorDflt = require ( '../components/color/attributes' ) . defaultLine ;
17
17
var isArrayOrTypedArray = require ( './array' ) . isArrayOrTypedArray ;
18
18
19
- function filterRGBA ( colorIn , desiredType ) {
20
- var colorOut = rgba ( colorIn , desiredType ) ;
21
-
22
- if ( typeof colorIn === 'string' &&
23
- ! colorIn . indexOf ( 'rgb' ) &&
24
- colorIn . indexOf ( 'rgba' )
25
- ) {
26
- // drop alpha if not having rgb
27
- colorOut = [ colorOut [ 0 ] , colorOut [ 1 ] , colorOut [ 2 ] ] ;
28
- }
29
- return colorOut ;
30
- }
31
-
32
- var colorDfltRgba = filterRGBA ( colorDflt ) ;
19
+ var colorDfltRgba = rgba ( colorDflt ) ;
33
20
var opacityDflt = 1 ;
34
21
35
22
function calculateColor ( colorIn , opacityIn ) {
36
23
var colorOut = colorIn ;
37
-
38
- if ( colorOut . length > 3 ) colorOut [ 3 ] *= opacityIn ;
39
- else if ( opacityIn < 1 ) colorOut [ 3 ] = opacityIn ;
40
-
24
+ colorOut [ 3 ] *= opacityIn ;
41
25
return colorOut ;
42
26
}
43
27
44
28
function validateColor ( colorIn ) {
45
29
if ( isNumeric ( colorIn ) ) return colorDfltRgba ;
46
30
47
- var colorOut = filterRGBA ( colorIn ) ;
31
+ var colorOut = rgba ( colorIn ) ;
32
+
48
33
return colorOut . length ? colorOut : colorDfltRgba ;
49
34
}
50
35
@@ -69,7 +54,7 @@ function formatColor(containerIn, opacityIn, len) {
69
54
if ( isArrayColorIn ) {
70
55
getColor = function ( c , i ) {
71
56
// FIXME: there is double work, considering that sclFunc does the opposite
72
- return c [ i ] === undefined ? colorDfltRgba : filterRGBA ( sclFunc ( c [ i ] ) ) ;
57
+ return c [ i ] === undefined ? colorDfltRgba : rgba ( sclFunc ( c [ i ] ) ) ;
73
58
} ;
74
59
} else getColor = validateColor ;
75
60
@@ -85,7 +70,7 @@ function formatColor(containerIn, opacityIn, len) {
85
70
opacityi = getOpacity ( opacityIn , i ) ;
86
71
colorOut [ i ] = calculateColor ( colori , opacityi ) ;
87
72
}
88
- } else colorOut = calculateColor ( filterRGBA ( colorIn ) , opacityIn ) ;
73
+ } else colorOut = calculateColor ( rgba ( colorIn ) , opacityIn ) ;
89
74
90
75
return colorOut ;
91
76
}
@@ -111,7 +96,6 @@ function parseColorScale(cont, alpha) {
111
96
}
112
97
113
98
module . exports = {
114
- filterRGBA : filterRGBA ,
115
99
formatColor : formatColor ,
116
100
parseColorScale : parseColorScale
117
101
} ;
0 commit comments