Table of Contents

Class PdfRadialGradientBrush

Namespace
Syncfusion.Pdf.Graphics
Assembly
Syncfusion.Pdf.Portable.dll

Represent radial gradient brush.

public class PdfRadialGradientBrush : PdfGradientBrush, ICloneable
Inheritance
PdfRadialGradientBrush
Implements
Inherited Members

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Constructors

PdfRadialGradientBrush(PointF, float, PointF, float, PdfColor, PdfColor)

Initializes a new instance of the PdfRadialGradientBrush class.

public PdfRadialGradientBrush(PointF centreStart, float radiusStart, PointF centreEnd, float radiusEnd, PdfColor colorStart, PdfColor colorEnd)

Parameters

centreStart PointF

The start centre.

radiusStart float

The start radius.

centreEnd PointF

The end centre.

radiusEnd float

The end radius.

colorStart PdfColor

The start color.

colorEnd PdfColor

The end color.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Properties

Blend

Gets or sets a PdfBlend that specifies positions and factors that define a custom falloff for the gradient.

public PdfBlend Blend { get; set; }

Property Value

PdfBlend

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
//Create PDF blend
PdfBlend blend = new PdfBlend();
//Set factors
blend.Factors = new float[] {1};
//Set poistions
blend.Positions = new float[] {0};
//Set blend to the brush.
brush.Blend = blend; 
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
'Create PDF blend
Dim blend As New PdfBlend()
'Set factors
blend.Factors = New Single() {1}
'Set poistions
blend.Positions = New Single() {0}
'Set blend to the brush.
brush.Blend = blend
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Extend

Gets or sets the value indicating whether the gradient should extend starting and ending points.

public PdfExtend Extend { get; set; }

Property Value

PdfExtend

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
//Set the extend mode.
brush.Extend = PdfExtend.Both;
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
 'Set the extend mode.
brush.Extend = PdfExtend.Both
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

InterpolationColors

Gets or sets a ColorBlend that defines a multicolor linear gradient.

public PdfColorBlend InterpolationColors { get; set; }

Property Value

PdfColorBlend

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
//Create PDF color blend
PdfColorBlend cblend = new PdfColorBlend();
//Set colors
cblend.Colors = new PdfColor[] { Color.Blue, Color.Red };
//Set poistions
cblend.Positions = new float[] { 0, 1 };
//Set internpolation colors to the brush.
brush.InterpolationColors = cblend;            
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
'Create PDF color blend
Dim cblend As New PdfColorBlend()
'Set colors
cblend.Colors = New PdfColor() { Color.Blue, Color.Red}
'Set poistions
cblend.Positions = New Single() { 0, 1}
'Set internpolation colors to the brush.
brush.InterpolationColors = cblend
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

LinearColors

Gets or sets the starting and ending colors of the gradient.

public PdfColor[] LinearColors { get; set; }

Property Value

PdfColor[]

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
PdfColor startColor = new PdfColor(Color.Black);
PdfColor endColor = new PdfColor(Color.Green);
//Set linear colors.
brush.LinearColors = new PdfColor[] { startColor, endColor };
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
Dim startColor As New PdfColor(Color.Black)
Dim endColor As New PdfColor(Color.Green)
'Set linear colors.
brush.LinearColors = New PdfColor() { startColor, endColor}
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Rectangle

Gets or sets the rectangle.

public RectangleF Rectangle { get; set; }

Property Value

RectangleF

The rectangle.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100)); 
//Get the radial brush bounds.
RectangleF rect = brush.Rectangle; 
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Get the radial brush bounds.
Dim rect As RectangleF = brush.Rectangle
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Methods

Clone()

Creates a new copy of a brush.

public override PdfBrush Clone()

Returns

PdfBrush

A new instance of the Brush class.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF gradient brush.  
PdfRadialGradientBrush brush = new PdfRadialGradientBrush(new PointF(50, 50), 0, new PointF(50, 50), 50, Color.Red, Color.Blue);
//Draw the ellipse.
graphics.DrawEllipse(brush, new RectangleF(0, 0, 100, 100));    
PdfColor startColor = new PdfColor(Color.Black);
PdfColor endColor = new PdfColor(Color.Green);
//Clone the existing brush.
PdfRadialGradientBrush cBrush = brush.Clone() as PdfRadialGradientBrush;
//Set linear colors.
cBrush.LinearColors = new PdfColor[] { startColor, endColor };
//Draw ellipse.
graphics.DrawEllipse(cBrush, new RectangleF(0, 150, 100, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfRadialGradientBrush(New PointF(50, 50), 0, New PointF(50, 50), 50, Color.Red, Color.Blue)
'Draw the ellipse.
graphics.DrawEllipse(brush, New RectangleF(0, 0, 100, 100))
'Clone the existing brush.
Dim cBrush As PdfRadialGradientBrush = TryCast(brush.Clone(), PdfRadialGradientBrush)
'Set linear colors.
cBrush.LinearColors = New PdfColor() { startColor, endColor}
'Draw rectangle.
graphics.DrawEllipse(cBrush, New RectangleF(0, 150, 100, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)