     _pos = []
     _min = 0
     _max = 1
+    _correctLightness = false
     _numClasses = 0
 
     # private methods

            return i-1
        return 0

    classifyValue = (value) ->
        val = value
        if _domain.length > 2

        _spread = val
        f

    f.correctLightness = (v) ->
        if not arguments.length
            return _correctLightness
        _correctLightness = v
        if _correctLightness
            tmap = (t) ->
                L0 = getColor(0, true).lab()[0]
                L1 = getColor(1, true).lab()[0]
                pol = L0 > L1
                L_actual = getColor(t, true).lab()[0]
                L_ideal = L0 + (L1 - L0) * t
                L_diff = L_actual - L_ideal
                t0 = 0
                t1 = 1
                max_iter = 20
                while Math.abs(L_diff) > 1e-2 and max_iter-- > 0
                    do () ->
                        L_diff *= -1 if pol
                        if L_diff < 0
                            t0 = t
                            t += (t1 - t) * 0.5
                        else
                            t1 = t
                            t += (t0 - t) * 0.5
                        L_actual = getColor(t, true).lab()[0]
                        L_diff = L_actual - L_ideal
                t
        else
            tmap = (t) -> t
        f
    f

# some pre-defined color scales:
