Example #1
0
 public void TestPicker_SL_H()
 {
     Color rgb = Color.green;
     float expected = ((HSLColor)rgb).Hue01;
     Vector3 raw = ColorPickerUtils.ColorToRawValue(ColorPickerMode.SL_H_Triangle, rgb);
     Assert.AreEqual(expected, raw.z, 1e-4f);
 }
Example #2
0
 private void Single_ColorPickerRoundTripFromColor(ColorPickerMode mode, Color rgb)
 {
     Vector3 raw = ColorPickerUtils.ColorToRawValue(mode, rgb);
     Color rgb2;
     bool ok = ColorPickerUtils.RawValueToColor(mode, raw, out rgb2);
     Assert.IsTrue(ok, "Mode {0}: {1} -> {2} -> fail", mode, Repr(rgb), raw);
     // RawValueToColor should always return colors with a=1
     Assert.AreEqual(1, rgb2.a, "RawValueToColor alpha");
     rgb.a = 1; // Don't check incoming alpha
     AssertNearlyEqualRGB(rgb, rgb2);
 }
Example #3
0
 private void Single_ColorPickerRoundTripFromRawValue(ColorPickerMode mode, Vector3 raw)
 {
     Color rgb;
     bool ok = ColorPickerUtils.RawValueToColor(mode, raw, out rgb);
     if (!ok) { return; }
     Vector3 raw2 = ColorPickerUtils.ColorToRawValue(mode, rgb);
     Vector3 diff = raw2 - raw;
     float EPSILON = 1e-4f;
     if (Mathf.Abs(diff.x) > EPSILON ||
         Mathf.Abs(diff.y) > EPSILON ||
         Mathf.Abs(diff.z) > EPSILON)
     {
         Assert.Fail("Mode {0} sent {1} -> {2}", mode, raw, raw2);
     }
 }