BrushGradientRadialSetPoints

Syntax

Success = BrushGradientRadialSetPoints(Brush, CenterX.d, CenterY.d, OriginOffsetX.d, OriginOffsetY.d, RadiusX.d, RadiusY.d)

Description

Modifies the geometric properties (center, origin offset, radii) of an existing radial gradient brush.

Parameters

Brush
The handle of the existing radial gradient brush to modify.

CenterX.d, CenterY.d
The new coordinates (in DIPs) for the center of the gradient ellipse.

OriginOffsetX.d, OriginOffsetY.d
The new offset (in DIPs) of the gradient origin relative to the `CenterX`, `CenterY`.

RadiusX.d, RadiusY.d
The new horizontal and vertical radii (in DIPs) of the gradient ellipse.

Return Value

Returns #True if the points were successfully updated, or #False if the brush handle was invalid or not a radial gradient brush.

Remarks

This function allows changing the shape, position, and origin of the radial gradient without recreating the entire brush object, useful for animations or interactive adjustments. The color stops remain unchanged.

Example

IncludeFile "ProGUI_PB.pbi"

Global MyGradient

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw)
  Static offset.d = 0, dir=1
  DrawClear(RGB(240, 240, 240), 1)

  ; Animate the origin offset horizontally
  BrushGradientRadialSetPoints(MyGradient, 200, 150, offset, 0, 150, 100)

  DrawBoxFill(50, 50, 300, 200, MyGradient)

  offset + (2 * dir)
  If Abs(offset) >= 70 : dir * -1 : EndIf ; Bounce offset between -70 and 70
EndProcedure

Procedure AnimationUpdate(Window, EventType, *EventData.PG_EventAnimate)
  WindowRedraw(Window)
EndProcedure

StartProGUI()

MyWindow = CreateWindow(0, 0, 400, 300, "Moving Gradient Origin")

If MyWindow
  MyGradient = CreateBrushGradientRadial(200, 150, 0, 0, 150, 100, RGB(0, 255, 0), 1.0, RGB(0, 0, 255), 1.0) ; Green to Blue

  If MyGradient
    AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
    AddEventHandler(MyWindow, #PG_Event_Animate, @AnimationUpdate())
    StartAnimation(MyWindow) ; Start continuous animation

    WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

    Repeat
        Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow

    FreeBrush(MyGradient)
  EndIf
EndIf

StopProGUI()

See Also

CreateBrushGradientRadial, CreateBrushGradientRadialEx, FreeBrush

Supported OS

Windows, Linux