public List<Color> GenerateColors(int colorCount) { var colors = new List<Color>(); var cellRange = 1f/colorCount; var cellOffset = Random.NextDouble()*cellRange; for (var i = 0; i < colorCount; i++) { var newHue = cellRange*i + cellOffset; if (newHue > 1) { newHue -= 1; } newHue *= 360; var hue = Convert.ToUInt16(newHue); var hslColor = new HSL(hue, 0.3f, 0.4f); colors.Add(hslColor); } return colors; }
public void HSLToRGBIsConvertedCorrectly(ushort hue, float saturation, float luminance, Color expected) { var sut = new HSL(hue, saturation, luminance); Color actual = sut; Assert.Equal(expected, actual); }
public void ZeroSaturationRendersColorFactoredByLuminance(ushort hue, float luminance) { var hueValue = (ushort) (hue%360); var luminanceValue = luminance%1; var hsl = new HSL(hueValue, 0, luminanceValue); Color actual = hsl; var colorValue = luminanceValue/1*255; var expectedColorValue = Convert.ToInt32(colorValue); var expected = Color.FromArgb(expectedColorValue, expectedColorValue, expectedColorValue); Assert.Equal(expected, actual); }