public class Operator
extends org.freedesktop.bindings.Constant
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.
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.
|
public static final Operator ADD
This operator has the same effect for bounded and unbounded.
public static final Operator ATOP
This operator has the same effect for bounded and unbounded.
public static final Operator CLEAR
This operator is bounded.
public static final Operator DEST
This operator has the same effect for bounded and unbounded.
public static final Operator DEST_ATOP
ATOP
Operator.
This operator is unbounded.
public static final Operator DEST_IN
IN
Operator.
This operator is unbounded.
public static final Operator DEST_OUT
This operator has the same effect for bounded and unbounded.
public static final Operator DEST_OVER
OVER
operator.
This operator has the same effect for bounded and unbounded.
public static final Operator IN
This operator is unbounded.
public static final Operator OUT
This operator is unbounded.
public static final Operator OVER
This is the default operator.
This operator has the same effect for bounded and unbounded.
public static final Operator SATURATE
This operator has the same effect for bounded and unbounded.
public static final Operator SOURCE
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();
public static final Operator XOR
This operator has the same effect for bounded and unbounded.