The value of 'y' is being calculated incorrectly because it is using an x value that has been modified on the previous line when it should be using the value of x as it existed after the conversion from rgb. This update uses capital X Y Z variables to avoid this, following the example of the original formulas cited in the comments: https://gist.github.com/popcorn245/30afa0f98eea1c2fd34d
The value of 'y' is being calculated incorrectly because it is using an
x
value that has been modified on the previous line when it should be using the value ofx
as it existed after the conversion from rgb. This update uses capital X Y Z variables to avoid this, following the example of the original formulas cited in the comments: https://gist.github.com/popcorn245/30afa0f98eea1c2fd34d