Syntax
Brush = CreateBrushGradientRadial(CenterX.d, CenterY.d, OriginOffsetX.d, OriginOffsetY.d, RadiusX.d, RadiusY.d, StartColor.l, StartOpacity.f, EndColor.l, EndOpacity.f, StartPosition.f=0, EndPosition.f=1)
Description
Creates a radial gradient brush that blends colors outwards from an origin point within an ellipse defined by a center point and radii. This version creates a simple two-color gradient. For more complex gradients with multiple colors, use CreateBrushGradientRadialEx() or add stops with BrushGradientAddColor().
Parameters
CenterX.d, CenterY.d
The coordinates (in DIPs relative to the drawing origin) of
the center of the gradient ellipse.
OriginOffsetX.d, OriginOffsetY.d
The offset (in DIPs) of the gradient origin
relative to the `CenterX`, `CenterY`. The `StartColor` begins at this origin point. Setting these to
0 centers the origin.
RadiusX.d, RadiusY.d
The horizontal and vertical radii (in DIPs) of the gradient
ellipse.
StartColor.l
The color (RGB value) at the gradient origin.
StartOpacity.f
The opacity (0.0 to 1.0) at the gradient origin.
EndColor.l
The color (RGB value) at the edge of the gradient ellipse (defined by
the radii).
EndOpacity.f
The opacity (0.0 to 1.0) at the edge of the gradient ellipse.
StartPosition.f (optional)
The relative position (0.0 to 1.0) along the radius
where the `StartColor` is fully opaque. Default is 0.0 (the origin).
EndPosition.f (optional)
The relative position (0.0 to 1.0) along the radius
where the `EndColor` is fully opaque. Default is 1.0 (the edge defined by the radii).
Return Value
Returns a handle to the newly created radial gradient brush object if successful, or #Null
if the brush could not be created.
Remarks
The gradient transitions between `StartColor` (at the origin point offset from the center) and `EndColor` (at the ellipse boundary). The shape of the gradient is determined by `RadiusX` and `RadiusY`. If they are equal, the gradient is circular. The extend mode (BrushSetExtendMode) determines behavior outside the ellipse. The brush can be transformed. Remember to free the brush using FreeBrush().
Example
IncludeFile "ProGUI_PB.pbi"
Global MyGradient
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw)
DrawClear(RGB(240, 240, 240), 1)
; Position the brush fill relative to the window origin (50, 50)
BrushSetPosition(MyGradient, 50, 50)
DrawBoxFill(50, 50, 300, 200, MyGradient)
EndProcedure
StartProGUI()
MyWindow = CreateWindow(0, 0, 400, 300, "Radial Gradient Brush")
If MyWindow
; Create a radial gradient centered in a 300x200 area
; Center: (150, 100), Origin offset: (0, 0), Radii: (150, 100)
; Starts yellow at center, ends red at edges
CenterX = 150 : CenterY = 100
RadiusX = 150 : RadiusY = 100
MyGradient = CreateBrushGradientRadial(CenterX, CenterY, 0, 0, RadiusX, RadiusY, RGB(255, 255, 0), 1.0, RGB(255, 0, 0), 1.0)
If MyGradient
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
FreeBrush(MyGradient) ; Free the brush
EndIf
EndIf
StopProGUI()
See Also
CreateBrushGradientRadialEx, BrushGradientAddColor, BrushGradientRadialSetPoints, BrushSetExtendMode, DrawBoxFill, FreeBrush
Supported OS
Windows, Linux