Refactored the darken formula in the color helper

This commit is contained in:
Nate Kane 2010-12-10 23:17:28 +10:00
parent f0097b53f5
commit cc79a2eca9

View File

@ -75,8 +75,8 @@ function! color_helper#hex_color_lighten(color, percent)
let l:rgb = color_helper#hex_color_to_rgb(a:color) let l:rgb = color_helper#hex_color_to_rgb(a:color)
let l:rgb_lightened = [] let l:rgb_lightened = []
for decimal in l:rgb for i in l:rgb
call add(l:rgb_lightened, float2nr(decimal * (a:percent + 1))) call add(l:rgb_lightened, float2nr(i + ((255 - i) * a:percent)))
endfor endfor
return color_helper#rgb_color_to_hex(l:rgb_lightened) return color_helper#rgb_color_to_hex(l:rgb_lightened)
@ -93,8 +93,8 @@ function! color_helper#hex_color_darken(color, percent)
let l:rgb = color_helper#hex_color_to_rgb(a:color) let l:rgb = color_helper#hex_color_to_rgb(a:color)
let l:rgb_darkened = [] let l:rgb_darkened = []
for decimal in l:rgb for i in l:rgb
call add(l:rgb_darkened, float2nr(decimal * (1 - a:percent))) call add(l:rgb_darkened, float2nr(i * (1 - a:percent)))
endfor endfor
return color_helper#rgb_color_to_hex(l:rgb_darkened) return color_helper#rgb_color_to_hex(l:rgb_darkened)