System.Drawing.Drawing2D.LinearGradientBrush.setColorsUsingBlend C# (CSharp) Method

setColorsUsingBlend() private method

private setColorsUsingBlend ( ) : void
return void
        void setColorsUsingBlend()
        {
            int size = blend.Positions.Length;

            if (size == 1)
            {
                shadingColors = new float[2][];
                factors = new float[2];
                positions = new float[2];

                // check for default Blend to setup the shading colors
                // appropriately.
                if (blend.Factors[0] == 1 && blend.Positions[0] == 1)
                {
                    factors[0] = 0f;
                    positions[0] = 0;
                }
                else
                {
                    // This is a special case where a blend was set
                    // with a factor.  It still does not give exact
                    // results with windows.  Need to look at this as
                    // still not sure what it should do.
                    // Example:
                    //	float[] myFactors = { 0.2f };
                    //	float[] myPositions = { 0.0f };
                    //	Blend myBlend = new Blend();
                    //	myBlend.Factors = myFactors;
                    //	myBlend.Positions = myPositions;
                    //	lgBrush2.Blend = myBlend;
                    factors[0] = blend.Factors[0];
                    positions[0] = 1.0f;
                }

                // Close off the color shadings
                factors[1] = 1.0f;
                positions[1] = 1.0f;

            }
            else
            {
                shadingColors = new float[size][];
                factors = blend.Factors;
                positions = blend.Positions;
            }

            float[] sc = colors[0].ElementsCGRGBA();
            float[] ec = colors[1].ElementsCGRGBA();

            float factor = 0;
            for (int s = 0; s < positions.Length; s++)
            {
                shadingColors[s] = new float[4];
                factor = factors[s];
                //Console.WriteLine("shadingIndex {0} position {1} factor {2}",s, positions[s], factor);

                for (int c = 0; c < 4; c++)
                {
                    shadingColors[s][c] = GeomUtilities.Lerp (sc[c], ec[c], factor);
                }
            }
        }