public void Black_is_transformed_to_first_color_In_byte_array() { Color c1 = Color.FromArgb(unchecked ((int)0xFF_FF_FF_00)); Color c2 = Color.FromArgb(unchecked ((int)0xFF_00_FF_00)); var transformation = new ColorSchemeTransformation(c1.ToHsv(), c2.ToHsv()); var rgbValues = new byte[] { 0x00, 0x00, 0x00, 0xFF }; transformation.Transform(rgbValues, 0); var expectedTransformed = new byte[] { 0xFF, 0xFF, 0x00, 0xFF }; Assert.That(rgbValues, Is.EquivalentTo(expectedTransformed)); }
public void Brightness_adaptation_Interpolates_hue_saturation_and_value( [Values(0f, 0.5f, 1f)] float v, [Values(90f)] float c1h, [Values(-30f, 30f)] float dh) { HsvColor c1 = new HsvColor(c1h, 1f, 1f); HsvColor c2 = new HsvColor(c1h + dh, 1f, 1f); var transformation = new ColorSchemeTransformation(c1, c2); var sourceColor = new HsvColor(0, 0, v); var resultColor = transformation.Transform(sourceColor); Assert.That(resultColor.H, Is.EqualTo(c1.H + v * (c2.H - c1.H)).Within(0.01f)); Assert.That(resultColor.S, Is.EqualTo(c1.S + v * (c2.S - c1.S)).Within(0.01f)); Assert.That(resultColor.V, Is.EqualTo(c1.V + v * (c2.V - c1.V)).Within(0.01f)); }