描述
获取当前为此路径渐变刷设置的混合因子的数目.
C++ Syntax
INT GetBlendCount() const; |
FreeBASIC 语法
FUNCTION GetBlendCount () AS INT_ |
参数
该方法没有参数.
返回值
在你打电话的PathGradientBrush对象的PathGradientBrush.GetBlend方法,你必须分配缓冲:一个接收的混合因子数组和一个接收的混合位置的数组.确定所需的缓冲区的大?降?span style="font-weight: bold;">PathGradientBrush对象的PathGradientBrush.GetBlendCount方法.的大?ㄒ宰纸谖ノ唬┟扛龌撼迩Ω檬?span style="font-weight: bold;">PathGradientBrush.GetBlendCount乘以4的返回值(一个简单的精度数的大??
引用文件
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
' ========================================================================================