Syntax
DrawSetStrokeCustom(*CustomDashArray.FLOAT, CustomDashArrayCount)
Description
Defines a custom dash pattern to be used for subsequent stroke operations when the
#PG_Stroke_CustomDash flag is set via DrawSetStroke().
Parameters
*CustomDashArray.FLOAT
A pointer to an array of FLOAT values defining the dash
pattern. The values represent lengths of dashes and gaps alternately, measured in multiples of the
stroke width. For example, {2.0, 1.0, 3.0, 1.0} would mean dash of length 2*width, gap
of 1*width, dash of 3*width, gap of 1*width, repeating.
CustomDashArrayCount
The number of elements in the *CustomDashArray.
Return Value
This command does not return a value. It returns internally if the array pointer is invalid or the count is zero or less.
Remarks
It only defines the custom pattern; the pattern is only applied to strokes after DrawSetStroke() is called with the #PG_Stroke_CustomDash
flag. The pattern defined persists until changed again or until the drawing state is restored via DrawRestore(). The array pointed to by *CustomDashArray
must remain valid as long as the pattern might be used.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Define a custom dash pattern: long dash, short gap, short dash, short gap
Global Dim MyDashPattern.f(3)
MyDashPattern(0) = 4.0 ; Dash length = 4 * stroke width
MyDashPattern(1) = 1.0 ; Gap length = 1 * stroke width
MyDashPattern(2) = 1.0 ; Dash length = 1 * stroke width
MyDashPattern(3) = 1.0 ; Gap length = 1 * stroke width
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
DrawClear(RGB(255, 255, 255), 1)
; Set the custom dash pattern
DrawSetStrokeCustom(@MyDashPattern(), 4)
; Set stroke to use the custom dash pattern, 3px wide
DrawSetStroke(3, #PG_Stroke_CustomDash)
; Draw a line and a box using the custom stroke
DrawLine(10, 20, 200, 20, RGB(128, 0, 128))
DrawBoxStroke(30, 50, 150, 80, RGB(0, 128, 128))
; Restore default stroke
DrawSetStroke(1)
EndProcedure
MyWindow = CreateWindow(0, 0, 230, 150, "Custom Stroke Example")
If MyWindow
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
DrawSetStroke, DrawGetStroke, BeginDraw, EndDraw
Supported OS
Windows, Linux