Clipping

Clipping allows you to ensure your drawing code does not extend outside an area that you define. Basically, you would define an area as the clipping region and then any drawing done to the drawing surface would display its output within the region and not outside the region.

To see how this works exactly, the following code sets a clipping region based on an arbitrary rectangle. Next, a string is drawn to the display surface. Figure 26.17 shows what would be displayed if no clipping region was set. Figure 26.18 shows the result of having the clipping region set. The output is as follows:

Figure 26.17. Example without clipping.
Figure 26.18. ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.