Graphics.ClipToPath

From Xojo Documentation

Method

Graphics.ClipToPath(path As GraphicsPath)

New in 2020r2

Supported for all project types and targets.

Clips the drawing to the specified GraphicsPath.

Notes

If you need to clear a Clip after it has been used, call SaveState before calling ClipToRectangle() and then call RestoreState when you no longer want the clipping in effect.

Sample Code

From within an MobileCanvas.Paint event handler:

// Clip to a GraphicsPath
// Path is a triangle
Var p As New GraphicsPath
p.MoveToPoint(0, 0) // Start location
p.AddLineToPoint(20, 44)
p.AddLineToPoint(40, 0)
p.AddLineToPoint(0, 0)

g.SaveState
g.ClipToPath(p)
g.FillOval(0, 0, 50, 50)
g.RestoreState

See Also

Graphics.SaveState, Graphics.RestoreState methods