Previous Next
175
SECTION 3.9 Functions
The last function applies to x values in the last subdomain, which includes the
upper bound: Boundsk−2 ≤ x ≤ Domain1 . The value of k may be 1, in which case
the Bounds array is empty and the single item in the Functions array applies to all
x values, Domain0 ≤ x ≤ Domain1 .
The Encode array contains 2 × k numbers. A value x from the ith subdomain is
encoded as follows:
·
x′ = Interpolate ( x , Bounds i – 1 , Bounds i , Encode 2i , Encode 2i + 1 )
for 0 ≤ i < k. In this equation, Bounds−1 means Domain0 , and Boundsk−1 means
Domain1 . If the last bound, Boundsk−2 , is equal to Domain1 , then x ′ is defined to
be Encode2i .
The stitching function is designed to make it easy to combine several functions to
be used within one shading pattern over different parts of the shading’s domain.
(Shading patterns are discussed in Section 4.6.3, “Shading Patterns.”) The same
effect could be achieved by creating a separate shading dictionary for each of the
functions, with adjacent domains. However, since each shading would have
similar parameters, and because the overall effect is one shading, it is more con-
venient to have a single shading with multiple function definitions.
Also, type 3 functions provide a general mechanism for inverting the domains of
1-input functions. For example, consider a function f with a Domain of [ 0.0 1.0 ]
and a stitching function g with a Domain of [ 0.0 1.0 ], a Functions array
containing f, and an Encode array of [ 1.0 0.0 ]. In effect, g (x) = f (1 − x).
3.9.4 Type 4 (PostScript Calculator) Functions
A type 4 function (PDF 1.3), also called a PostScript calculator function, is
represented as a stream containing code written in a small subset of the PostScript
language. Although any function can be sampled (in a type 0 PDF function) and
others can be described with exponential functions (type 2 in PDF), type 4
functions offer greater flexibility and potentially greater accuracy. For example, a
tint transformation function for a hexachrome (six-component) DeviceN color
space with an alternate color space of DeviceCMYK (see “DeviceN Color Spaces”
on page 268) requires a 6-in, 4-out function. If such a function were sampled with
m values for each input variable, the number of samples, 4 × m6, could be
prohibitively large. In practice, such functions are often written as short, simple
PostScript functions. (See implementation note 43 in Appendix H.)
Previous Next