Help Center

CGpLinearGradientBrush.GetInterpolationColorsmethod

Gts the colors currently set to be interpolated for this linear gradient brush and their corresponding blend positions.

GraphicsmethodCGpBrush.incdocumented

Syntax

FUNCTION GetInterpolationColors (BYVAL presetColors AS ARGB PTR, BYVAL blendPositions AS SINGLE PTR, BYVAL count AS LONG) AS GpStatus

Parameters

NameDescription
presetColorsPointer to an array that receives the colors. A color of a given index in the presetColors array corresponds to the blend position of that same index in the blendPositions array.
blendPositionsPointer to an array that receives the blend positions. Each number in the array indicates a percentage of the distance between the starting boundary and the ending boundary and is in the range from 0.0 through 1.0, where 0.0 indicates the starting boundary of the gradient and 1.0 indicates the ending boundary. A blend position between 0.0 and 1.0 indicates a line, parallel to the boundary lines, that is a certain fraction of the distance from the starting boundary to the ending boundary. For example, a blend position of 0.7 indicates the line that is 70 percent of the distance from the starting boundary to the ending boundary. The color is constant on lines that are parallel to the boundary lines.
countInteger that specifies the number of elements in the presetColors array. This is the same as the number of elements in the blendPositions array. Before calling the GetInterpolationColors method of a LinearGradientBrush object, call the GetInterpolationColorCount method of that same LinearGradientBrush object to determine the current number of colors. The number of blend positions retrieved is the same as the number of colors retrieved.

Return value

If the function succeeds, it returns Ok, which is an element of the GpStatus enumeration.

If the function fails, it returns one of the other elements of the GpStatus enumeration.

Description

Gets the colors currently set to be interpolated for this linear gradient brush and their corresponding blend positions.

Example

' ======================================================================================== ' The following example sets the colors that are interpolated for this linear gradient ' brush to red, blue, and green and sets the blend positions to 0, 0.3, and 1. The code ' calls the LinearGradientBrush.GetInterpolationColorCount method of a LinearGradientBrush ' object to obtain the number of colors currently set to be interpolated for the brush. ' Next, the code gets the colors and their positions. Then, the code fills a small ' rectangle with each color. ' ======================================================================================== SUB Example_GetInterpolationColors (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

' // Create a linear gradient brush, and set the colors to be interpolated. DIM colors(0 TO 2) AS ARGB = {ARGB_RED, ARGB_BLUE, ARGB_LIGHTGREEN} DIM positions(0 TO 2) AS SINGLE = {0.0, 0.3, 1.0}

DIM pt1 AS GpPoint = (0, 0) DIM pt2 AS GpPoint = (100, 0)

DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@pt1, @pt2, ARGB_BLACK, ARGB_WHITE) linGrBrush.SetInterpolationColors(@colors(0), @positions(0), 3)

' // Obtain information about the linear gradient brush. ' // How many colors have been specified to be interpolated for this brush? DIM colorCount AS LONG = linGrBrush.GetInterpolationColorCount

' // Allocate a buffer large enough to hold the set of colors. DIM rgcolors(0 TO colorCount - 1) AS ARGB

' // Allocate a buffer to hold the relative positions of the colors. DIM rgPositions(0 TO colorCount - 1) AS SINGLE

' // Get the colors and their relative positions. linGrBrush.GetInterpolationColors(@rgcolors(0), @rgPositions(0), colorCount)

' // Fill a small rectangle with each of the colors. DIM pSolidBrush AS CGpSolidBrush PTR FOR j AS LONG = 0 TO colorCount - 1

pSolidBrush = NEW CGpSolidBrush(rgcolors(j))
  graphics.FillRectangle(pSolidBrush, 15 * j, 0, 10, 10)
  Delete pSolidBrush

NEXT

END SUB ' ========================================================================================

Reference

  • Include file CGpBrush.inc
  • Defined in AfxNova/CGpBrush.inc:427
  • Documented in Graphics/GdiPlus Classes/CGpBrush Classes.md
  • Topic: CGpBrush Class