Permalink
Browse files

simplify s:pow to s:square

  • Loading branch information...
ap committed May 17, 2011
1 parent 1d77924 commit a3379d067b9190a71a25aa2f62d4c7a2a5612993
Showing with 3 additions and 6 deletions.
  1. +3 −6 after/syntax/css.vim
View
@@ -73,11 +73,8 @@ function! s:Xterm2rgb(color)
return rgb
endfunction
function! s:pow(x, n)
let x = a:x
for i in range(a:n-1)
let x = x*a:x
return x
function! s:square(x)
return a:x * a:x
endfunction
let s:colortable=[]
@@ -95,7 +92,7 @@ function! s:Rgb2xterm(color)
let g = s:hex[color[3:4]]
let b = s:hex[color[5:6]]
for c in range(0,254)
let d = s:pow(s:colortable[c][0]-r,2) + s:pow(s:colortable[c][1]-g,2) + s:pow(s:colortable[c][2]-b,2)
let d = s:square(s:colortable[c][0]-r) + s:square(s:colortable[c][1]-g) + s:square(s:colortable[c][2]-b)
if d<smallest_distance
let smallest_distance = d
let best_match = c

0 comments on commit a3379d0

Please sign in to comment.