|
| 以 PDF 格式下載這本書
Operators
11
- This chapter describes the operators found in OpenStep, but not in the standard PostScript language. The PostScript Language Reference Manual (the Red Book), Second Edition, by Adobe Systems Incorporated, provides the specifications for standard PostScript and Display PostScript operators.
- The following operator descriptions are in the format used by the PostScript Language Reference Manual, and the Adobe publication Programming the Display PostScript System with X (the Orange Book). For example:
-
operand ... operand operator result ... result 1....n......1...m
Compositing Operators
composite
-
src src width height srcgstate dest dest op composite - x y...........x y
- 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 have different orientations; 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 * Fd(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 the following table. The choices for op are also given in the following table.
-
Table 11-1
| Op | Fs | Fd |
| Clear | 0 | 0 |
| Copy | 1 | 0 |
| Sover | 1 | 1 - srcA |
| Sin | dstA | 0 |
| Sout | 1 - dstA | 0 |
| Satop | dstA | 1 - srcA |
| Dover | 1 - dstA | 1 |
| Din | 0 | srcA |
| Dout | 0 | 1 - srcA |
| Datop | 1 - dstA | srcA |
-
Table 11-1 (Continued)
| Op | Fs | Fd |
| Xor | 1 - dstA | 1 - srcA |
| 1 PlusD | N/A | N/A |
| 2 PlusL | 1 | 1 |
| 3 dissolve | delta | 1 - delta |
| 4 Highlight | N/A | N/A |
- 1. 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.
- 2. For PlusL the addition saturates. That is if (src + dst > white) the result is white.
- 3. For dissolve, Fa and Fs have another parameter: the delta operand to the dissolve operator.
- 4. Highlight doesn't follow the general equation. It turns white pixels light gray (2/3) and light gray pixels white. Pixels of other colors are unaffected. Alpha values are unaffected. Highlight is a valid op only for the compositerect operator.
compositerect
-
dest dest width height op compositerect - x y
- Composites rectangle of current color and coverage with image in current graphics state.
- 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, white becomes black, black becomes white.)
- Note that 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 this operation, 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.
dissolve
-
src src width height srcgstate dest dest delta dissolve - x y...........x y
- Dissolves between area of window referred to by srcgstate and equal area of window referred to by the current graphics state. 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. The values of the composite ops 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
Graphics State Operators
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 sets how much background shows through when compositing images. If the coverage value given 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 the RGB color space.
currentalpha
- - currentalpha coverage
- Returns the coverage parameter of the current graphics state.
|
|