描述
获取当前为该路径渐变画笔指定的环绕色.
C++ Syntax
Status GetSurroundColors( [in] Color *colors, [in, out] INT *count ); |
FreeBASIC 语法
FUNCTION GetSurroundColors ( _ BYVAL colors AS ARGB PTR, _ BYVAL count AS INT_ PTR _ ) AS GpStatus |
参数
colors
[in]指向数组的指针,接收周围的颜色.
count
[in, out]指针指向一个整数,输入,指定颜色的数量要求.如果方法成功,输出上的该参数将接收检索的颜色数.如果方法失败,此参数不接收值.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
路径渐变刷具有边界路径和中心点.中心点设置为单一颜色,但可以在边界上的几个点指定不同的颜色.例如,假设为中心颜色指定红色,并在边界上的不同点指定蓝色、绿色和黄色.当你沿着边界移动时,颜色会逐渐从蓝变绿再变黄再回到蓝色.当你沿着一条直线从边界上的任何点移动到中心点时,颜色就会从边界点的颜色变为红色.
引用文件
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
' ========================================================================================