Example #1
0
    private static GradientWrapper CreateGradTexture()
    {
        // Create gradient object and assign generic starting colours
        GradientWrapper.ColorKey[] gck = new GradientWrapper.ColorKey[2];
        gck[0] = new GradientWrapper.ColorKey(Color.black, 0f);
        gck[1] = new GradientWrapper.ColorKey(Color.white, 1f);
        GradientWrapper.AlphaKey[] gak = new GradientWrapper.AlphaKey[2];
        gak[0] = new GradientWrapper.AlphaKey(1f, 0f);
        gak[1] = new GradientWrapper.AlphaKey(1f, 1f);
        GradientWrapper gw = new GradientWrapper();

        gw = GUIGradientField.GradientField("Gradient", gw);
        gw.SetKeys(gck, gak);
        return(gw);
    }
Example #2
0
        public static GradientWrapper ParseGradient(string gradientString)
        {
            var results = MapCssGradientRegEx.Matches(gradientString);
            var count   = results.Count;

            if (count == 0)
            {
                throw new ArgumentException(String.Format(Strings.InvalidGradientString, gradientString));
            }

            var colorKeys = new GradientWrapper.ColorKey[count];

            for (int i = 0; i < count; i++)
            {
                var   values = results[i].Groups[0].Value.Split(' ');
                var   color  = ColorUtils.FromUnknown(values[0]);
                float time   = i == 0 ? 0 :
                               (i == results.Count - 1) ? 1 :
                               float.Parse(values[1].Substring(0, values[1].Length - 1)) / 100f;
                colorKeys[i] = colorKeys[i] = new GradientWrapper.ColorKey
                {
                    Color = color.ToUnityColor(),
                    Time  = time
                };
            }

            var alphaKeys = new GradientWrapper.AlphaKey[]
            {
                new GradientWrapper.AlphaKey()
                {
                    Alpha = 1, Time = 0
                },
                new GradientWrapper.AlphaKey()
                {
                    Alpha = 1, Time = 1
                },
            };

            return(new GradientWrapper(colorKeys, alphaKeys));
        }
Example #3
0
	private static GradientWrapper CreateGradTexture(){
		// Create gradient object and assign generic starting colours	
		GradientWrapper.ColorKey[] gck = new GradientWrapper.ColorKey[2];
		gck[0] = new GradientWrapper.ColorKey(Color.black, 0f);
		gck[1] = new GradientWrapper.ColorKey(Color.white, 1f);
		GradientWrapper.AlphaKey[] gak = new GradientWrapper.AlphaKey[2];
		gak[0] = new GradientWrapper.AlphaKey(1f, 0f);
		gak[1] = new GradientWrapper.AlphaKey(1f, 1f);
		GradientWrapper gw = new GradientWrapper();
		gw = GUIGradientField.GradientField("Gradient", gw);
		gw.SetKeys(gck, gak);
		return gw;
	}