Solaris X Window System Developer's Guide

Operator Descriptions

This section describes the new DPS operators. The information is provided in the format used in the PostScript manuals PostScript Language Reference Manual and Programming the Display PostScript System with X.

setalpha coverage setalpha

Sets the coverage parameter in the current graphics state to coverage. coverage should be a number between 0 and 1, with 0 corresponding to transparent, 1 corresponding to opaque, and intermediate values corresponding to partial coverage. The default value is 1. This establishes how much background shows through for purposes of compositing. If the coverage value is less than 0, the coverage parameter is set to 0. If the value is greater than 1, the coverage parameter is set to 1.

The coverage value affects the color painted by PostScript marking operations. The current color is pre-multiplied by the alpha value before rendering. This multiplication occurs after the current color has been transformed to RGB space.

Errors stackunderflow, typecheck

See also composite, currentalpha

currentalpha -currentalpha coverage

Returns the coverage parameter of the current graphics state.

Errors None

See also composite, setalpha

composite srcx srcy width height srcgstate destx desty op composite

Performs the compositing operation specified by op between pairs of pixels in two images, a source and a destination. The source pixels are in the drawable referred to by the srcgstate graphics state, and the destination pixels are in the drawable specified by the current graphics state. If srcgstate is NULL, the current graphics state is assumed.

The rectangle specified by srcx, srcy, width, and height defines the source image. The outline of the rectangle may cross pixel boundaries due to fractional coordinates, scaling, or rotated axes. The pixels included in the source are all those that the outline of the rectangle encloses or enters.

The destination image has the same size, shape, and orientation as the source; destx and desty give destination's location image compared to the source. Even if the two graphic states have different orientations, the images will not; composite will not rotate images.

Both images are clipped to the frame rectangles of the respective drawables. The destination image is further clipped to the clipping path of the current graphics state. The result of a composite operation replaces the destination image.

op specifies the compositing operation. The color of each destination image pixel (alpha value) after the operation, dst' (dstA'), is given by:

	dst' = src *

Fs(srcA, dstA, op) + dst * Fd(srcA, dstA, op)
	dstA' = srcA *

Fs(srcA, dstA, op) + dstA * Fs(srcA, dstA, op)

where src and srcA are the source color and alpha values, dst and dstA are the destination color and alpha values, and Fs and Fd are the functions given in Table 2–2.

The choices for the composite op are given in Table 2–2. See Figure 2–3for the result of each operation.

Errors rangecheck, stackunderflow, typecheck

See also compositerect, setalpha, setgray, sethsbcolor, setrgbcolor

Table 2–2 Factors of the Compositing Equation







1 - srcA 




1 - dstA 



1 - srcA 


1 - dstA 




1 - srcA 


1 - dstA 



1 - dstA 

1 - srcA 

PlusD [PlusD does not follow the general equation. The equation is dst'=(1-dst)+(1-src). If the result is less than 0 (black), then the result is 0.]



PlusL [For PlusL, the addition asturates. That is, if (src+dst) > white), the result is white.]

Figure 2–3 shows the result of the compositing operations.

Figure 2–3 Results of Compositing Operations


compositerect destx desty width height op compositerect -

In general, this operator is the same as the composite operator except that there is no real source image. The destination is in the current graphics state; destx, desty, width, and height describe the destination image in that graphics state's current coordinate system. The effect on the destination is as if there were a source image filled with the color and coverage specified by the graphics state's current color and coverage parameters. op has the same meaning as the op operand of the composite operator; however, one additional operation, Highlight, is allowed.

Highlight turns every white pixel in the destination rectangle to light gray and every light gray pixel to white, regardless of the pixel's coverage value. Light gray is defined as 2/3. Repeating the same operation reverses the effect. (On monochrome displays, Highlight inverts each pixel so that white becomes black, black becomes white.)

Note –

The Highlight operation doesn't change the value of a pixel's coverage component. To ensure that the pixel's color and coverage combination remains valid, Highlight operations should be temporary and should be reversed before any further compositing.

For compositerect, the pixels included in the destination are those that the outline of the specified rectangle encloses or enters. The destination image is clipped to the frame rectangle and clipping path of the window in the current graphics state.

Errors rangecheck, stackunderflow, typecheck

See also composite, setalpha, setgray, sethsbcolor, setrbgcolor

dissolve srcx srcy width height srcgstate destx desty delta dissolve -

The effect of this operation is a blending of a source and a destination image. The first seven arguments choose source and destination pixels as they do for composite. The exact fraction of the blend is specified by delta, which is a floating-point number between 0.0 and 1.0. The resulting image is:

delta * source + (1-delta) * destination

If srcgstate is null, the current graphics state is assumed.

Errors stackunderflow, typecheck

See also composite

The values of the composite op are available for applications in the PostScript systemdict. The definitions are as follows:

/Clear 0 def

/Copy 1 def

/Sover 2 def

/Sin 3 def

/Sout 4 def

/Satop 5 def

/Dover 6 def

/Din 7 def

/Dout 8 def

/Datop 9 def

/Xor 10 def

/PlusD 11 def

/Highlight 12 def

/PlusL 13 def