描述
获取此路径渐变画笔的中心点的颜色.
C++ Syntax
Status GetCenterColor( [out] Color *color ); |
FreeBASIC 语法
FUNCTION GetCenterColor ( _ BYVAL colour AS ARGB PTR _ ) AS GpStatus |
参数
colour
[out]变量指针接收中心点的颜色.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
默认情况下,一个PathGradientBrush对象的中心点是刷的边界路径的中心,但是你可以设置中心点到任何位置,路径的内部或外部,通过调用对象的方法的PathGradientBrush PathGradientBrush.SetCenterPoint.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a PathGradientBrush object and uses it to fill an ellipse.
' Then the code calls the PathGradientBrush.GetCenterColor method of the PathGradientBrush
' object to obtain the center color.
' ========================================================================================
SUB Example_GetCenterColor (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)
' // Fill the ellipse with the path gradient brush.
graphics.FillEllipse(@pthGrBrush, 0, 0, 200, 100)
' // Obtain information about the path gradient brush.
DIM colour AS ARGB
pthGrBrush.GetCenterColor(@colour)
' // Fill a rectangle with the retrieved color.
DIM solidBrush AS CGpSolidBrush = colour
graphics.FillRectangle(@solidBrush, 0, 120, 200, 30)
END SUB
' ========================================================================================