static Color[] GenerateColors(AdaptiveGradient gradient, uint numSamples)
        {
            double leftAnchor  = gradient.First().Anchor.AnchorValue;
            double rightAnchor = gradient.Last().Anchor.AnchorValue;

            //we need to make sure it spreads out across the whole range, so we set the
            //increment such that we include the end two colors.
            double increment = (rightAnchor - leftAnchor) / (numSamples - 1);

            Color[] colors = new Color[numSamples];

            double targetValue;


            for (int i = 0; i < numSamples; i++)
            {
                targetValue = leftAnchor + increment * i;
                //consider stops in pairs, and if we're in the right pair
                // interpolate between the stops.
                for (int j = 0; j < gradient.Count - 1; j++)
                {
                    //because of the way we're counting, if this condition
                    // is true, we're between a pair of gradient stops
                    // with the left one smaller and the right one larger.
                    if (targetValue >= gradient[j].Anchor.AnchorValue)
                    {
                        colors[i] = InterpolateBetweenStops(targetValue, gradient[j], gradient[j + 1]);
                        continue;
                    }
                }
            }
            return(colors);
        }
        static double[] GenerateTargetValues(AdaptiveGradient gradient, uint numSamples)
        {
            double leftAnchor  = gradient.First().Anchor.AnchorValue;
            double rightAnchor = gradient.Last().Anchor.AnchorValue;
            double increment   = (rightAnchor - leftAnchor) / numSamples;

            double[] targetValues = new double[numSamples];

            //generate sample sets. Note that each block is represented by the max value in the block.
            for (int i = 1; i <= numSamples; i++)
            {
                targetValues[i - 1] = leftAnchor + increment * i;
            }

            return(targetValues);
        }