Exemple #1
0
        public static Rgba32 Map(ColorRange fromRange, Rgba32 color, ColorRange toRange)
        {
            float redColorPositionInRange   = fromRange.From.R / fromRange.To.R;
            float greenColorPositionInRange = fromRange.From.G / fromRange.To.G;
            float blueColorPositionInRange  = fromRange.From.B / fromRange.To.B;

            var absoluteColorDifference = GetAbsoluteColorDifference(fromRange.From, fromRange.To);

            return(new Rgba32()
            {
                R = (byte)((absoluteColorDifference.R * redColorPositionInRange) + toRange.From.R),
                G = (byte)((absoluteColorDifference.G * greenColorPositionInRange) + toRange.From.G),
                B = (byte)((absoluteColorDifference.B * blueColorPositionInRange) + toRange.From.B),
                A = 255
            });
        }