private TestColor TestColorHSB()
        {
            var color = ColorHSB.FromColor(testColor);

            var color2      = (ColorRGB)color.ToRgb();;
            var nativeValue = string.Format("H:{0:0.0#} S:{1:0.0#} B:{2:0.0#}", color.H, color.S, color.B);

            return(new TestColor {
                Name = "HSB", Value = color2.ToHex(), NativeValue = nativeValue
            });
        }
Пример #2
0
        public void RGBtoHSBConversion()
        {
            var rgb          = ColorRGB.FromHex("#6653B2");
            var hsb          = (ColorHSB)ColorHSB.FromColor(rgb);
            var rgbConverted = (ColorRGB)hsb.ToRgb();

            // HSL
            Assert.AreEqual(hsb.Hue, 252);
            Assert.AreEqual(hsb.Saturation, 53.37);
            Assert.AreEqual(hsb.Brightness, 69.8);

            // RGB Converted
            Assert.AreEqual(rgbConverted.Red, 102);
            Assert.AreEqual(rgbConverted.Green, 83);
            Assert.AreEqual(rgbConverted.Blue, 178);
        }