private Color RybAsUColor(Color color) { RYB rybColor = Khroma.RgbToRyb(color); Color rybAsColor = new Color(rybColor.R, rybColor.Y, rybColor.B, rybColor.Alpha); return(rybAsColor); }
public void AddHarmony(Color baseColor, Harmony harmony) { colors.Add(baseColor); if (wheelModel == WheelModel.RYB) { baseColor = RybAsUColor(baseColor); } HSV baseHSV = new HSV(baseColor); List <HSV> colorTransforms = presetHarmonies[harmony.ToString()]; // Debug.Log("base: " + baseHSV.h + " / " + baseHSV.s + " / " + baseHSV.v); for (int i = 0; i < colorTransforms.Count; i++) { HSV tempHSV = baseHSV; tempHSV.h += colorTransforms[i].h; tempHSV.h = Mathf.Repeat(tempHSV.h, 1f); tempHSV.s += colorTransforms[i].s; if (tempHSV.s > 1f || tempHSV.s < 0f) { tempHSV.s = Mathf.PingPong(tempHSV.s, 1f); } tempHSV.v += colorTransforms[i].v; if (tempHSV.v > 1f || tempHSV.v < 0f) { tempHSV.v = Mathf.PingPong(tempHSV.v, 1f); } // Debug.Log(tempHSV.h + " / " + tempHSV.s + " / " + tempHSV.v); Color outColor = Color.HSVToRGB(tempHSV.h, tempHSV.s, tempHSV.v); if (wheelModel == WheelModel.RYB) { outColor = Khroma.RybToRgb(RybAsUColorReverse(outColor)); } colors.Add(outColor); } }