org.freedesktop.cairo

## Class Operator

- Object
- - org.freedesktop.bindings.Constant
  - - org.freedesktop.cairo.Operator

-     public class Operator
      extends org.freedesktop.bindings.Constant

  Constants specifying the compositing operating mode in effect. These are set for a drawing Context using `setOperator()`, and take effect when commands like `paint()` are invoked.

  The Context should be created using a cairo `Surface`. The operators don't seem to work correctly when a `Drawable` is used instead of a cairo Surface.

  The example images shown below were generated with the following code:

       cr.rectangle(0, 0, 75, 75);
       cr.setSource(0.7, 0, 0, 0.8);
       cr.fill();

       cr.setOperator(Operator.FOO);

       cr.rectangle(40, 40, 75, 75);
       cr.setSource(0, 0, 0.9, 0.4);
       cr.fill();

  The drawing operations in cairo are said to be bounded and unbounded with reguards to the Surface to be drawn to.

  When an operator is said to be bounded any cairo mask present determines where the operation is applied.

  When an operator is said to be unbounded the operation is applied ignoring any present mask. Note: Clipping can still limit an unbounded operator.

  Since:
    4.0.7
  Author:
    Andrew Cowie, Kenneth Prugh, Zak Fenton

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Operator` | `ADD` Add the colors of the overlapping region.
    `static Operator` | `ATOP` Draw only where existing pixels are, mixing the color of the overlapping region.
    `static Operator` | `CLEAR` Clear a surface to all transparent.
    `static Operator` | `DEST` Any existing pixels are left untouched, while the current drawing is discarded.
    `static Operator` | `DEST_ATOP` Draw and clear any existing pixels outside the overlapping region, the color of the overlapping region is mixed similar to the `ATOP` Operator.
    `static Operator` | `DEST_IN` Draw below the overlapping region, clearing everything outside the region similar to the `IN` Operator.
    `static Operator` | `DEST_OUT` Reduce the visibility of the overlapping region.
    `static Operator` | `DEST_OVER` Draw below any existing pixels with similar results to the `OVER` operator.
    `static Operator` | `IN` Draw only where existing pixels are, clearing the rest of the surface.
    `static Operator` | `OUT` Draw only where existing pixels are not present, leaving a shadow behind where the two overlapped due to transparency.
    `static Operator` | `OVER` Draws the specified source object over the underlying object as if both objects were two overlapping panels of transparent glass.
    `static Operator` | `SATURATE` Saturate the colors of the overlapping region.
    `static Operator` | `SOURCE` Draw over existing pixels as if they were not present.
    `static Operator` | `XOR` XOR the colors of the overlapping region.

  - ### Method Summary

    - ### Methods inherited from class org.freedesktop.bindings.Constant

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ADD

          public static final Operator ADD

      Add the colors of the overlapping region.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.16

    - #### ATOP

          public static final Operator ATOP

      Draw only where existing pixels are, mixing the color of the overlapping region.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.16

    - #### CLEAR

          public static final Operator CLEAR

      Clear a surface to all transparent.

      This operator is bounded.

      Since:
        4.0.7

    - #### DEST

          public static final Operator DEST

      Any existing pixels are left untouched, while the current drawing is discarded.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.16

    - #### DEST_ATOP

          public static final Operator DEST_ATOP

      Draw and clear any existing pixels outside the overlapping region, the color of the overlapping region is mixed similar to the `ATOP` Operator.

      This operator is unbounded.

      Since:
        4.0.16

    - #### DEST_IN

          public static final Operator DEST_IN

      Draw below the overlapping region, clearing everything outside the region similar to the `IN` Operator.

      This operator is unbounded.

      Since:
        4.0.16

    - #### DEST_OUT

          public static final Operator DEST_OUT

      Reduce the visibility of the overlapping region.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.16

    - #### DEST_OVER

          public static final Operator DEST_OVER

      Draw below any existing pixels with similar results to the `OVER` operator.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.16

    - #### IN

          public static final Operator IN

      Draw only where existing pixels are, clearing the rest of the surface.

      This operator is unbounded.

      Since:
        4.0.16

    - #### OUT

          public static final Operator OUT

      Draw only where existing pixels are not present, leaving a shadow behind where the two overlapped due to transparency.

      This operator is unbounded.

      Since:
        4.0.16

    - #### OVER

          public static final Operator OVER

      Draws the specified source object over the underlying object as if both objects were two overlapping panels of transparent glass. This only applies to objects that have an alpha channel; if the objects do not have an alpha channel, the source object simply paints over the underlying object.

      This is the default operator.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.10

    - #### SATURATE

          public static final Operator SATURATE

      Saturate the colors of the overlapping region.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.16

    - #### SOURCE

          public static final Operator SOURCE

      Draw over existing pixels as if they were not present.

      This operator is bounded.

      As an example, you could set up the object to be drawn over:

           cr.setSource(0.7, 0, 0, 0.8);
           cr.rectangle(15, 10, 50, 50);
           cr.fill();

      Now set up the source object that will draw over the area beneath it:

           cr.setSource(0, 0, 0.9, 0.4);
           cr.rectangle(35, 35, 50, 50);
           cr.setOperator(Operator.SOURCE);
           cr.fill();

      Since:
        4.0.16

    - #### XOR

          public static final Operator XOR

      XOR the colors of the overlapping region.

      This operator has the same effect for bounded and unbounded.

      Since:
        4.0.16