描述
获取为此路径渐变画笔的边界路径指定的颜色数.
C++ Syntax
INT GetSurroundColorCount(); |
FreeBASIC 语法
FUNCTION GetSurroundColorCount () AS INT_ |
参数
该方法没有参数.
返回值
此方法返回为该路径渐变刷的边界路径指定的颜色数.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a PathGradientBrush object based on a triangular path that
' is defined by an array of three points. The code calls the PathGradientBrush.SetSurroundColors
' method of the PathGradientBrush object to specify a color for each of the points that
' define the triangle. The PathGradientBrush.GetSurroundColorCount method determines the
' current number of surround colors (the colors specified for the brush's boundary path).
' Next, the code allocates a buffer large enough to receive the array of surround colors
' and calls PathGradientBrush.GetSurroundColors to fill that buffer. Finally the code fills
' a small square with each of the brush's surround colors.
' ========================================================================================
SUB Example_GetSurroundColors (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 points(0 TO 2) AS GpPoint = {GDIP_POINT(100, 0), GDIP_POINT(200, 200), GDIP_POINT(0, 200)}
DIM pthGrBrush AS CGpPathGradientBrush = CGpPathGradientBrush(@points(0), 3)
DIM nCount AS LONG = 3
DIM colors(0 TO 2) AS ARGB = {GDIP_ARGB(255, 255, 0, 0), GDIP_ARGB(255, 0, 0, 255), GDIP_ARGB(255, 0, 255, 255)}
pthGrBrush.SetSurroundColors(@colors(0), @nCount)
' // Obtain information about the path gradient brush.
DIM colorCount AS LONG = pthGrBrush.GetSurroundColorCount
DIM rgColors(colorCount - 1) AS ARGB
pthGrBrush.GetSurroundColors(@rgColors(0), @colorCount)
' // Fill a small square with each of the surround colors.
DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 255, 255, 255)
FOR j AS LONG = 0 TO colorCount - 1
solidBrush.SetColor(rgColors(j))
graphics.FillRectangle(@solidBrush, 15 * j, 0, 10, 10)
NEXT
END SUB
' ========================================================================================