ChartDirector Ver 3.0 (Perl Edition)

DrawArea.gradientColor2


Usage

gradientColor2(colorArray[, angle[, scale[, startX, startY]]])

Description

Create a multi-point gradient color.

In this method, the color points are defined as an array of positions and colors along a gradient line segment. During definition, the gradient line segment is always assumed to be horizontal and 256 pixels in length. When actually creating the gradient color, the direction and length of the gradient line can be controlled using the angle and scale parameters.

The array of positions and their colors along the gradient line is of the following format:

position0, color0, position1, color1, position2, color2, .... positionN, colorN

where positionX is the pixel position along the gradient line, and colorX is the color at that position. During definition, the gradient line it is always assumed to be 256 pixels in length, so position0 is always 0, and the last position is always 256.

For example, the array (in hex):

000000, FF0000, 000080, FFFF00, 000100, 00FF00

means pixel 0 (000000) is red (FF0000), pixel 128 (000080) is yellow (FFFF00), and pixel 256 (000100) is green (00FF00).

One common use of multi-point gradient colors is to define colors that have metallic look and feel. ChartDirector comes from several pre-defined gradient color arrays as follows.

NameValue (in hex numbers)
goldGradient 000000, FFE743, 000060, FFFFE0, 0000B0, FFF0B0, 000100, FFE743
silverGradient 000000, C8C8C8, 000060, F8F8F8, 0000B0, E0E0E0, 000100, C8C8C8
redMetalGradient 000000, E09898, 000060, FFF0F0, 0000B0, F0D8D8, 000100, E09898
greenMetalGradient 000000, 98E098, 000060, F0FFF0, 0000B0, D8F0D8, 000100, 98E098
blueMetalGradient 000000, 9898E0, 000060, F0F0FF, 0000B0, D8D8F0, 000100, 9898E0

Arguments

ArgumentDefaultDescription
colorArray(Mandatory)An array defining the positions and colors of the pixels along the gradient line.
angle90The direction of the gradient line segment in degrees, measured clockwise, with 0 degree as the upward pointing direction. The default direction is horizontal from left to right (90 degrees).
scale1.0The scaling factor for the gradient line segment. By default, the gradient line segment is 256 pixels in length. The scaling factor can be use to stretch or compress the gradient line segment.
startX0The x coordinate of the starting point of the gradient line segment.
startY0The y coordinate of the starting point of the gradient line segment.

Return Value

Return a 32-bit integer acting as a handle to the gradient color. The handle can be used in any ChartDirector API that expects a color as an argument.