private const double whiteFactor = 2.2; // Provide more accuracy around the white-point public override RGBColor ColorMapping(double radius, double theta, double value) { HSVColor hsv = new HSVColor((float)theta, (float)Math.Pow(radius, whiteFactor), (float)value); RGBColor rgb = hsv.ToRGB(); return(rgb); }
private void HsvChanged() { rgbColor = hsvColor.ToRGB(); xyzColor = rgbColor; xyyColor = xyzColor; //application.color = rgbColor; }
void SetImageColor(Image ui, HSVColor displacement) { Color temp = ui.color; temp = displacement.ToRGB(); temp.a = ui.color.a; ui.color = temp; }
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); }
// Use this for initialization public override void Start() { base.Start(); Renderer[] renderers = GetComponentsInChildren <Renderer>(); float increment = 1.0f / 16.0f; float value = 0.0f; foreach (Renderer renderer in renderers) { if (renderer.transform.name == "Quad") { Color color = HSVColor.ToRGB(new HSVColor(value, 1.0f, 1.0f)); renderer.material.color = color; value += increment; } } }
/// <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()); }
public void Update() { var color = new HSVColor(H.ToFloat(), S.ToFloat(), V.ToFloat()); SelectedColor = color.ToRGB(); }