示例#1
0
        /// <summary>
        /// Creates gradient with given colours, positions and type.
        /// </summary>
        /// <returns></returns>
        public static GradientFill CreateGradient([NotEmptyArray] Colour[] colours,
                                                  [NotNull] float[] positions, Vector2f texMixing)
        {
            if (colours.Length - 2 != positions.Length)
            {
                throw new ArgumentException("Number of positions must be number of colours - 2.");
            }

            // We now create fill.
            GradientFill fill = CreateGradient((uint)colours.Length);

            fill.Colours        = colours;
            fill.Positions      = positions;
            fill.texcoordMixing = texMixing;

            return(fill);
        }
示例#2
0
        /// <summary>
        /// Creates gradient with a given number of colours and gradient type.
        /// </summary>
        /// <param name="colours"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static GradientFill CreateGradient([MinUInt(2)] uint colours)
        {
            GradientFill fill = null;

            if (colours <= 4)
            {
                fill = new Gradient4Fill();
            }

            // We create and initialize it.
            if (fill != null)
            {
                fill.colours   = new Colour[colours];
                fill.positions = new float[colours - 2];
                return(fill);
            }

            throw new NotImplementedException("This kind of gradient not yet supported.");
        }