描述
获取当前为此路径渐变刷设置的混合因子和相应的混合位置.
C++ Syntax
Status GetBlend( [out] REAL *blendFactors, [out] REAL *blendPositions, [in] INT count ); |
FreeBASIC 语法
FUNCTION GetBlend ( _ BYVAL blendFactors AS SINGLE PTR, _ BYVAL blendPositions AS SINGLE PTR, _ BYVAL count AS LONG _ ) AS GpStatus |
参数
blendFactors
[out]数组指针接收混合因子.
blendPositions
[out]数组指针接收混合位置.
count
[in]整数,指定要检索的混合因子数.调用一个对象的PathGradientBrush.GetBlend PathGradientBrush方法之前,调用同一PathGradientBrush对象的PathGradientBrush.GetBlendCount方法来确定当前的混合因子数.检索的混合位置的数目是相同的检索的混合因子的数目.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
一个PathGradientBrush对象有一个边界路径和中心点.当你用路径渐变笔刷填充一个区域时,当你从边界路径移动到中心点时,颜色会逐渐改变.默认情况下,色彩的距离成线性关系,但可以通过调用PathGradientBrush.SetBlend方法自定义颜色和距离之间的关系.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example demonstrates several methods of the PathGradientBrush class including
' PathGradientBrush.SetBlend, PathGradientBrush.GetBlendCount, and PathGradientBrush.GetBlend.
' The code creates a PathGradientBrush object and calls the PathGradientBrush.SetBlend method
' to establish a set of blend factors and blend positions for the brush. Then the code calls
' the PathGradientBrush.GetBlendCount method to retrieve the number of blend factors. After
' the number of blend factors is retrieved, the code allocates two buffers: one to receive
' the array of blend factors and one to receive the array of blend positions. Then the code
' calls the PathGradientBrush.GetBlend method to retrieve the blend factors and the blend
' positions.
' ========================================================================================
SUB Example_GetBlend (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)
' // Obtain information about the path gradient brush.
DIM blendCount AS LONG = pthGrBrush.GetBlendCount
DIM rgFactors(blendCount - 1) AS SINGLE
DIM rgPositions(blendCount - 1) AS SINGLE
pthGrBrush.GetBlend(@rgFactors(0), @rgPositions(0), blendCount)
FOR j AS LONG = 0 TO blendCount - 1
' // Inspect or use the value in rgFactors(j)
' // Inspect or use the value in rgPositions(j)
OutputDebugString STR(rgFactors(j)) & STR(rgPositions(j))
NEXT
END SUB
' ========================================================================================