public void AllColors_DoesNotContain_DuplicateColors(Chrominance chroma, Luma luma)
        {
            byte value = new Color(chroma, luma).Value;
            IEnumerable <byte> allValues = Color.GetAllColors().Select(c => c.Value);

            Assert.DoesNotContain(value, allValues);
        }
        public void Parse_ParsesValidNames(string name, Chrominance chroma, Luma luma)
        {
            Color c = Color.Parse(name);

            Assert.Equal(name, c.Name);
            Assert.Equal(chroma, c.Chrominance);
            Assert.Equal(luma, c.Luma);
        }
        /// <summary>
        /// Determines whether two <see cref="Chrominance"/> instances are equal.
        /// </summary>
        /// <param name="other">The instance to compare.</param>
        /// <returns>true if the specified <see cref="Chrominance"/> is equal to the current <see cref="Chrominance"/>; otherwise, false.</returns>
        public bool Equals(Chrominance other)
        {
            if (Cb != other.Cb)
            {
                return(false);
            }

            return(Cr == other.Cr);
        }
        /// <summary>
        /// Determines whether two chrominances are close to each others.
        /// </summary>
        /// <param name="other">The instance to compare.</param>
        /// <param name="maxSquaredDistance">The maximum squared euclidian distance to consider the two chrominances as being close.</param>
        /// <returns></returns>
        public bool IsClose(Chrominance other, int maxSquaredDistance)
        {
            int cbDistance = this.Cb - other.Cb;
            int crDsitance = this.Cr - other.Cr;
            int distance   = cbDistance * cbDistance + crDsitance * crDsitance;

            if (distance <= maxSquaredDistance)
            {
                return(true);
            }

            return(false);
        }
        public void Name_BasedOnChromaAndLuma(Chrominance chroma, Luma luma, string name)
        {
            var color = new Color(chroma, luma);

            Assert.Equal(name, color.Name);
        }
        public void Value_BasedOnChromaAndLuma(Chrominance chroma, Luma luma, byte value)
        {
            var color = new Color(chroma, luma);

            Assert.Equal(value, color.Value);
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of a <see cref="Blend"/>.
 /// </summary>
 /// <param name="chrominance">The chrominance of the blend.</param>
 /// <param name="distance">The distance of the blend.</param>
 public Blend(Chrominance chrominance, int distance)
 {
     Chrominance = chrominance;
     Distance    = distance;
 }
 /// <summary>
 /// Determines whether two chrominances are close to each others.
 /// </summary>
 /// <param name="other">The instance to compare.</param>
 /// <returns>true if the specified <see cref="Chrominance"/> is close to the current <see cref="Chrominance"/>; otherwise, false.</returns>
 /// <remarks>
 /// The method considers the maximum squared euclidean distance to be close is 150.
 /// </remarks>
 public bool IsClose(Chrominance other)
 {
     return(IsClose(other, 150));
 }
Example #9
0
 public Color(Chrominance chroma, Luma luma) =>
 (this.Chrominance, this.Luma) = (chroma, luma);