描述
得到的混合因子的数量目前为这个LinearGradientBrush对象.
C++ Syntax
INT GetBlendCount() const; |
FreeBASIC 语法
FUNCTION GetBlendCount () AS INT_ |
参数
该方法没有参数.
返回值
此方法返回的混合因子的数量目前为这个LinearGradientBrush对象.如果没有自定义的共混物已被使用LinearGradientBrush.SetBlend,或者无效的位置传给了LinearGradientBrush.SetBlend,然后LinearGradientBrush.GetBlend返回1.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a linear gradient brush, sets its blend, and uses the brush
' to fill a rectangle. The code then gets the blend. The blend factors and positions can
' then be inspected or used in some way.
' ========================================================================================
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)
DIM factors(0 TO 3) AS SINGLE = {0.0, 0.4, 0.6, 1.0}
DIM positions(0 TO 3) AS SINGLE = {0.0, 0.2, 0.8, 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, 255, 0, 0), GDIP_ARGB(255, 0, 0, 255))
linGrBrush.SetBlend(@factors(0), @positions(0), 4)
' // Use the linear gradient brush to fill a rectangle.
graphics.FillRectangle(@linGrBrush, 0, 0, 100, 50)
' // Obtain information about the linear gradient brush.
DIM blendCount AS LONG = linGrBrush.GetBlendCount
DIM rgFactors(blendCount - 1) AS SINGLE
DIM rgPositions(blendCount - 1) AS SINGLE
linGrBrush.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
' ========================================================================================