Esempio n. 1
0
            internal static void ToColorSpace(IRgb color, ILuv item)
            {
                var xyz   = new Xyz();
                var white = XyzConverter.WhiteReference;

                xyz.Initialize(color);

                var y = xyz.Y / XyzConverter.WhiteReference.Y;

                item.L = y > XyzConverter.Epsilon ? 116.0 * XyzConverter.CubicRoot(y) - 16.0 : XyzConverter.Kappa * y;

                var targetDenominator    = GetDenominator(xyz);
                var referenceDenominator = GetDenominator(white);
                // ReSharper disable CompareOfFloatsByEqualityOperator
                var xTarget = targetDenominator == 0
                    ? 0
                    : ((4.0 * xyz.X / targetDenominator) - (4.0 * white.X / referenceDenominator));
                var yTarget = targetDenominator == 0
                    ? 0
                    : ((9.0 * xyz.Y / targetDenominator) - (9.0 * white.Y / referenceDenominator));

                // ReSharper restore CompareOfFloatsByEqualityOperator

                item.U = 13.0 * item.L * xTarget;
                item.V = 13.0 * item.L * yTarget;
            }
Esempio n. 2
0
        internal static void ToColorSpace(IRgb color, ILab item)
        {
            var xyz = new Xyz();
            xyz.Initialize(color);

            var x = PivotXyz(xyz.X/RefX);
            var y = PivotXyz(xyz.Y/RefY);
            var z = PivotXyz(xyz.Z/RefZ);

            item.L = Math.Max(0,116*y - 16);
            item.A = 500*(x - y);
            item.B = 200*(y - z);
        }
Esempio n. 3
0
        internal static void ToColorSpace(IRgb color, IYxy item)
        {
            var xyz = new Xyz();
            xyz.Initialize(color);

            item.Y1 = xyz.Y;

            var xDividend = xyz.X + xyz.Y + xyz.Z;
            item.X = xDividend.BasicallyEqualTo(0) ? 0.0 : xyz.X / xDividend;

            var y2Dividend = xyz.X + xyz.Y + xyz.Z;
            item.Y2 = y2Dividend.BasicallyEqualTo(0) ? 0.0 : xyz.Y / (xyz.X + xyz.Y + xyz.Z);
        }
Esempio n. 4
0
        internal static void ToColorSpace(IRgb color, ILab item)
        {
            var xyz = new Xyz();
            xyz.Initialize(color);

            var white = XyzConverter.WhiteReference;
            var x = PivotXyz(xyz.X / white.X);
            var y = PivotXyz(xyz.Y / white.Y);
            var z = PivotXyz(xyz.Z / white.Z);

            item.L = Math.Max(0, 116 * y - 16);
            item.A = 500 * (x - y);
            item.B = 200 * (y - z);
        }
Esempio n. 5
0
        internal static void ToColorSpace(IRgb color, ILab item)
        {
            var xyz = new Xyz();

            xyz.Initialize(color);

            var x = PivotXyz(xyz.X / RefX);
            var y = PivotXyz(xyz.Y / RefY);
            var z = PivotXyz(xyz.Z / RefZ);

            item.L = Math.Max(0, 116 * y - 16);
            item.A = 500 * (x - y);
            item.B = 200 * (y - z);
        }
Esempio n. 6
0
        internal static void ToColorSpace(IRgb color, ILab item)
        {
            var xyz = new Xyz();

            xyz.Initialize(color);

            var white = XyzConverter.WhiteReference;
            var x     = PivotXyz(xyz.X / white.X);
            var y     = PivotXyz(xyz.Y / white.Y);
            var z     = PivotXyz(xyz.Z / white.Z);

            item.L = Math.Max(0, 116 * y - 16);
            item.A = 500 * (x - y);
            item.B = 200 * (y - z);
        }
Esempio n. 7
0
        internal static void ToColorSpace(IRgb color, IYxy item)
        {
            var xyz = new Xyz();

            xyz.Initialize(color);

            item.Y1 = xyz.Y;

            var xDividend = xyz.X + xyz.Y + xyz.Z;

            item.X = xDividend.BasicallyEqualTo(0) ? 0.0 : xyz.X / xDividend;

            var y2Dividend = xyz.X + xyz.Y + xyz.Z;

            item.Y2 = y2Dividend.BasicallyEqualTo(0) ? 0.0 : xyz.Y / (xyz.X + xyz.Y + xyz.Z);
        }
Esempio n. 8
0
        internal static void ToColorSpace(IRgb color, ILuv item)
        {
            var xyz = new Xyz();
            var white = XyzConverter.WhiteReference;
            xyz.Initialize(color);

            var y = xyz.Y / XyzConverter.WhiteReference.Y;
            item.L = y > XyzConverter.Epsilon ? 116.0 * XyzConverter.CubicRoot(y) - 16.0 : XyzConverter.Kappa * y;

            var targetDenominator = GetDenominator(xyz);
            var referenceDenominator = GetDenominator(white);
            // ReSharper disable CompareOfFloatsByEqualityOperator
            var xTarget = targetDenominator == 0 ? 0 : ((4.0 * xyz.X / targetDenominator) - (4.0 * white.X / referenceDenominator));
            var yTarget = targetDenominator == 0 ? 0 : ((9.0 * xyz.Y / targetDenominator) - (9.0 * white.Y / referenceDenominator));
            // ReSharper restore CompareOfFloatsByEqualityOperator

            item.U = 13.0 * item.L * xTarget;
            item.V = 13.0 * item.L * yTarget;
        }