Syntax
DrawSetStrokeMiterLimit(MiterLimit.f)
Description
Sets the miter limit for mitered line joins. The miter limit is the maximum ratio of the miter length (the distance from the inner corner to the outer corner of the join) to half the stroke width. If the miter length exceeds this limit, the join is converted from a miter join to a bevel join.
Parameters
MiterLimit.f
The maximum miter length ratio. Must be 1.0 or greater. A typical
default value is 10.0.
Return Value
This command does not return a value. It returns internally if MiterLimit is less than 1.0 or if called outside a BeginDraw() / EndDraw() block.
Remarks
This setting only affects corners drawn when the line join style is set to the default (mitered join),
which happens when neither #PG_Stroke_RoundCorner nor #PG_Stroke_BevelCorner
is specified in DrawSetStroke(). It prevents extremely long spikes at
sharp corners when using thick strokes. A higher limit allows for sharper, longer miters. The setting
persists until changed again or until the drawing state is restored via DrawRestore().
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
DrawClear(RGB(255, 255, 255), 1)
DrawSetStroke(15, #PG_Stroke_Center) ; Use a thick stroke to see the effect
; Draw sharp angle with default miter limit (usually 10.0) - might bevel
PathMoveTo(20, 100)
PathAddLine(70, 30)
PathAddLine(120, 100)
DrawPathStroke(RGB(255, 0, 0))
; Draw same shape with a very small miter limit (forces bevel)
DrawSetStrokeMiterLimit(1.1) ; Low limit
PathMoveTo(150, 100)
PathAddLine(200, 30)
PathAddLine(250, 100)
DrawPathStroke(RGB(0, 0, 255))
; Restore default stroke width and miter limit
DrawSetStroke(1)
DrawSetStrokeMiterLimit(10.0)
EndProcedure
MyWindow = CreateWindow(0, 0, 280, 150, "Miter Limit 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, DrawPathStroke, BeginDraw, EndDraw
Supported OS
Windows, Linux