Graphics.ClipToRectangle

From Xojo Documentation

Revision as of 18:55, 11 March 2021 by PLefebvre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
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