I have the following elm function:
labToColor : { l : Float, a : Float, b : Float } -> Color
labToColor { l, a, b } =
let
y = (l + 16) / 116
x = y + a / 500
z = y - b / 200
y' = d y
x' =(d x) * 0.95047
z' = (d z) * 1.08883
r = x' * 3.2404542 + y' * -1.5371385 + z' * -0.4986
g = x' * -0.969266 + y' * 1.8760108 + z' * 4.1556e-2
b = x' * 5.56434e-2 + y' * 0.2040259 + z' * 1.0572252
in
Debug.log
"rgb"
(rgb
(round (f r) * 255)
(round (f g) * 255)
(round (f b) * 255)
)
Note the order of z and z' variable in the compiled result
var labToColor = function (_p0) {
var _p1 = _p0;
var y = (_p1.l + 16) / 116;
var x = y + _p1.a / 500;
var x$ = d(x) * 0.95047;
var y$ = d(y);
var b = x$ * 5.56434e-2 + y$ * 0.2040259 + z$ * 1.0572252;
var z$ = d(z) * 1.08883;
var z = y - _p1.b / 200;
var r = x$ * 3.2404542 + y$ * -1.5371385 + z$ * -0.4986;
var g = x$ * -0.969266 + y$ * 1.8760108 + z$ * 4.1556e-2;
return A2($Debug.log,
"rgb",
A3($Color.rgb,
$Basics.round(f(r)) * 255,
$Basics.round(f(g)) * 255,
$Basics.round(f(b)) * 255));
};
For some reasons now z' is used before z is declared. Is this a problem with the code or the compiler?