描述
获取定义渐变边界的矩形.
C++ Syntax
Status GetRectangle( [out] RectF* rect ) const; |
FreeBASIC 语法
FUNCTION GetRectangle ( _ BYVAL rc AS GpRectF PTR _ ) AS GpStatus |
参数
rc
[out]指针指向一个结构,RectF接收定义梯度的边界矩形.例如,如果一个线性渐变画笔与起始点和终结点(20.2, 50.8)在(60.5, 110.0),然后定义矩形的左上点(20.2, 50.8),宽度和高度59.2.构建40.3,
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
矩形定义的梯度的边界在以下几个方面:对矩形形式的水平梯度的边界左边;顶部和底部形成一个垂直梯度的边界;两对角相对的角落位于对角线梯度的边界.在每一种情况下,任一边/角可能位于起始边界上,这取决于起始点和结束点是如何传递给构造函数的.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a linear gradient brush. Then the code gets the brush's
' rectangle and draws it.
' ========================================================================================
SUB Example_GetRectangle (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 linear gradient brush.
DIM pt1 AS GpPoint = GDIP_POINT(20, 10)
DIM pt2 AS GpPoint = GDIP_POINT(60, 110)
DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@pt1, @pt2, _
GDIP_ARGB(255, 0, 0, 0), GDIP_ARGB(255, 0, 0, 255))
' // Obtain information about the linear gradient brush.
DIM rc AS GpRect
linGrBrush.GetRectangle(@rc)
' // Draw the retrieved rectangle.
DIM pen AS CGpPen = GDIP_ARGB(255, 0, 0, 0)
graphics.DrawRectangle(@pen, @rc)
END SUB
' ========================================================================================