Like a clipping region, a clip path is another graphics object that an application can select into a device context. Unlike a clipping region, a clip path is always created by an application and it is used for clipping to one or more irregular shapes. For example, an application can use the lines and curves that form the outlines of characters in a string of text to define a clip path.
To create a clip path, it's first necessary to create a path that describes the required irregular shape. Paths are created by calling the appropriate graphics device interface (GDI) drawing functions after calling the BeginPath function and before calling the EndPath function. This collection of functions is called a path bracket. For more information about paths and path brackets, see Paths.
After the path is created, it can be converted to a clip path by calling the SelectClipPath function, identifying a device context, and specifying a usage mode. The usage mode determines how the system combines the new clip path with the device context's original clipping region. The following table describes the usage modes.
|RGN_AND||The clip path includes the intersection (overlapping areas) of the device context's clipping region and the current path.|
|RGN_COPY||The clip path is the current path.|
|RGN_DIFF||The clip path includes the device context's clipping region with any intersecting parts of the current path excluded.|
|RGN_OR||The clip path includes the union (combined areas) of the device context's clipping region and the current path.|
|RGN_XOR||The clip path includes the union of the device context's clipping region and the current path but excludes the intersection.|