描述
设置此路径渐变画笔的混合因子和混合位置.
C++ Syntax
Status SetBlend( [in] const REAL *blendFactors, [in] const REAL *blendPositions, [in] INT count ); |
FreeBASIC 语法
FUNCTION SetBlend ( _ BYVAL blendFactors AS SINGLE PTR, _ BYVAL blendPositions AS SINGLE PTR, _ BYVAL nCount AS INT_ _ ) AS GpStatus |
参数
blendFactors
[in]混合因子数组指针.数组中的每个数字应该在0到1的范围内.
blendPositions
[in]混合位置指针数组.数组中的每个数字应该在0到1的范围内.
nCount
[in]整数,指定在blendFactors数组元素个数.这是因为在blendPositions数组的元素个数.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
一个PathGradientBrush对象有一个边界路径和中心点.当你用路径渐变笔刷填充一个区域时,当你从边界路径移动到中心点时,颜色会逐渐改变.默认情况下,色彩的距离成线性关系,但可以通过调用PathGradientBrush.SetBlend方法自定义颜色和距离之间的关系.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a PathGradientBrush object based on an ellipse. The code
' calls the PathGradientBrush::SetBlend method of the PathGradientBrush object to establish
' a set of blend factors and blend positions for the brush. Then the code uses the path
' gradient brush to fill the ellipse.
' ========================================================================================
SUB Example_SetBlend (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 path that consists of a single ellipse.
DIM path AS CGpGraphicsPath
path.AddEllipse(0, 0, 200, 100)
' // Use the path to construct a brush.
DIM pthGrBrush AS CGpPathGradientBrush = @path
' // Set the color at the center of the path to blue.
pthGrBrush.SetCenterColor(GDIP_ARGB(255, 0, 0, 255))
' // Set the color along the entire boundary of the path to aqua.
DIM colors(0) AS ARGB = {GDIP_ARGB(255, 0, 255, 255)}
DIM count AS LONG = 1
pthGrBrush.SetSurroundColors(@colors(0), @count)
' // Set blend factors and positions for the path gradient brush.
DIM factors(0 TO 3) AS SINGLE = {0.0, 0.4, 0.8, 1.0}
DIM positions(0 TO 3) AS SINGLE = {0.0, 0.3, 0.7, 1.0}
pthGrBrush.SetBlend(@factors(0), @positions(0), 4)
' // Fill the ellipse with the path gradient brush.
graphics.FillEllipse(@pthGrBrush, 0, 0, 200, 100)
END SUB
' ========================================================================================