Graphics.ClipToRectangle

From Xojo Documentation

Method

Graphics.ClipToRectangle(x As Double, y As Double, width As Double, height As Double)

New in 2020r2

Supported for all project types and targets.

Clips the drawing to the specified rectangle.

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:

// The part of the circle drawn outside the clip area
// is not displayed.
g.SaveState
g.ClipToRectangle(0, 0, 50, 50)

g.DrawingColor = Color.Blue
g.FillOval(25, 25, 50, 50)
g.RestoreState // removes the clipping rectangle

See Also

Graphics.SaveState, Graphics.RestoreState methods