PTC ALD in Arbortext Styler > Components of Documents and Templates > Style Components > Colors > Gradients
A gradient is a special type of color in PTC Arbortext Layout Developer, which provides graduated color instead of a solid block of color. Gradients are described using the fGradientColor object. fGradientColor inherits from the fNamedColor object and extends it with specific properties that describe the gradient.
This example code will create a new gradient:
var c = template.content.getNamedColor("myGradient",fContent.COLOR_GRADIENT);
if (!c) {
c = template.content.createNamedColor("myGradient",fContent.COLOR_GRADIENT);

var s1 = new fGradientStop;
s1.color = "red";
s1.position = 0;

var s2 = new fGradientStop;
s2.color = "white";
s2.position = 100;
A stop is a color change point in the gradient. It has both a color value and a position value. As a minimum, there should be one stop at position 0 and one stop at position 100. If these stops are not defined, PTC Arbortext Layout Developer uses the first and last stop declared and copies the color values to those positions. There is no limit to the number of stops that can be declared for a gradient. The color of the stop can be any color known to PTC Arbortext Layout Developer, including another gradient.
Gradients can be applied anywhere color is applied. Some additional properties determine how PTC Arbortext Layout Developer uses that color when it is applied:
fGradientColor.fillHorizontal and fGradientColor.fillVertical — Horizontal and vertical fill
These properties specify how the gradient should be adjusted to fit the area to which it is applied. The fNamedColor.FILL_STRETCH flag ensures the gradient always fits the shape. Other values described in the fNamedColor.ColorFillTypes constant achieve different results.
fGradientColor.resolutionX and fGradientColor.resolutionY — Resolution in x and y axes
These properties specify the number of stripes created when building the gradient. More stripes give a smoother result but take longer to build. The default number is 100.
fGradientColor.flags — Gradient display
When creating a gradient, PTC Arbortext Layout Developer creates an internal raster that represents the gradient, and applies that raster. The fGradientColor.flags property instructs PTC Arbortext Layout Developer to use graphical lines of color instead of a raster when drawing the gradient.
Possible values for the property are listed in the fNamedColor.ColorFlags constant. The relevant flags for gradients are:
fNamedColor.TYPE_SOLID — generate gradient using solid blocks of color instead of generating a raster
fNamedColor.TYPE_SPOT — generate gradient using percentage values of the specified spot color