Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="color1"></param>
        /// <param name="color2"></param>
        /// <returns></returns>
        public static int DistanceRgb(ArgbRev color1, ArgbRev color2)
        {
            var r = Math.Abs(color1.R - color2.R);
            var g = Math.Abs(color1.G - color2.G);
            var b = Math.Abs(color1.B - color2.B);

            return(r * r + g * g + b * b);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="color1"></param>
        /// <param name="color2"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public static ArgbRev Mix(ArgbRev color1, ArgbRev color2, float offset = 0.5f)
        {
            var offset1A = MathUtils.FastClamp(offset, 0, 1);
            var offset2A = 1 - offset1A;

            var offset1C = offset1A * color1.Af;
            var offset2C = offset2A * color2.Af;

            MathUtils.NormalizeSum(ref offset1C, ref offset2C);

            return(new ArgbRev(
                       color1.A + color2.A,
                       (int)(color1.R * offset1C + color2.R * offset2C),
                       (int)(color1.G * offset1C + color2.G * offset2C),
                       (int)(color1.B * offset1C + color2.B * offset2C)
                       ));
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="color1"></param>
        /// <param name="color2"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public static ArgbRev Interpolate(ArgbRev color1, ArgbRev color2, float offset)
        {
            var offset1A = MathUtils.FastClamp(offset, 0, 1);
            var offset2A = 1 - offset1A;

            var offset1C = offset1A * (color1.Af);
            var offset2C = offset2A * (color2.Af);

            MathUtils.NormalizeSum(ref offset1C, ref offset2C);

            return(new ArgbRev(
                       (int)(color1.A * offset1A + color2.A * offset2A),
                       (int)(color1.R * offset1C + color2.R * offset2C),
                       (int)(color1.G * offset1C + color2.G * offset2C),
                       (int)(color1.B * offset1C + color2.B * offset2C)
                       ));
        }