DrawBoxStrokeFill

Syntax

DrawBoxStrokeFill(x.d, y.d, Width.d, Height.d, Brush)

Description

Draws the outline (stroke) of a rectangle at the specified position and size using the provided brush. The appearance of the stroke (width, dash style, corners, caps) is determined by the current stroke settings defined by DrawSetStroke().

Parameters

x.d
The horizontal coordinate of the rectangle's top-left corner in device-independent pixels (DIPs).

y.d
The vertical coordinate of the rectangle's top-left corner in DIPs.

Width.d
The width of the rectangle in DIPs.

Height.d
The height of the rectangle in DIPs.

Brush
The handle of the brush (created with CreateBrushImg(), CreateBrushGradientLinear(), etc.) used to draw the outline.

Return Value

This command does not return a value. It returns internally if the Brush handle is invalid, or if Width or Height are zero or less.

Remarks

The coordinates and dimensions are specified in DIPs but are converted internally to physical pixels based on the current output's DPI and aligned to the pixel grid before drawing. Use DrawSetStroke() before calling this function to customize the line's appearance. The appearance of the stroke depends on the brush type (image, gradient) and its properties (position, scale, rotation, extend mode, opacity).

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

; Create an image brush
MyImage = CreateImg(10, 10, RGB(200, 0, 200))
Global ImageBrush = CreateBrushImg(MyImage)
BrushSetExtendMode(ImageBrush, #PG_Brush_ExtendMode_Repeat, #PG_Brush_ExtendMode_Repeat) ; Tile the image

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)

    DrawClear(RGB(255, 255, 255), 1) ; White background

    ; Set stroke to 10px wide
    DrawSetStroke(10)
    ; Draw a box outline using the repeating image brush
    DrawBoxStrokeFill(20, 20, 150, 100, ImageBrush)

    ; Restore default stroke
    DrawSetStroke(1)

EndProcedure

MyWindow = CreateWindow(0, 0, 200, 150, "DrawBoxStrokeFill Example")

If MyWindow
  AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

FreeBrush(ImageBrush)
FreeImg(MyImage)
StopProGUI()

See Also

DrawSetStroke, DrawBoxStroke, DrawBoxFill, DrawRoundBoxStrokeFill, CreateBrushImg, CreateBrushGradientLinear, BeginDraw, EndDraw

Supported OS

Windows, Linux