描述
设置要为这个线性渐变画笔和相应的混合位置进行插值的颜色.
C++ Syntax
Status SetInterpolationColors( [in] const Color *presetColors, [in] const REAL *blendPositions, [in] INT count ); |
FreeBASIC 语法
FUNCTION SetInterpolationColors ( _ BYVAL presetColors AS ARGB PTR, _ BYVAL blendPositions AS SINGLE PTR, _ BYVAL count AS LONG _ ) AS GpStatus |
参数
presetColors
[in]指向ARGB颜色指定颜色插值线性渐变画笔数组.一种颜色的一个给定的指标在presetColors阵列对应于同一指标在blendPositions阵列混合位置.
blendPositions
[in]指针简单精度数字指定混合位置数组.数组中指定的开始和结束的边界和边界之间的距离的百分比数字是从哪里0.0通过1.0, 0.0表明梯度和1.0起始边界表示结束的边界范围.至少要有两个指定位置:第一的位置,这始终是0.0f,和最后的位置,这始终是1.0f.否则,该行为是未定义的.0.0和1.0之间的混合位置指示线,平行的边界线,这是一个一定的分数,距离开始到结束边界的边界.例如,对0.7混合位置指示线,从开始到结束的边界,边界的距离百分之70.在平行于边界线的线条上,颜色是恒定的.
count
[in]整数,指定在presetColors数组元素个数.这是因为在blendPositions数组的元素个数.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a linear gradient brush, sets the colors to be interpolated
' for the linear gradient brush, and fills a rectangle.
' ========================================================================================
SUB Example_SetInterpolationColors (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)
' // Create a linear gradient brush, and set the colors to be interpolated.
DIM colors(0 TO 2) AS ARGB = {GDIP_ARGB(255, 255, 0, 0), GDIP_ARGB(255, 0, 0, 255), GDIP_ARGB(255, 0, 255, 0)}
DIM positions(0 TO 2) AS SINGLE = {0.0, 0.3, 1.0}
DIM pt1 AS GpPoint = GDIP_POINT(0, 0)
DIM pt2 AS GpPoint = GDIP_POINT(100, 0)
DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@pt1, @pt2, GDIP_ARGB(255, 0, 0, 0), GDIP_ARGB(255, 255, 255, 255))
linGrBrush.SetInterpolationColors(@colors(0), @positions(0), 3)
graphics.FillRectangle(@linGrBrush, 0, 0, 100, 50)
END SUB
' ========================================================================================