/// <summary>
        /// Indicates whether the current value is equal to another color model object.
        /// </summary>
        /// <param name="other">A color model to compare with this value.</param>
        /// <param name="exact"><c>true</c> to compare exact values; otherwise, <c>false</c> to compare normalized values.</param>
        /// <returns><c>true</c> if the current value is equal to another color model object; otherwise, <c>false</c>.</returns>
        public bool Equals(IRgbColorModel <float> other, bool exact)
        {
            if (other == null)
            {
                return(false);
            }
            float b;

            if (exact)
            {
                if (other.Alpha != _alpha.ToPercentage())
                {
                    return(false);
                }
                ColorExtensions.RGBtoHSB(other.Red, other.Green, other.Blue, out float h, out float s, out b);
                return(_hue.ToDegrees() == h && _saturation.ToDegrees() == s && _brightness.ToDegrees() == b);
            }

            if (other.Alpha.FromPercentage() != _alpha)
            {
                return(false);
            }

            ColorExtensions.HSBtoRGB(_hue.ToDegrees(), _saturation.ToPercentage(), _brightness.ToPercentage(), out float r, out float g, out b);
            return(other.Red == r.FromPercentage() && other.Green == g.FromPercentage() && other.Blue == b.FromPercentage());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="exact"></param>
        /// <returns></returns>
        public bool Equals(IRgbColorModel <byte> other, bool exact)
        {
            if (other == null)
            {
                return(false);
            }

            if (exact)
            {
                return(_alpha == other.Alpha.ToPercentage() && _red == other.Red.ToPercentage() && _green == other.Green.ToPercentage() && _blue == other.Blue.ToPercentage());
            }
            return(ToARGB() == other.ToARGB());
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="exact"></param>
        /// <returns></returns>
        public bool Equals(IRgbColorModel <float> other, bool exact)
        {
            if (other == null)
            {
                return(false);
            }

            if (exact)
            {
                return(_alpha.ToPercentage() == other.Alpha && _red.ToPercentage() == other.Red && _green.ToPercentage() == other.Green && _blue.ToPercentage() == other.Blue);
            }
            return(_alpha == other.Alpha.FromPercentage() && _red == other.Red.FromPercentage() && _green == other.Green.FromPercentage() && _blue == other.Blue.FromPercentage());
        }
        /// <summary>
        /// Indicates whether the current value is equal to another color model object.
        /// </summary>
        /// <param name="other">A color model to compare with this value.</param>
        /// <param name="exact"><c>true</c> to compare exact values; otherwise, <c>false</c> to compare normalized values.</param>
        /// <returns><c>true</c> if the current value is equal to another color model object; otherwise, <c>false</c>.</returns>
        public bool Equals(IRgbColorModel <byte> other, bool exact)
        {
            if (other == null || _alpha != other.Alpha)
            {
                return(false);
            }
            float b;

            if (exact)
            {
                ColorExtensions.RGBtoHSB(other.Red, other.Green, other.Blue, out float h, out float s, out b);
                return(_hue == h.FromDegrees() && _saturation == s.FromPercentage() && _brightness == b.FromPercentage());
            }
            ColorExtensions.HSBtoRGB(_hue, _saturation, _brightness, out float r, out float g, out b);
            return(other.Red == r.FromPercentage() && other.Green == g.FromPercentage() && other.Blue == b.FromPercentage());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="exact"></param>
        /// <returns></returns>
        public bool Equals(IRgbColorModel <float> other, bool exact)
        {
            if (other == null)
            {
                return(false);
            }
            if (exact)
            {
                if (other.Alpha != _alpha.ToPercentage())
                {
                    return(false);
                }
                ColorExtensions.RGBtoHSB(other.Red, other.Green, other.Blue, out float h, out float s, out float b);
                return(_hue.ToDegrees() == h && _saturation.ToDegrees() == s && _brightness.ToDegrees() == b);
            }

            return(AsNormalized().Equals(other, false));
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="exact"></param>
        /// <returns></returns>
        public bool Equals(IRgbColorModel <float> other, bool exact)
        {
            if (other == null || _alpha != other.Alpha)
            {
                return(false);
            }

            float b;

            if (exact)
            {
                ColorExtensions.RGBtoHSB(other.Red, other.Green, other.Blue, out float h, out float s, out b);
                return(_hue == h && _saturation == s && _brightness == b);
            }

            ColorExtensions.HSBtoRGB(_hue, _saturation, _brightness, out float r, out float g, out b);
            return(other.Red == r && other.Green == g && other.Blue == b);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="exact"></param>
        /// <returns></returns>
        public bool Equals(IRgbColorModel <byte> other, bool exact)
        {
            if (other == null)
            {
                return(false);
            }

            float b;

            if (exact)
            {
                if (other.Alpha.ToPercentage() != _alpha)
                {
                    return(false);
                }
                ColorExtensions.RGBtoHSB(other.Red.ToPercentage(), other.Green.ToPercentage(), other.Blue.ToPercentage(), out float h, out float s, out b);
                return(_hue == h && _saturation == s && _brightness == b);
            }

            return(AsNormalized().Equals(other, false));
        }
Beispiel #8
0
 /// <summary>
 /// Merges a source <see cref="IColorModel"/> with 1 or more <seealso cref="IColorModel"/> objects by averaging average their values.
 /// </summary>
 /// <typeparam name="T">Value component type.</typeparam>
 /// <param name="source"></param>
 /// <param name="other"></param>
 /// <param name="additionalColors"></param>
 /// <returns></returns>
 public static IRgbColorModel <T> MergeAverage <T>(this IRgbColorModel <T> source, IRgbColorModel <T> other, params IRgbColorModel <T>[] additionalColors)
     where T : struct, IComparable, IFormattable, IConvertible, IComparable <T>, IEquatable <T>
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Indicates whether the current value is equal to another color model object.
 /// </summary>
 /// <param name="other">A color model to compare with this value.</param>
 /// <returns><c>true</c> if the current value is equal to another color model object; otherwise, <c>false</c>.</returns>
 public bool Equals(IRgbColorModel <byte> other)
 {
     return(Equals(other, false));
 }
Beispiel #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(IRgbColorModel <float> other)
 {
     return(other.Alpha == _alpha && other.Red == _red && other.Green == _green && other.Blue == _blue);
 }