     return gradient
 }
 
-func colorFromGradientRange(_ left: GradientColor, _ right: GradientColor, _ pos: Double) -> (Double, Double, Double) {
+func colorFromGradientRange(_ left: GradientColor, _ right: GradientColor, _ pos: Float) -> (Float, Float, Float) {
     let pos2 = (pos - left.pos) / (right.pos - left.pos)
 
     return (((right.r - left.r) * pos2) + left.r,

}

struct GradientColor {
    var pos: Double
    var r, g, b: Double
}

struct Gradient {

}


// Compare two float values for "enough" equality.
func equalEnough(_ a: Float, _ b: Float) -> Bool {
    let absA = abs(a)
    let absB = abs(b)

    return abs(absA - absB) <= max(absA, absB) * Float.ulpOfOne
}

func gradientGetIndexOfColorAtPosition(_ gradient: Gradient, _ pos: Float) -> Int? {
    for i in 0..<gradient.colors.count {
        if equalEnough(gradient.colors[i].pos, pos) {
            return i
