Class AbstractLinearGradientBuilder
Base class for linear gradient builders implementations.
public abstract class AbstractLinearGradientBuilder
- Inheritance
-
AbstractLinearGradientBuilder
- Derived
- Inherited Members
Remarks
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.Constructors
AbstractLinearGradientBuilder()
protected AbstractLinearGradientBuilder()
Fields
ZERO_EPSILON
The epsilon value used for data creation
protected const double ZERO_EPSILON = 1E-10
Field Value
Methods
AddColorStop(GradientColorStop)
Adds the new color stop to the end ( more info ).
public virtual AbstractLinearGradientBuilder AddColorStop(GradientColorStop gradientColorStop)
Parameters
gradientColorStop
GradientColorStopthe gradient stop color to add
Returns
- AbstractLinearGradientBuilder
the current builder instance
Remarks
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.)
BuildColor(Rectangle, AffineTransform, PdfDocument)
Builds the Color object representing the linear gradient with specified configuration that fills the target bounding box.
public virtual Color BuildColor(Rectangle targetBoundingBox, AffineTransform contextTransform, PdfDocument document)
Parameters
targetBoundingBox
Rectanglethe bounding box to be filled in current space
contextTransform
AffineTransformthe 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
PdfDocumentthe PdfDocument for which the linear gradient would be built.
Returns
- Color
the constructed Color or null if no color to be applied or base gradient vector has been specified
CreateCoordinatesForNewDomain(double[], Point[])
Expand the base vector to cover the new domain
protected static Point[] CreateCoordinatesForNewDomain(double[] newDomain, Point[] baseVector)
Parameters
newDomain
double[]the array of exactly two elements that specifies the domain that should be covered by the created vector
baseVector
Point[]the array of exactly two elements that specifies the base vector which corresponds to [0, 1] domain
Returns
- Point[]
the array of two
EvaluateCoveringDomain(Point[], Rectangle)
Evaluates the minimal domain that covers the box with vector normals.
protected static double[] EvaluateCoveringDomain(Point[] coords, Rectangle toCover)
Parameters
coords
Point[]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
Rectanglethe box that needs to be covered
Returns
- double[]
the array of two elements in ascending order specifying the calculated covering domain
Remarks
Evaluates the minimal domain that covers the box with vector normals. The domain corresponding to the initial vector is [0, 1].
GetColorStops()
Get the copy of current color stops list.
public virtual IList<GradientColorStop> GetColorStops()
Returns
- IList<GradientColorStop>
the copy of current stop colors list
Remarks
Get the copy of current color stops list. Note that the stop colors are not copied here
GetCurrentSpaceToGradientVectorSpaceTransformation(Rectangle, AffineTransform)
Returns the current space to gradient vector space transformations that should be applied to the shading color.
protected virtual AffineTransform GetCurrentSpaceToGradientVectorSpaceTransformation(Rectangle targetBoundingBox, AffineTransform contextTransform)
Parameters
targetBoundingBox
Rectanglethe rectangle to be covered by constructed color in current space
contextTransform
AffineTransformthe current canvas transformation
Returns
- AffineTransform
the additional transformation to be concatenated to the current for resulted shading or null if no additional transformation is specified
Remarks
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.
GetGradientVector(Rectangle, AffineTransform)
Returns the base gradient vector in gradient vector space.
protected abstract Point[] GetGradientVector(Rectangle targetBoundingBox, AffineTransform contextTransform)
Parameters
targetBoundingBox
Rectanglethe rectangle to be covered by constructed color in current space
contextTransform
AffineTransformthe current canvas transformation
Returns
- Point[]
the array of exactly two elements specifying the gradient coordinates vector
Remarks
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.
GetSpreadMethod()
Get the current spread method
public virtual GradientSpreadMethod GetSpreadMethod()
Returns
- GradientSpreadMethod
the current spread method
SetSpreadMethod(GradientSpreadMethod)
Set the spread method to use for the gradient
public virtual AbstractLinearGradientBuilder SetSpreadMethod(GradientSpreadMethod gradientSpreadMethod)
Parameters
gradientSpreadMethod
GradientSpreadMethodthe gradient spread method to set
Returns
- AbstractLinearGradientBuilder
the current builder instance