         right = gradient.colors[i]
 
         if pos >= left.pos && pos <= right.pos {
-            colorFromGradientRange(left, right, pos, &r, &g, &b)
-            return true
+            return colorFromGradientRange(left, right, pos)
         }
 
         left = right
     }
 
-    return false
+    return (0.0, 0.0, 0.0)
 }
 
 func mandelbrotCalc(_ imageWidth: Int, _ imageHeight: Int, _ maxIterations: Int, _ centerX: Double, _ centerY: Double, _ height: Double, _ histogram: inout [Int], _ iterationsPerPixel: inout [Int], _ smoothedDistancesToNextIterationPerPixel: inout [Double]) {

    return gradient
}

func colorFromGradientRange(_ left: GradientColor, _ right: GradientColor, _ pos: Double, _ r: inout Double, _ g: inout Double, _ b: inout Double) {
    let pos2 = (pos - left.pos) / (right.pos - left.pos)

    r = ((right.r - left.r) * pos2) + left.r
    g = ((right.g - left.g) * pos2) + left.g
    b = ((right.b - left.b) * pos2) + left.b
}

func colorFromGradient(_ gradient: Gradient, _ posInGradient: Double, _ r: inout Double, _ g: inout Double, _ b: inout Double) -> Bool {
    var pos = posInGradient

    if (pos < 0.0) {


            histogram[iter] += 1
            iterationsPerPixel[pixelY * imageWidth + pixelX] = iter  // 1 .. max_iterations
        }
    }
}
