示例#1
0
        internal static PdfColors.RadialGradient ConvertRadialGradientBrush(RadialGradientBrush brush, double opacity, IPosition position, double width, double height)
        {
            if (width * height == 0)
            {
                return(null);
            }

            var center1 = new Point(brush.GradientOrigin.X * height, brush.GradientOrigin.Y * height);
            var center2 = new Point(brush.Center.X * height, brush.Center.Y * height);

            PdfColors.RadialGradient pdfGradient = new PdfColors.RadialGradient(center1, center2, 0, height / 2);

            var matrix    = new Matrix(width / height, 0, 0, 1, 0, 0);
            var newMatrix = matrix = MathHelper.Multiply(position.Matrix, matrix);

            pdfGradient.Position = new Telerik.Windows.Documents.Fixed.Model.Data.MatrixPosition(newMatrix);

            foreach (var gradientStop in brush.GradientStops)
            {
                var rgbColor = new PdfColors.RgbColor((byte)(gradientStop.Color.A * opacity), gradientStop.Color.R, gradientStop.Color.G, gradientStop.Color.B);
                pdfGradient.GradientStops.Add(new PdfColors.GradientStop(rgbColor, gradientStop.Offset));
            }

            return(pdfGradient);
        }
示例#2
0
        internal static PdfColors.LinearGradient ConvertLinearGradientBrush(LinearGradientBrush brush, double opacity, IPosition position, double width, double height)
        {
            Point startPoint = new Point(brush.StartPoint.X * width, brush.StartPoint.Y * height);
            Point endPoint = new Point(brush.EndPoint.X * width, brush.EndPoint.Y * height);

            var pdfGradient = new PdfColors.LinearGradient(startPoint, endPoint);
            pdfGradient.Position = position;

            foreach (GradientStop gradientStop in brush.GradientStops.OrderBy(x => x.Offset))
            {
                var rgbColor = new PdfColors.RgbColor((byte)(gradientStop.Color.A * opacity), gradientStop.Color.R, gradientStop.Color.G, gradientStop.Color.B);
                pdfGradient.GradientStops.Add(new PdfColors.GradientStop(rgbColor, gradientStop.Offset));
            }

            return pdfGradient;
        }
示例#3
0
        internal static PdfColors.LinearGradient ConvertLinearGradientBrush(LinearGradientBrush brush, double opacity, IPosition position, double width, double height)
        {
            Point startPoint = new Point(brush.StartPoint.X * width, brush.StartPoint.Y * height);
            Point endPoint   = new Point(brush.EndPoint.X * width, brush.EndPoint.Y * height);

            var pdfGradient = new PdfColors.LinearGradient(startPoint, endPoint);

            pdfGradient.Position = position;

            foreach (GradientStop gradientStop in brush.GradientStops.OrderBy(x => x.Offset))
            {
                var rgbColor = new PdfColors.RgbColor((byte)(gradientStop.Color.A * opacity), gradientStop.Color.R, gradientStop.Color.G, gradientStop.Color.B);
                pdfGradient.GradientStops.Add(new PdfColors.GradientStop(rgbColor, gradientStop.Offset));
            }

            return(pdfGradient);
        }
示例#4
0
        internal static PdfColors.RadialGradient ConvertRadialGradientBrush(RadialGradientBrush brush, double opacity, IPosition position, double width, double height)
        {
            if (width * height == 0)
            {
                return null;
            }

            var center1 = new Point(brush.GradientOrigin.X * height, brush.GradientOrigin.Y * height);
            var center2 = new Point(brush.Center.X * height, brush.Center.Y * height);
            PdfColors.RadialGradient pdfGradient = new PdfColors.RadialGradient(center1, center2, 0, height / 2);

            var matrix = new Matrix(width / height, 0, 0, 1, 0, 0);
            var newMatrix = matrix = MathHelper.Multiply(position.Matrix, matrix);
            pdfGradient.Position = new Telerik.Windows.Documents.Fixed.Model.Data.MatrixPosition(newMatrix);

            foreach (var gradientStop in brush.GradientStops)
            {
                var rgbColor = new PdfColors.RgbColor((byte)(gradientStop.Color.A * opacity), gradientStop.Color.R, gradientStop.Color.G, gradientStop.Color.B);
                pdfGradient.GradientStops.Add(new PdfColors.GradientStop(rgbColor, gradientStop.Offset));
            }

            return pdfGradient;
        }