GdipGetLineRectfunction
Gets the rectangle that defines the boundaries of the gradient.
Syntax
FUNCTION GdipGetLineRect (BYVAL brush AS GpLineGradient PTR, BYVAL rcf AS GpRectF PTR) AS GpStatus
GdipGetLineRectI — one description covers them all.Parameters
| Name | Description | |
|---|---|---|
brush | [in] Pointer to the LinearGradientBrush object. | |
rect | [out] Pointer to a GpRectF object that receives the rectangle that defines the boundaries of the gradient. For example, if a linear gradient brush is constructed with a starting point at (20.2, 50.8) and an ending point at (60.5, 110.0), then the defining rectangle has its upper-left point at (20.2, 50.8), a width of 40.3, and a height of 59.2. |
Description
Gets the rectangle that defines the boundaries of the gradient.
Example
' ======================================================================================== ' The following example creates a linear gradient brush. Then the code gets the brush's ' rect and draws a rectangle with these values. ' ======================================================================================== SUB Example_GetLineRect (BYVAL hdc AS HDC)
DIM hStatus AS LONG
' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)
' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)
' // Create a linear gradient brush DIM pt1 AS GpPointF = (20, 10) DIM pt2 AS GpPointF = (60, 110) DIM brush AS GpLineGradient PTR hStatus = GdipCreateLineBrush(@pt1, @pt2, ARGB_BLACK, ARGB_BLUE, WrapModeTile, @brush)
' // Get the rectangle that defines the boundaries of the gradient. DIM rcf AS GpRectF hStatus = GdipGetLineRect(brush, @rcf)
' // Draw the retrieved rectangle. DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_BLACK, 1 * rxRatio, UnitPixel, @pen) hStatus = GdipDrawRectangle(graphics, pen, rcf.x, rcf.y, rcf.Width, rcf.Height)
' // Cleanup IF pen THEN GdipDeletePen(pen) IF brush THEN GdipDeleteBrush(brush) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2171
- Documented in Graphics/GdiPlus Flat Api/GdiPlusLinearGradientBrush.md
- Topic: GdiPlusLinearGradientBrush