     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,

    }
}

func mandelbrotColorize(_ imageWidth: Int, _ imageHeight: Int, _ maxIterations: Int, _ gradient: Gradient, _ imageData: inout [UInt8], _ histogram: [Int], _ iterationsPerPixel: [Int], _ smoothedDistancesToNextIterationPerPixel: [Double], _ normalizedColors: inout [Double]) {
    // Sum all iterations, not counting the last one at position histogram[max_iterations] (which
    // are points in the Mandelbrot Set).
    var totalIterations = 0

            let pixel = pixelY * imageWidth + pixelX

            if iter < maxIterations {
                smoothedDistancesToNextIterationPerPixel[pixel] = 1.0 - Float(min(1.0, (log(log(finalMagnitude)) - logLogBailout) / log2))
                histogram[iter] += 1  // no need to count histogram[max_iterations]
            }

