Exemple #1
0
        /// <summary>
        /// Override so that the radial pattern extends beyond the set size to the farthest corner.
        /// With the repeat at the distances
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        protected override List <PDFGradientFunctionBoundary> GetRepeatingBoundaries(PDFPoint offset, PDFSize size)
        {
            var items = base.GetRepeatingBoundaries(offset, size);

            if (this.Size != RadialSize.None && this.Size != RadialSize.FarthestCorner)
            {
                var height = Math.Abs(size.Height.PointsValue);
                var width  = size.Width.PointsValue;

                //calculate the centre and radii for the names side and farthest corner
                var      newItems       = new List <PDFGradientFunctionBoundary>(items.Count);
                PDFPoint centre         = PDFRadialShadingPattern.CacluateRadialCentre(this.XCentre, this.YCentre, height, width);
                var      radiusActual   = Math.Abs(PDFRadialShadingPattern.CalculateRadiusForSize(this.Size, height, width, centre.X.PointsValue, centre.Y.PointsValue));
                var      radiusRequired = Math.Abs(PDFRadialShadingPattern.CalculateRadiusForSize(RadialSize.FarthestCorner, height, width, centre.X.PointsValue, centre.Y.PointsValue));

                //all our boundaries will be adjusted for the factor so we extend out.
                var factor = radiusActual / radiusRequired;

                var start    = 0.0;
                var boundary = 0.0;
                var index    = 0;

                while (boundary < 1)
                {
                    var one = items[index];
                    boundary = (one.Bounds * factor) + start;
                    one      = new PDFGradientFunctionBoundary(boundary);
                    newItems.Add(one);

                    index++;

                    if (index >= items.Count)
                    {
                        index    = 0;
                        start    = boundary;
                        boundary = 0.0;
                    }
                }

                this.Size = RadialSize.FarthestCorner;
                items     = newItems;
            }

            return(items);
        }
        public PDFResource GetRadialShadingPattern(PDFGraphics g, string key, PDFGradientRadialDescriptor descriptor, PDFRect bounds)
        {
            PDFRadialShadingPattern pattern = new PDFRadialShadingPattern(g.Container.Document, key, descriptor, bounds);

            return(pattern);
        }