コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="exact"></param>
        /// <returns></returns>
        public bool Equals(IHsbColorModel <byte> other, bool exact)
        {
            if (other == null)
            {
                return(false);
            }
            float b;

            if (exact)
            {
                if (other.Alpha.ToPercentage() != _alpha)
                {
                    return(false);
                }
                ColorExtensions.HSBtoRGB(other.Hue.ToDegrees(), other.Saturation.ToPercentage(), other.Brightness.ToPercentage(), out float r, out float g, out b);
                return(_red == r && _green == g && _blue == b);
            }

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

            if (!other.IsNormalized)
            {
                other = other.AsNormalized();
            }

            ColorExtensions.RGBtoHSB(_red, _green, _blue, out float h, out float s, out b);
            return(other.Hue == h.FromDegrees() && other.Saturation == s.FromPercentage() && other.Brightness == b.FromPercentage());
        }
コード例 #2
0
 /// <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(IHsbColorModel <float> other, bool exact)
 {
     if (other == null)
     {
         return(false);
     }
     if (exact)
     {
         return(_alpha.ToPercentage() == other.Alpha && _hue.ToDegrees() == other.Hue && _saturation.ToPercentage() == other.Saturation && _brightness.ToPercentage() == other.Brightness);
     }
     if (!other.IsNormalized)
     {
         other = other.AsNormalized();
     }
     return(_alpha == other.Alpha.FromPercentage() && _hue == other.Hue.FromDegrees() && _saturation == other.Saturation.FromPercentage() && _brightness == other.Brightness.FromPercentage());
 }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <param name="exact"></param>
        /// <returns></returns>
        public bool Equals(IHsbColorModel <float> other, bool exact)
        {
            if (other == null || _alpha != other.Alpha)
            {
                return(false);
            }

            float b;

            if (exact)
            {
                ColorExtensions.RGBtoHSB(_red, _green, _blue, out float h, out float s, out b);
                return(other.Hue == h && other.Saturation == s && other.Brightness == b);
            }

            if (!other.IsNormalized)
            {
                other = other.AsNormalized();
            }

            ColorExtensions.HSBtoRGB(other.Hue, other.Saturation, other.Brightness, out float r, out float g, out b);
            return(_red == r && _green == g && _blue == b);
        }