Syntax
DrawBorder(Border, x.d, y.d, Width.d, Height.d, Opacity.f=1, FillBrush=#Null, Flags=#Null)
Description
Draws a border, defined by a border object created with CreateBorder() or CreateBorderImg(), at the specified position and size. Allows for applying an overall opacity and optionally filling the area inside the border with a brush.
Parameters
Border
The handle to the border object to draw.
x.d
The horizontal coordinate of the top-left corner of the border's outer
bounding box in device-independent pixels (DIPs).
y.d
The vertical coordinate of the top-left corner of the border's outer bounding
box in DIPs.
Width.d
The total width of the border's outer bounding box in DIPs.
Height.d
The total height of the border's outer bounding box in DIPs.
Opacity.f (optional)
An overall opacity multiplier (0.0 to 1.0) applied to the
border. Default is 1.0 (fully opaque).
FillBrush (optional)
A brush handle used to fill the area inside the border. If
#Null, the inside area is not filled by this command. Default is #Null.
Flags (optional)
Flags modifying the drawing behavior:
#PG_DrawBorder_FillInside : If FillBrush is provided, only the area strictly *inside* the border edges is filled. Without this flag, FillBrush fills the entire area defined by x, y, Width, Height before the border is drawn over it.
#PG_DrawBorder_NoMask : Forces drawing without using the border's mask, even if one exists.
#PG_DrawBorder_MaskOnly : Draws only the border's mask (useful for compositing effects), ignoring the main border image/colors. The FillBrush parameter is used as the color/pattern to draw the mask with.
#PG_DrawBorder_DrawMask : Draws the border's mask using a solid black color with the specified Opacity. Useful for debugging mask shapes.
Return Value
This command does not return a value. It returns internally if parameters are invalid (e.g., invalid Border handle, negative Width/Height).
Remarks
This is the primary function for rendering borders created with the ProGUI border API. It handles both generated borders (styles, widths, colors, radii) and image-based borders (slicing, scaling, repeating). DPI scaling is applied internally based on the border's settings and the current drawing context. For generated borders, pre-rendered, DPI-specific cached images are used for performance unless the border uses dash/dot styles or has dimensions smaller than its combined widths/heights, in which case it's rendered dynamically using paths.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Create a generated border
Global GenBorder = CreateBorder(#PG_Border_Groove, 10, 15, RGB(0, 0, 200), 0.8)
; Create an image border
BorderImg = LoadImg("icons/border_new2.png")
BorderMask = LoadImg("icons/border_new_mask2.png")
Global ImgBorder = CreateBorderImg(BorderImg, BorderMask, 20, 20, 26, 28, #PG_BorderImg_RepeatRound | #PG_BorderImg_CenterStretch)
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
DrawClear(RGB(255, 255, 255), 1)
; Draw the generated border
DrawBorder(GenBorder, 20, 20, 150, 100, 1.0)
; Draw the image border without internal fill
DrawBorder(ImgBorder, 200, 20, 200, 150)
; Draw the image border's mask only, filled with red
RedBrush = CreateBrushImg(CreateImg(1,1,RGBA(255,0,0,255))) ; Quick way to get a solid color brush
DrawBorder(ImgBorder, 200, 200, 200, 150, 0.75, RedBrush, #PG_DrawBorder_MaskOnly)
FreeBrush(RedBrush)
EndProcedure
MyWindow = CreateWindow(0, 0, 450, 400, "DrawBorder Example")
If MyWindow
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
FreeBorder(GenBorder)
FreeBorder(ImgBorder) ; This also frees the internal mask border
FreeImg(BorderImg)
FreeImg(BorderMask)
StopProGUI()
See Also
CreateBorder, CreateBorderImg, BeginDraw, EndDraw
Supported OS
Windows, Linux