描述
获取此路径渐变画笔的中心点.
C++ Syntax
Status GetCenterPoint( [out] PointF *point ); |
Status GetCenterPoint( [out] Point *point ); |
FreeBASIC 语法
FUNCTION GetCenterPoint ( _ BYVAL pt AS PointF PTR _ ) AS GpStatus |
FUNCTION GetCenterPoint ( _ BYVAL pt AS Point PTR _ ) AS GpStatus |
参数
pt
[out]指向PointF或Point结构接收中心点.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
默认情况下,一个PathGradientBrush对象的中心点是在刷的边界路径的中心,但是你可以设置中心点到任何位置,路径的内部或外部,通过调用对象的方法的PathGradientBrush SetCenterPoint.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example demonstrates several methods of the PathGradientBrush class including
' PathGradientBrush.GetCenterPoint and PathGradientBrush.SetCenterColor. The code creates
' a PathGradientBrush object and then sets the brush's center color and boundary color.
' The code calls the PathGradientBrush.GetCenterPoint method to determine the center point
' of the path gradient and then draws a line from the origin to that center point.
' ========================================================================================
SUB Example_GetCenterPoint (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 centerPoint AS GpPointF
pthGrBrush.GetCenterPoint(@centerPoint)
' // Draw a line from the origin to the center of the ellipse.
DIM pen AS CGpPen = GDIP_ARGB(255, 0, 255, 0)
DIM pt AS GpPointF = GDIP_POINTF(0, 0)
graphics.DrawLine(@pen, @pt, @centerPoint)
END SUB
' ========================================================================================