@@ -20,6 +20,7 @@ function! s:FGForBG(color)
20
20
endfunction
21
21
22
22
function ! s: MatchColorValue (color , pattern)
23
+ if ! len (a: color ) | return | endif
23
24
let group = ' cssColor' . tolower (a: color )
24
25
let pattern = a: pattern
25
26
if pattern = ~ ' \>$' | let pattern .= ' \>' | endif
@@ -48,7 +49,7 @@ endfunction
48
49
49
50
function ! s: HexForHSLValue (h ,s ,l )
50
51
" Convert 80% -> 0.8, 100% -> 1.0, etc.
51
- let [s ,l ] = map ( [a: s , a: l ], ' v:val =~ "%$" ? v:val / 100.0 : v:val * 1.0 ' )
52
+ let [s ,l ] = map ( [a: s , a: l ], ' v:val =~ "%$" ? v:val / 100.0 : str2float( v:val) ' )
52
53
" algorithm transcoded to vim from http://www.w3.org/TR/css3-color/#hsl-color
53
54
let hh = ( a: h % 360 ) / 360.0
54
55
let m2 = l <= 0.5 ? l * ( s + 1 ) : l + s - l * s
@@ -61,6 +62,7 @@ function! s:HexForHSLValue(h,s,l)
61
62
\ h * 2 < 1 ? m2 :
62
63
\ h * 3 < 2 ? m1 + ( m2 - m1 ) * ( 2 /3.0 - h ) * 6 :
63
64
\ m1
65
+ if v > 1.0 | return ' ' | endif
64
66
let rgb += [ float2nr ( 255 * v ) ]
65
67
endfor
66
68
return printf ( ' %02x%02x%02x' , rgb[0 ], rgb[1 ], rgb[2 ] )
0 commit comments