Skip to content

CLIP_PATH ​

Restrict drawing to an area by setting or modifying the clipping region with based on a defined path.

Syntax ​

leo-grammar
CLIP_PATH [ combine-mode: CombineMode ] .

CombineMode :  copy | and | or | diff | xor .

Parameters ​

  • combine-mode (modifier, optional) - Whether and how to combine the clipping region with an existing clipping region. Should be one of copy, and, or, diff or xor. The default is copy.

Details ​

This command restricts the area in which anything is drawn by setting a clipping region or modifying an existing clipping region. All drawing which lies outside the current clipping region is ineffective, while all parts of elements inside are visible. The clipping region can be of any shape by combining several basic shapes. A clipping region can even consist of disjoint parts.

The CLIP_PATH command sets / modifies the clipping region based on a previously defined path. For additional details defining paths see the commands BEGIN_PATH, MOVE_TO, LINE_TO, BEZIER_TO and END_PATH. Otherwise this command behaves similarly to the DRAW_PATH command with a mode:fill.

At the beginning of a GraphRep drawing, no clipping is active. When reaching a clipping command, the current clipping region is set to the given shape. If clipping is already active, the new region can either replace the current clipping region (combine-mode:copy, which is the default) or can be combined with the current clipping region with one of the following combine-mode operators:

  • and: The resulting clipping region includes everything which belongs to both regions (intersection).
  • or: The resulting clipping region includes everything which belongs at least to one of both regions (union).
  • diff: The resulting clipping region is the current clipping region with the given region removed from it (difference, subtraction).
  • xor: The resulting clipping region includes everything which belongs to exactly one of both regions (symmetric difference).

The current clipping region can be deactivated with the CLIP_OFF command.

The combine-mode:and, combine-mode:diff and combine-mode:xor are not fully supported in SVG Graphics. Instead of combinations, separate clippings have to be defined.

See Also ​

Examples ​

Draw only a part of the image "nao_1.jepg" (located in the library's database), with the cut-out using a complex path to define the clipping region.
Part of an image of a blue NAO robot

leo
GRAPHREP

# Define the path.
BEGIN_PATH
MOVE_TO x:0cm y:0cm
LINE_TO x:0cm y:1cm
BEZIER_TO 3
    x1:0.75cm y1:0cm x2:1.5cm y2:3.5cm x3:2cm y3:1cm
LINE_TO x:2cm y:0cm
END_PATH

# Clip the path and draw the image.
CLIP_PATH
BITMAPINFO ("db:\\nao_1.jpeg")
# Image assumed at 120dpi (2.54cm = 1inch) scaled down by a factor of 3
BITMAP ("db:\\nao_1.jpeg")
    x:-0.9cm y:-1.5cm
    w:(bmpwidth / 120 * 2.54cm / 3) h:(bmpheight / 120 * 2.54cm / 3)

Versions and Changes ​

Available since ADOxx 1.3