       _G = from_linear res[1][0]
       _B = from_linear res[2][0]
       [_R, _G, _B]
-    from: = (tuple) ->
-      _R = tuple[0]
-      _G = tuple[1]
-      _B = tuple[2]
+    from: (_R, _G, _B) ->
       to_linear = (c) ->
         a = 0.055
         if c <= 0.04045

          ab[i].push dot_product get_row(a, i), get_col(b, j)
  return ab

# Reference white point used for CIE Lab conversion
white_point = [95.047, 100.000, 108.883]

# Functions for converting between CIE XYZ and other color spaces

      _a = 500 * (f(_X) - f(_Y))
      _b = 200 * (f(_Y) - f(_Z))
      [_L, _a, _b]
    from: (_L, _a, _b) ->
      f_inv = (t) ->
        if t > 6 / 29
          Math.pow(t, 3)
        else
          3 * Math.pow(6 / 29, 2) * (t - 4 / 29)
      _Y = white_point[1] * f_inv 1 / 116 * (_L + 16)
      _X = white_point[0] * f_inv 1 / 116 * (_L + 16) + 1 / 500 * _a
      _Z = white_point[2] * f_inv 1 / 116 * (_L + 16) - 1 / 200 * _b
      [_X, _Y, _Z]
  _CIELCH:
    to: (_X, _Y, _Z) ->
      [_L, _a, _b] = conv._CIELAB.to([_X, _Y, _Z])
      _C = Math.pow Math.pow(_a, 2) + Math.pow(_b, 2), 1 / 2
      _h = Math.atan2 _b, _a
      [_L, _C, _h]
    from: (_L, _C, _h) ->
      _h_rad = _h / 360 * 2 * Math.PI
      _a = Math.cos(_h_rad) * _C
      _b = Math.sin(_h_rad) * _C
      conv._CIELAB.from([_L, _a, _b])

get_color = (space, tuple) ->
  color = conv["_" + space].from(tuple...)
  as: (space) ->
    conv["_" + space].to(color...)

if jQuery?
  exports =
