iText 8.0.5 API
iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder Class Referenceabstract

Base class for linear gradient builders implementations. More...

Inheritance diagram for iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder:
iText.Kernel.Colors.Gradients.LinearGradientBuilder iText.Kernel.Colors.Gradients.StrategyBasedLinearGradientBuilder

Public Member Functions

virtual AbstractLinearGradientBuilder  AddColorStop (GradientColorStop gradientColorStop)
  Adds the new color stop to the end ( more info ). More...
 
virtual AbstractLinearGradientBuilder  SetSpreadMethod (GradientSpreadMethod gradientSpreadMethod)
  Set the spread method to use for the gradient More...
 
virtual IList< GradientColorStop GetColorStops ()
  Get the copy of current color stops list. More...
 
virtual GradientSpreadMethod  GetSpreadMethod ()
  Get the current spread method More...
 
virtual Color  BuildColor (Rectangle targetBoundingBox, AffineTransform contextTransform, PdfDocument document)
  Builds the iText.Kernel.Colors.Color object representing the linear gradient with specified configuration that fills the target bounding box. More...
 

Package Functions

abstract Point[]  GetGradientVector (Rectangle targetBoundingBox, AffineTransform contextTransform)
  Returns the base gradient vector in gradient vector space. More...
 
virtual AffineTransform  GetCurrentSpaceToGradientVectorSpaceTransformation (Rectangle targetBoundingBox, AffineTransform contextTransform)
  Returns the current space to gradient vector space transformations that should be applied to the shading color. More...
 

Static Package Functions

static double[]  EvaluateCoveringDomain (Point[] coords, Rectangle toCover)
  Evaluates the minimal domain that covers the box with vector normals. More...
 
static Point[]  CreateCoordinatesForNewDomain (double[] newDomain, Point[] baseVector)
  Expand the base vector to cover the new domain More...
 

Static Package Attributes

const double  ZERO_EPSILON = 1E-10
  The epsilon value used for data creation More...
 

Detailed Description

Base class for linear gradient builders implementations.

Base class for linear gradient builders implementations.

Color transitions for linear gradients are defined by a series of color stops along a gradient vector. A gradient normal defines how the colors in a vector are painted to the surface. For a linear gradient, a normal is a line perpendicular to the vector.

Contains the main logic that works with stop colors and creation of the resulted pdf color object.

Member Function Documentation

◆ AddColorStop()

virtual AbstractLinearGradientBuilder iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.AddColorStop ( GradientColorStop  gradientColorStop )
inlinevirtual

Adds the new color stop to the end ( more info ).

Adds the new color stop to the end ( more info ). Note: if the previously added color stop's offset would have grater offset than the added one, then the new offset would be normalized to be equal to the previous one. (Comparison made between relative on coordinates vector offsets. If any of them has the absolute offset, then the absolute value would converted to relative first.)

Parameters
gradientColorStop the gradient stop color to add
Returns
the current builder instance

◆ BuildColor()

virtual Color iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.BuildColor ( Rectangle  targetBoundingBox,
AffineTransform  contextTransform,
PdfDocument  document 
)
inlinevirtual

Builds the iText.Kernel.Colors.Color object representing the linear gradient with specified configuration that fills the target bounding box.

Parameters
targetBoundingBox the bounding box to be filled in current space
contextTransform the transformation from the base coordinates space into the current space. The null value is valid and can be used if there is no transformation from base coordinates to current space specified, or it is equal to identity transformation.
document the iText.Kernel.Pdf.PdfDocument for which the linear gradient would be built.
Returns
the constructed iText.Kernel.Colors.Color or null if no color to be applied or base gradient vector has been specified

◆ CreateCoordinatesForNewDomain()

static Point [] iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.CreateCoordinatesForNewDomain ( double[]  newDomain,
Point[]  baseVector 
)
inlinestaticpackage

Expand the base vector to cover the new domain

Parameters
newDomain the array of exactly two elements that specifies the domain that should be covered by the created vector
baseVector the array of exactly two elements that specifies the base vector which corresponds to [0, 1] domain
Returns
the array of two

◆ EvaluateCoveringDomain()

static double [] iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.EvaluateCoveringDomain ( Point[]  coords,
Rectangle  toCover 
)
inlinestaticpackage

Evaluates the minimal domain that covers the box with vector normals.

Evaluates the minimal domain that covers the box with vector normals. The domain corresponding to the initial vector is [0, 1].

Parameters
coords the array of exactly two elements that describe the base vector (corresponding to [0,1] domain, that need to be adjusted to cover the box
toCover the box that needs to be covered
Returns
the array of two elements in ascending order specifying the calculated covering domain

◆ GetColorStops()

virtual IList<GradientColorStop> iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.GetColorStops ( )
inlinevirtual

Get the copy of current color stops list.

Get the copy of current color stops list. Note that the stop colors are not copied here

Returns
the copy of current stop colors list

◆ GetCurrentSpaceToGradientVectorSpaceTransformation()

virtual AffineTransform iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.GetCurrentSpaceToGradientVectorSpaceTransformation ( Rectangle  targetBoundingBox,
AffineTransform  contextTransform 
)
inlinepackagevirtual

Returns the current space to gradient vector space transformations that should be applied to the shading color.

Returns the current space to gradient vector space transformations that should be applied to the shading color. The transformation should be invertible as the current target bounding box coordinates should be transformed into the resulted shading space coordinates.

Parameters
targetBoundingBox the rectangle to be covered by constructed color in current space
contextTransform the current canvas transformation
Returns
the additional transformation to be concatenated to the current for resulted shading or null if no additional transformation is specified

Reimplemented in iText.Kernel.Colors.Gradients.LinearGradientBuilder.

◆ GetGradientVector()

abstract Point [] iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.GetGradientVector ( Rectangle  targetBoundingBox,
AffineTransform  contextTransform 
)
packagepure virtual

Returns the base gradient vector in gradient vector space.

Returns the base gradient vector in gradient vector space. This vector would be set as shading coordinates vector and its length would be used to translate all color stops absolute offsets into the relatives.

Parameters
targetBoundingBox the rectangle to be covered by constructed color in current space
contextTransform the current canvas transformation
Returns
the array of exactly two elements specifying the gradient coordinates vector

Implemented in iText.Kernel.Colors.Gradients.StrategyBasedLinearGradientBuilder, and iText.Kernel.Colors.Gradients.LinearGradientBuilder.

◆ GetSpreadMethod()

virtual GradientSpreadMethod iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.GetSpreadMethod ( )
inlinevirtual

Get the current spread method

Returns
the current spread method

◆ SetSpreadMethod()

virtual AbstractLinearGradientBuilder iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.SetSpreadMethod ( GradientSpreadMethod  gradientSpreadMethod )
inlinevirtual

Set the spread method to use for the gradient

Parameters
gradientSpreadMethod the gradient spread method to set
Returns
the current builder instance

Member Data Documentation

◆ ZERO_EPSILON

const double iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder.ZERO_EPSILON = 1E-10
staticpackage

The epsilon value used for data creation