描述
获取当前为该路径渐变画笔指定的预置颜色和混合位置.
C++ Syntax
Status GetInterpolationColors( [out] Color *presetColors, [out] REAL *blendPositions, [in] INT count ) const; |
FreeBASIC 语法
FUNCTION GetInterpolationColors ( _ BYVAL presetColors AS ARGB PTR, _ BYVAL blendPositions AS SINGLE PTR, _ BYVAL count AS INT_ _ ) AS GpStatus |
参数
presetColors
[out]数组指针接收预设的颜色.一种颜色的一个给定的指标在presetColors阵列对应于同一指标在blendPositions阵列混合位置.
blendPositions
[out]数组指针接收混合位置.每个混合位置是一个数字从0到1,其中0表示梯度的边界和1表示中心点.0和1之间的混合位置表示所有点的集合,它们是距离边界到中心点距离的一部分.例如,对0.7混合位置指示点是从边界到中心点的方式,百分之70套.
count
[in]整数,指定在presetColorsarray元素个数.这是因为在blendPositions数组的元素个数.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
一个简单的路径渐变刷有两种颜色:边界颜色和中心颜色.当你用这种画笔作画时,当你从边界路径移动到中心点时,颜色从边界颜色逐渐变为中心颜色.您可以通过指定预置颜色数组和混合位置数组来创建更复杂的渐变.
在你打电话的PathGradientBrush.GetInterpolationColors方法,你必须分配缓冲:一个拥有预设颜色数组和一个持有的混合位置数组.你可以调用该对象的PathGradientBrush.GetInterpolationColorCount PathGradientBrush方法来确定所需的缓冲区大小.的颜色缓冲区的大小是PathGradientBrush.GetInterpolationColorCount乘以4的返回值.位置的缓冲区的大小是PathGradientBrush.GetInterpolationColorCount数值乘以4(一个简单的精度数的大??
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a PathGradientBrush object from a triangular path. The code
' sets the preset colors to red, blue, and aqua and sets the blend positions to 0, 0.6, and 1.
' The code calls the PathGradientBrush.GetInterpolationColorCount method of the PathGradientBrush
' object to obtain the number of preset colors currently set for the brush. Next, the code
' allocates two buffers: one to hold the array of preset colors, and one to hold the array
' of blend positions. The call to the PathGradientBrush.GetInterpolationColors method of
' the PathGradientBrush object fills the buffers with the preset colors and the blend positions.
' Finally the code fills a small square with each of the preset colors.
' ========================================================================================
SUB Example_GetInterpolationColors (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context
DIM graphics AS CGpGraphics = hdc
' // Get the DPI scaling ratio
DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
' // Set the scale transform
graphics.ScaleTransform(rxRatio, ryRatio)
DIM points(0 TO 2) AS GpPoint = {GDIP_POINT(100, 0), GDIP_POINT(200, 200), GDIP_POINT(0, 200)}
DIM pthGrBrush AS CGpPathGradientBrush = CGpPathGradientBrush(@points(0), 3)
DIM colors(0 TO 2) AS ARGB = {GDIP_ARGB(255, 255, 0, 0), GDIP_ARGB(255, 0, 0, 255), GDIP_ARGB(255, 0, 255, 255)}
DIM positions(0 TO 2) AS SINGLE = {0.0, 0.6, 1.0}
pthGrBrush.SetInterpolationColors(@colors(0), @positions(0), 3)
' // Obtain information about the path gradient brush.
DIM colorCount AS LONG = pthGrBrush.GetInterpolationColorCount
DIM rgColors(colorCount - 1) AS ARGB
DIM rgPositions(colorCount - 1) AS SINGLE
pthGrBrush.GetInterpolationColors(@rgColors(0), @rgPositions(0), colorCount)
' // Fill a small square with each of the interpolation colors.
DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 255, 255, 255)
FOR j AS LONG = 0 TO colorCount - 1
solidBrush.SetColor(rgColors(j))
graphics.FillRectangle(@solidBrush, 15 * j, 0, 10, 10)
NEXT
END SUB
' ========================================================================================