Clipping Operators

Model for Clipping

The region of the page image within which imaging operators are allowed to have an effect is called the clipping region. The CurrentClippingRegion Graphics State Variable represents the clipping region in effect, and is represented in the Reference Coordinate System. At the beginning of a page, the CurrentClippingRegion is set to include the entire imageable region of the medium provided a superior block does not changed the CurrentClippingRegion. The operators which modify the CurrentClippingRegion do so by intersecting it with a region derived from the CurrentPath.

Operators

The specification of these operators and their semantics includes the specification of conditions which may cause content exceptions to be raised as a result of interpretation of the operators. Content exceptions and exception handling are defined in . In addition to these operator-specific exceptions, there are generic exceptions which may be raised during the interpretation of almost any operator. These generic exceptions and their semantics are described in .

ClipPath

The ClipPath operator accepts no operand and returns no results. It modifies the CurrentClippingRegion Graphics State Variable using the CurrentPath Graphics State Variable, but does not change the value of CurrentPath.

ClipPath implicitly closes any open path segments of the CurrentPath and determines the interior of the resulting shapes according to the non-zero winding rule. The Graphics State Variable CurrentClippingRegion is then set to the intersection of the current CurrentClippingRegion with the interior of the shape determined from the CurrentPath. If the CurrentPath is the null path, the value of the resultant CurrentClippingRegion is an implementation-dependent non-empty Path which encloses zero area.

ClipPathEvenOdd

The ClipPathEvenOdd imaging operator accepts no operand and returns no results. It modifies the CurrentClippingRegion Graphics State Variable using the CurrentPath Graphics State Variable, but does not change the value of CurrentPath.

ClipPathEvenOdd implicitly closes any open path segments of the CurrentPath and determines the interior of the resulting shapes according to the even/odd winding rule. The Graphics State Variable CurrentClippingRegion is then set to the intersection of the current CurrentClippingRegion with the interior of the shape determined from the CurrentPath. If the CurrentPath is the null path, the value of the resultant CurrentClippingRegion is an implementation-dependent non-empty Path which encloses zero area.

RectangleClip

The RectangleClip operator takes four operands

  • <height: Number>
  • <width: Number>
  • <y: Number>
  • <x: Number> and returns no results. It creates a new closed rectangular path with one path segment. The Graphics State Variable CurrentClippingRegion is then set to the intersection of the value of the CurrentClippingRegion Graphics State Variable with the interior of the rectangular path. After compute the new clipping path, RectangleClip resets the CurrentPath Graphics State Variable to the null path and makes the CurrentPosition Graphics State Variable be undefined.

    Under the assumption that height and width are positive, the RectangleClip operator is equivalent to the following procedure:

  • {
  • % Start a new path for the rectangle
  • NewPath
  • % Position at one corner
  • x y SetPosition
  • % Draw lines to other corner
  • width 0 LineToRelative
  • 0 height LineToRelative
  • % Add final two sides of rectangle
  • width Negate 0 LineToRelative
  • ClosePathSegment
  • % Intersect Rectangle with CurrentClippingRegion
  • % yielding a new CurrentClippingRegion
  • ClipPath
  • % Erase all trace of the rectangle path
  • Newpath
  • }