public void RgbConversionTest() { RGBWorkingSpaces workingSpaces = new RGBWorkingSpaces(); ColorRGB rgb = new ColorRGB(0.741176470588235D, 0.513725490196078D, 0.580392156862745D); ColorLAB lab = new ColorLAB(new ColorXYZ(rgb, workingSpaces.SRGB_D65_Degree2), workingSpaces.SRGB_D65_Degree2); ColorHCL hcl = new ColorHCL(lab); Console.WriteLine(hcl); }
public void ColorToHCLToColor() { var ws = new RGBWorkingSpaces(); ColorRGB rgb = new ColorRGB(1, 0, 0); ColorXYZ xyz = new ColorXYZ(rgb, ws.Adobe_D65_Degree2); ColorLAB lab = new ColorLAB(xyz, ws.Adobe_D65_Degree2); ColorHCL hcl = new ColorHCL(lab); Console.WriteLine(hcl.ToColor()); }
public void ColorizationTest() { var workingspace = new RGBWorkingSpaces(); var hclColor = new ColorHCL(320, 3, 1); var lab = hclColor.ToLab(); ColorRGB rgb = new ColorRGB(new ColorXYZ(lab, workingspace.SRGB_D65_Degree2), workingspace.SRGB_D65_Degree2); Console.WriteLine(rgb.ToString()); }
public void LabToHCLToLab() { const double epsilon = 0.0001; var lab = new ColorLAB(1, 50, 10, 10); var hcl = new ColorHCL(lab); var hclToLab = hcl.ToLab(); Assert.Less(lab.Alpha - hclToLab.Alpha, epsilon); Assert.Less(lab.L - hclToLab.L, epsilon); Assert.Less(lab.A - hclToLab.A, epsilon); Assert.Less(lab.B - hclToLab.B, epsilon); }
public void GenerateFromLabTest() { const double epsilon = 0.01; //#4BC8E6 ColorLAB lab = new ColorLAB(1, 75, -25, -25); var hcl = new ColorHCL(lab); Console.WriteLine(lab); Console.WriteLine(hcl); Assert.Less(lab.Alpha - hcl.Alpha, epsilon); Assert.Less(hcl.H - 225, epsilon); Assert.Less(hcl.C - 35.355, epsilon); Assert.Less(hcl.L - 75, epsilon); }
/// <summary> /// Draws the GUI for the color property. /// </summary> /// <param name="position">Rectangle on the screen to use for the property GUI.</param> /// <param name="property">The SerializedProperty to make the custom GUI for.</param> /// <param name="label">The label of this property.</param> public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); var h = property.FindPropertyRelative("h"); var c = property.FindPropertyRelative("c"); var l = property.FindPropertyRelative("l"); var a = property.FindPropertyRelative("a"); var hcy = new ColorHCL(h.floatValue, c.floatValue, l.floatValue, a.floatValue); hcy = EditorGUI.ColorField(position, hcy); h.floatValue = hcy.h; c.floatValue = hcy.c; l.floatValue = hcy.l; a.floatValue = hcy.a; EditorGUI.EndProperty(); }
/// <summary> /// Initializes a color by converting the given HCL color to the CMY color space. /// </summary> /// <param name="hcl">The HCL color to convert to CMY.</param> public ColorCMY(ColorHCL hcl) { this = FromHCL(hcl.h, hcl.c, hcl.l, hcl.a); }