public void Equals_Same() { var first = new LuvColor(l: 10, u: 20.5, v: 45.445); var second = new LuvColor(l: 10, u: 20.5, v: 45.445); CustomAssert.EqualsWithHashCode(first, second); }
public void Equals_Different() { var first = new LuvColor(l: 11, u: 20.5, v: 45.445); var second = new LuvColor(l: 10, u: 20.5, v: 45.445); CustomAssert.NotEqualsWithHashCode(first, second); }
public void LuvColor() { var first = new LuvColor(10, 20.5, 45.445); var second = new LuvColor(10, 20.5, 45.445); Assert.Equal(first, (object)second); }
public void VectorCtor() { var first = new LuvColor(l: 10, u: 20.5, v: 45.445); var vector = new[] { 10, 20.5, 45.445 }; var second = new LuvColor(vector); CustomAssert.EqualsWithHashCode(first, second); Assert.Equal(vector, second.Vector); }
public void Dctor() { const double l1 = 10; const double u1 = 20.5; const double v1 = 45.445; var(l2, u2, v2) = new LuvColor(l1, u1, v1); Assert.Equal(l1, l2); Assert.Equal(u1, u2); Assert.Equal(v1, v2); }
public xyYColor ToxyY(LuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } XYZColor xyzColor = ToXYZ(color); xyYColor result = ToxyY(xyzColor); return(result); }
public HunterLabColor ToHunterLab(LuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } XYZColor xyzColor = ToXYZ(color); HunterLabColor result = ToHunterLab(xyzColor); return(result); }
public LChuvColor ToLChuv(XYZColor color) { if (color == null) { throw new ArgumentNullException("color"); } LuvColor luvColor = ToLuv(color); LChuvColor result = ToLChuv(luvColor); return(result); }
public LuvColor ToLuv(LChabColor color) { if (color == null) { throw new ArgumentNullException("color"); } XYZColor xyzColor = ToXYZ(color); LuvColor result = ToLuv(xyzColor); return(result); }
public LinearRGBColor ToLinearRGB(LuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } XYZColor xyzColor = ToXYZ(color); LinearRGBColor result = ToLinearRGB(xyzColor); return(result); }
public void LuvToRgb() { var inputLuv = new LuvColor(53.04, 140.97, 26.21); var rgbWorkingSpace = RGBWorkingSpaces.sRGB; var luvToRgb = new ConverterBuilder().FromLuv(rgbWorkingSpace.WhitePoint).ToRGB(rgbWorkingSpace).Build(); var outputRgb = luvToRgb.Convert(inputLuv); // RGB [R=0.94, G=0.2, B=0.25] Assert.Equal(0.9369894149662827, outputRgb.R); Assert.Equal(0.20000252466899038, outputRgb.G); Assert.Equal(0.2509774344647836, outputRgb.B); }
public void Convert_Luv_to_LChuv(double l, double u, double v, double l2, double c, double h) { // arrange var input = new LuvColor(l, u, v); // act LChuvColor output = Converter.ToLChuv(input); // assert Assert.That(output.L, Is.EqualTo(l2).Using(DoubleComparer)); Assert.That(output.C, Is.EqualTo(c).Using(DoubleComparer)); Assert.That(output.h, Is.EqualTo(h).Using(DoubleComparer)); }
public void Convert_Luv_to_LChuv(double l, double u, double v, double l2, double c, double h) { // arrange var input = new LuvColor(l, u, v); // act var output = Converter.ToLChuv(input); // assert Assert.Equal(output.L, l2, DoubleComparer); Assert.Equal(output.C, c, DoubleComparer); Assert.Equal(output.h, h, DoubleComparer); }
public void Convert_LChuv_to_Luv(double l, double c, double h, double l2, double u, double v) { // arrange var input = new LChuvColor(l, c, h); // act LuvColor output = Converter.ToLuv(input); // assert Assert.That(output.L, Is.EqualTo(l2).Using(DoubleComparer)); Assert.That(output.u, Is.EqualTo(u).Using(DoubleComparer)); Assert.That(output.v, Is.EqualTo(v).Using(DoubleComparer)); }
public void Convert_Luv_to_XYZ(double l, double u, double v, double x, double y, double z) { // arrange var input = new LuvColor(l, u, v, Illuminants.D65); var converter = new ColourfulConverter { WhitePoint = Illuminants.D65, TargetLuvWhitePoint = Illuminants.D65 }; // act XYZColor output = converter.ToXYZ(input); // assert Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparerXYZPrecision)); Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparerXYZPrecision)); Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparerXYZPrecision)); }
public void SamplesLuv() { // red var c1 = new LuvColor(53.04, 140.97, 26.21); // white var c2 = new LuvColor(100, 0, 0); // gray var c3 = new LuvColor(53.39, 0, 0); // black var c4 = new LuvColor(0, 0, 0); }
public void Convert_Luv_to_XYZ(double l, double u, double v, double x, double y, double z) { // arrange var input = new LuvColor(l, u, v, Illuminants.D65); var converter = new ColourfulConverter { WhitePoint = Illuminants.D65, TargetLuvWhitePoint = Illuminants.D65 }; // act var output = converter.ToXYZ(input); // assert Assert.Equal(output.X, x, DoubleComparerXYZPrecision); Assert.Equal(output.Y, y, DoubleComparerXYZPrecision); Assert.Equal(output.Z, z, DoubleComparerXYZPrecision); }
public void Convert_XYZ_to_Luv(double x, double y, double z, double l, double u, double v) { // arrange var input = new XYZColor(x, y, z); var converter = new ColourfulConverter { WhitePoint = Illuminants.D65, TargetLuvWhitePoint = Illuminants.D65 }; // act LuvColor output = converter.ToLuv(input); // assert Assert.That(output.L, Is.EqualTo(l).Using(DoubleComparerLuvPrecision)); Assert.That(output.u, Is.EqualTo(u).Using(DoubleComparerLuvPrecision)); Assert.That(output.v, Is.EqualTo(v).Using(DoubleComparerLuvPrecision)); }
public LChuvColor ToLChuv(LuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } // adaptation to target luv white point (LuvWhitePoint) LuvColor adapted = IsChromaticAdaptationPerformed ? Adapt(color) : color; // conversion (perserving white point) var converter = new LuvToLChuvConverter(); LChuvColor result = converter.Convert(adapted); return(result); }
public XYZColor ToXYZ(LChuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } // conversion to Luv var luvConverter = new LChuvToLuvConverter(); LuvColor labColor = luvConverter.Convert(color); // conversion to XYZ (incl. adaptation) XYZColor result = ToXYZ(labColor); return(result); }
public LuvColor ToLuv(XYZColor color) { if (color == null) { throw new ArgumentNullException("color"); } // adaptation XYZColor adapted = !WhitePoint.Equals(TargetLuvWhitePoint) && IsChromaticAdaptationPerformed ? ChromaticAdaptation.Transform(color, WhitePoint, TargetLuvWhitePoint) : color; // conversion var converter = new XYZToLuvConverter(TargetLuvWhitePoint); LuvColor result = converter.Convert(adapted); return(result); }
public XYZColor ToXYZ(LuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } // conversion var converter = new LuvToXYZConverter(); XYZColor unadapted = converter.Convert(color); // adaptation XYZColor adapted = color.WhitePoint.Equals(WhitePoint) || !IsChromaticAdaptationPerformed ? unadapted : Adapt(unadapted, color.WhitePoint); return(adapted); }
public LuvColor ToLuv <T>(T color) where T : IColorVector { if (color == null) { throw new ArgumentNullException("color"); } LuvColor converted = color as LuvColor; if (converted != null) { return(converted); } else { dynamic source = color; return(ToLuv(source)); } }
public LuvColor ToLuv(LChuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } // conversion (perserving white point) var converter = new LChuvToLuvConverter(); LuvColor unadapted = converter.Convert(color); if (!IsChromaticAdaptationPerformed) { return(unadapted); } // adaptation to target luv white point (LuvWhitePoint) LuvColor adapted = Adapt(unadapted); return(adapted); }
/// <summary> /// Adapts Luv color from the source white point to white point set in <see cref="TargetLuvWhitePoint"/>. /// </summary> public LuvColor Adapt(LuvColor color) { if (color == null) { throw new ArgumentNullException("color"); } if (!IsChromaticAdaptationPerformed) { throw new InvalidOperationException("Cannot perform chromatic adaptation, provide chromatic adaptation method and white point."); } if (color.WhitePoint.Equals(TargetLuvWhitePoint)) { return(color); } XYZColor xyzColor = ToXYZ(color); LuvColor result = ToLuv(xyzColor); return(result); }
public void ToString_Simple() { var color = new LuvColor(l: 10, u: 20.5, v: 45.445); Assert.Equal("Luv [L=10, u=20.5, v=45.45]", color.ToString()); }
/// <summary> /// Adapts Luv color from the source white point to white point set in <see cref="TargetLuvWhitePoint"/>. /// </summary> public LuvColor Adapt(LuvColor color) { if (color == null) throw new ArgumentNullException("color"); if (!IsChromaticAdaptationPerformed) throw new InvalidOperationException("Cannot perform chromatic adaptation, provide chromatic adaptation method and white point."); if (color.WhitePoint.Equals(TargetLuvWhitePoint)) return color; XYZColor xyzColor = ToXYZ(color); LuvColor result = ToLuv(xyzColor); return result; }