//No need to test other values, because Unity's h values are only defined from [0, 1) public void GetNew_Test(float value) { // setup float expected = value; HSVColor hsvColor = new HSVColor(Color.blue); // perform hsvColor = hsvColor.GetNew(value); // assert Assert.AreEqual(value, (float)Math.Round(hsvColor.h, 1)); }
public void ToRGBAfterGetNew_Test(float h, float r, float g, float b) { // setup Color expected = new Color(r, g, b); HSVColor hsvColor = new HSVColor(Color.red); // perform hsvColor = hsvColor.GetNew(h); Color actual = hsvColor.ToRGB(); // assert Assert.AreEqual(expected, actual); }
/// <summary> /// Calculates a Color32 based on the given dose. /// </summary> private static Color32 Calculate(float dose) { dose = Mathf.Abs(dose); float baseH = startColor.h; // since HSV Colors have a h value range from 0 to 360 // and yellow is at 60 float stepSize = 300f / maxDose; float newH = baseH + stepSize * dose / 360f; // since unity h values only range from 0 to 1 newH = Mathf.Clamp01(newH); HSVColor hsvColor = startColor.GetNew(newH); return((Color32)hsvColor.ToRGB()); }