public void ToHsv_ShouldBeCorrect_AtMaxHue() { var hsv = Hsl.FromScaledValues(360, 50, 50).ToHsv(); hsv.RoundedScaledHue.ShouldBe(360); hsv.RoundedScaledSaturation.ShouldBe(66.67); hsv.RoundedScaledValue.ShouldBe(75); }
public void Darker_ShouldDecreaseLightness() { var hsl = Hsl.FromScaledValues(240, 100, 20); hsl.Darker(5).ShouldBeEquivalentTo(hsl.WithScaledLuminance(15)); hsl.Darker(11).ShouldBeEquivalentTo(hsl.WithScaledLuminance(9)); hsl.Darker(30).ShouldBeEquivalentTo(hsl.WithScaledLuminance(0)); }
public void ToRgb_ShouldBeCorrect_AtMaxHue() { var rgb = Hsl.FromScaledValues(360, 50, 50).ToRgb(); rgb.ScaledRed.ShouldBeEquivalentTo(191); rgb.ScaledGreen.ShouldBeEquivalentTo(64); rgb.ScaledBlue.ShouldBeEquivalentTo(64); }
public void Lighter_ShouldIncreaseLightness() { var hsl = Hsl.FromScaledValues(240, 100, 80); hsl.Lighter(5).ShouldBeEquivalentTo(hsl.WithScaledLuminance(85)); hsl.Lighter(11).ShouldBeEquivalentTo(hsl.WithScaledLuminance(91)); hsl.Lighter(30).ShouldBeEquivalentTo(hsl.WithScaledLuminance(100)); }
public void ToHsv_ShouldBeCorrect_AtDecimals() { var hsv = Hsl.FromScaledValues(60.2, 53, 70.91).ToHsv(); hsv.RoundedScaledHue.ShouldBe(60.2); hsv.RoundedScaledSaturation.ShouldBe(35.72); hsv.RoundedScaledValue.ShouldBe(86.33); }
public void Luminance_ShouldBeClamped() { var hsl = Hsl.FromScaledValues(120, 0, -1); hsl.ScaledLuminance.ShouldBe(0); hsl = Hsl.FromScaledValues(120, 0, 101); hsl.ScaledLuminance.ShouldBe(100); }
public void RoundedScaledLuminance_ShouldRound() { // Half-up var hsl = Hsl.FromScaledValues(240, 100, 59.645); hsl.RoundedScaledLuminance.ShouldBe(59.65); // Down hsl = Hsl.FromScaledValues(240, 100, 59.644); hsl.RoundedScaledLuminance.ShouldBe(59.64); }
public void RoundedScaledSaturation_ShouldRound() { // Half-up var hsl = Hsl.FromScaledValues(240, 59.645, 100); hsl.RoundedScaledSaturation.ShouldBe(59.65); // Down hsl = Hsl.FromScaledValues(240, 59.644, 100); hsl.RoundedScaledSaturation.ShouldBe(59.64); }
public void RoundedScaledHue_ShouldRound() { // Half-up var hsl = Hsl.FromScaledValues(240.585, 1, 50); hsl.RoundedScaledHue.ShouldBe(240.59); // Down hsl = Hsl.FromScaledValues(240.584, 1, 50); hsl.RoundedScaledHue.ShouldBe(240.58); }
public void ToRgb_ShouldBeCorrect_AtDecimals() { var rgb = Hsl.FromScaledValues(60.2, 53, 70.91).ToRgb(); rgb.ScaledRed.ShouldBeEquivalentTo(220); rgb.ScaledGreen.ShouldBeEquivalentTo(220); rgb.ScaledBlue.ShouldBeEquivalentTo(142); rgb = Hsl.FromScaledValues(60.5, 53, 70.91).ToRgb(); rgb.ScaledRed.ShouldBeEquivalentTo(219); rgb.ScaledGreen.ShouldBeEquivalentTo(220); rgb.ScaledBlue.ShouldBeEquivalentTo(142); }
// Conversion tool for reference: // https://www.easyrgb.com/en/convert.php#inputFORM public IEnumerable <object[]> GetData(MethodInfo methodInfo) { yield return(new object[] { new ColorData { Name = "Black", Rgb = new Rgb(0, 0, 0), Hsl = new Hsl(0, 0, 0), Hsv = new Hsv(0, 0, 0), Cmyk = new Cmyk(0, 0, 0, 1), Xyz = new Xyz(0, 0, 0), Lab = new Lab(0, 0, 0) } }); yield return(new object[] { new ColorData { Name = "White", Rgb = new Rgb(1, 1, 1), Hsl = new Hsl(0, 0, 1), Hsv = new Hsv(0, 0, 1), Cmyk = new Cmyk(0, 0, 0, 0), Xyz = new Xyz(95.047, 100, 108.883), Lab = new Lab(100, 0, 0) } }); yield return(new object[] { new ColorData { Name = "Red", Rgb = new Rgb(1, 0, 0), Hsl = new Hsl(0, 1, 0.5), Hsv = new Hsv(0, 1, 1), Cmyk = new Cmyk(0, 1, 1, 0), Xyz = new Xyz(41.2456, 21.2673, 1.9334), Lab = new Lab(53.2408, 80.0925, 67.2032) } }); yield return(new object[] { new ColorData { Name = "Green", Rgb = new Rgb(0, 1, 0), Hsl = Hsl.FromScaledValues(120, 100, 50), Hsv = Hsv.FromScaledValues(120, 100, 100), Cmyk = new Cmyk(1, 0, 1, 0), Xyz = new Xyz(35.7576, 71.5152, 11.9192), Lab = new Lab(87.7347, -86.1827, 83.1793) } }); yield return(new object[] { new ColorData { Name = "Blue", Rgb = new Rgb(0, 0, 1), Hsl = Hsl.FromScaledValues(240, 100, 50), Hsv = Hsv.FromScaledValues(240, 100, 100), Cmyk = new Cmyk(1, 1, 0, 0), Xyz = new Xyz(18.0437, 7.2175, 95.0304), Lab = new Lab(32.297, 79.1875, -107.8602) } }); yield return(new object[] { new ColorData { Name = "Material Blue", Rgb = Rgb.FromScaledValues(33, 150, 243), Hsl = Hsl.FromScaledValues(206.5716, 89.744, 54.118), Hsv = Hsv.FromScaledValues(206.5716, 86.42, 95.294), Cmyk = Cmyk.FromScaledValues(86.419753, 38.271604, 0, 4.705882), Xyz = new Xyz(27.704960365063513, 28.60350077011483, 88.83745176406208), Lab = new Lab(60.4301, 2.0799, -55.1094) } }); yield return(new object[] { new ColorData { Name = "Purple HEX to HSL/HSV issue", Rgb = Rgb.FromScaledValues(116, 58, 111), Hsl = Hsl.FromScaledValues(305.172, 33.333, 34.118), Hsv = Hsv.FromScaledValues(305.172, 50, 45.49), Cmyk = Cmyk.FromScaledValues(0, 50, 4.310, 54.510), Xyz = new Xyz(11.5846, 7.8875, 15.9481), Lab = new Lab(33.7475, 33.4761, -19.6542) } }); }
public void Saturation_ShouldBeClamped() { Hsl.FromScaledValues(120, -1, 100).ScaledSaturation.ShouldBe(0); Hsl.FromScaledValues(120, 101, 100).ScaledSaturation.ShouldBe(100); }
public void Hue_ShouldBeClamped() { Hsl.FromScaledValues(-0.01, 100, 100).ScaledHue.ShouldBe(0); Hsl.FromScaledValues(360.01, 100, 100).ScaledHue.ShouldBe(360); }