Esempio n. 1
0
    public static Color ToColor(StackColor c)
    {
        float r, g, b, a = c.a;

        r = g = b = c.l;

        if (c.l <= 0)
        {
            c.l = 0.001f;
        }
        if (c.l >= 1)
        {
            c.l = 0.999f;
        }

        if (c.s != 0f)
        {
            var v2 = c.l < 0.5f ? c.l * (c.s + 1f) : c.l + c.s - c.l * c.s;
            var v1 = c.l * 2 - v2;
            r = GetRGB(v1, v2, c.h + 1f / 3f);
            g = GetRGB(v1, v2, c.h);
            b = GetRGB(v1, v2, c.h - 1f / 3f);
        }

        return(new Color(r, g, b, a));
    }
Esempio n. 2
0
    public static Color GetRandomDarkColor()
    {
        StackColor randomColor = new StackColor();

        randomColor.h = RandomValue();
        randomColor.s = 0.8f;
        randomColor.l = 0.1f;
        randomColor.a = 1;

        return(randomColor);
    }
Esempio n. 3
0
    public static Color GetRandomColor()
    {
        StackColor randomColor = new StackColor();

        randomColor.h = RandomValue();
        randomColor.s = RandomRange(0.3f, 0.4f);
        randomColor.l = RandomRange(0.45f, 0.6f);
        randomColor.a = 1;

        return(randomColor);
    }
Esempio n. 4
0
 public StackColor(Color c)
 {
     StackColor temp = Utils.FromColor(c); h = temp.h; s = temp.s; l = temp.l; a = temp.a;
 }