public static List <MaterialAndShades> Palette(float hueP, float saturationP, float valueP, int harmonyStep, int tintsAndShades, Material standardMaterial)
    {
        List <MaterialAndShades> pallete = new List <MaterialAndShades>();

        //first main

        //6 tones, main, adjacents, contrasting, and contrasting adjacent, this will give a nice amount to randomly select from
        for (int i = 0; i < 6; i++)
        {
            //first coloour, hue no harmony
            int addition = 0;
            //add adjacents
            if (i == 1)
            {
                addition = -harmonyStep;
            }
            if (i == 2)
            {
                addition = harmonyStep;
            }

            //now contrasting
            if (i == 3)
            {
                addition = 180;
            }
            //now contrast adjacents
            if (i == 4)
            {
                addition = 180 - harmonyStep;
            }
            if (i == 5)
            {
                addition = 180 + harmonyStep;
            }

            float hueForHarmony = ((hueP * 360) + addition);
            //clamp so it stays within 360 degrees
            if (hueForHarmony < 0)
            {
                hueForHarmony += 360;
            }

            if (hueForHarmony > 360)
            {
                hueForHarmony -= 360;
            }
            //convert to fraction
            hueForHarmony /= 360;

            //complimentary

            //create materials
            MaterialAndShades mAs = ColourAndShades(hueForHarmony, saturationP, valueP, standardMaterial, tintsAndShades);
            pallete.Add(mAs);
        }

        return(pallete);
    }
    static MaterialAndShades ColourAndShades(float hueP, float saturationP, float valueP, Material standardMaterial, int tintsAndShades)
    {
        //create material for main hue
        Color    color0  = Color.HSVToRGB(hueP, saturationP, valueP);
        Material matMain = new Material(standardMaterial);

        matMain.color = color0;

        //get a list of tints based on the starting hue,value,saturation - tints, lighter colours
        List <Material> tints = Tints(hueP, saturationP, valueP, standardMaterial, tintsAndShades);
        //shades too, darker
        List <Material> shades = Shades(hueP, saturationP, valueP, standardMaterial, tintsAndShades);

        MaterialAndShades mAs = new MaterialAndShades(matMain, tints, shades);

        return(mAs);
    }
Exemple #3
0
    List <MaterialAndShades> Palette(float hueP, float saturationP, float valueP)
    {
        //destroy all materials - stops memory leak
        for (int i = 0; i < matsAndShades.Count; i++)
        {
            //main
            Destroy(matsAndShades[i].material);

            //tints shades
            for (int j = 0; j < matsAndShades[i].tints.Count; j++)
            {
                Destroy(matsAndShades[i].tints[j]);
                Destroy(matsAndShades[i].shades[j]);
            }
        }

        List <MaterialAndShades> pallete = new List <MaterialAndShades>();

        //first main

        //6 tones, main, adjacents, contrasting, and contrasting adjacent, this will give a nice amount to randomly select from
        for (int i = 0; i < 6; i++)
        {
            //first coloour, hue no harmony
            int addition = 0;
            //add adjacents
            if (i == 1)
            {
                addition = -harmonyStep;
            }
            if (i == 2)
            {
                addition = harmonyStep;
            }

            //now contrasting
            if (i == 3)
            {
                addition = 180;
            }
            //now contrast adjacents
            if (i == 4)
            {
                addition = 180 - harmonyStep;
            }
            if (i == 5)
            {
                addition = 180 + harmonyStep;
            }

            float hueForHarmony = ((hueP * 360) + addition);
            //clamp so it stays within 360 degrees
            if (hueForHarmony < 0)
            {
                hueForHarmony += 360;
            }

            if (hueForHarmony > 360)
            {
                hueForHarmony -= 360;
            }
            //convert to fraction
            hueForHarmony /= 360;

            //complimentary

            //create materials
            MaterialAndShades mAs = ColourAndShades(hueForHarmony, saturationP, valueP);
            pallete.Add(mAs);
        }

        return(pallete);
    }