PdfFunction Class
A function (ISO 32000-2, 7.10): it maps m inputs to n outputs, such as the position in a gradient to the components of its color. A function does not belong to a document: each document that uses it gets its own object. The instances are immutable.
public abstract class PdfFunctionProperties
| Name | Description |
|---|---|
| InputCount | Gets the number of inputs. |
| OutputCount | Gets the number of outputs. |
InputCount
PdfFunction.csOutputCount
Methods
| Name | Description |
|---|---|
| Exponential(PdfColor, PdfColor) | Creates an exponential interpolation function between two colors of the same color space. |
| Exponential(ReadOnlySpan<double>, ReadOnlySpan<double>, double) | Creates an exponential interpolation function (type 2, 7.10.3): C0 + x^N × (C1 − C0), with one input from 0 to 1. |
| Gradient(ReadOnlySpan<(double Position, PdfColor Color)>) | Creates a stitching function of linear interpolations between colors at positions from 0 to 1: the stops of a gradient. |
| PostScript(string, ReadOnlySpan<double>, ReadOnlySpan<double>) | Creates a PostScript calculator function (type 4, 7.10.5): a program of the operators of 7.10.5 between braces, such as { dup 0.5 mul exch }. |
| Sampled(ReadOnlySpan<int>, int, ReadOnlySpan<double>, ReadOnlySpan<double>, ReadOnlySpan<byte>) | Creates a sampled function (type 0, 7.10.2): a table of samples, interpolated linearly between them. |
| Stitching(IReadOnlyList<PdfFunction>, ReadOnlySpan<double>, ReadOnlySpan<double>, double, double) | Creates a stitching function (type 3, 7.10.4): the domain is split by the bounds into intervals, each mapped to one of the functions. |
Exponential overloads
Exponential(PdfColor, PdfColor)
PdfFunction.csCreates an exponential interpolation function between two colors of the same color space.
public static PdfFunction Exponential(PdfColor start, PdfColor end)Exponential(ReadOnlySpan<double>, ReadOnlySpan<double>, double)
PdfFunction.csCreates an exponential interpolation function (type 2, 7.10.3): C0 + x^N × (C1 − C0), with one input from 0 to 1.
public static PdfFunction Exponential(ReadOnlySpan<double> c0, ReadOnlySpan<double> c1, double exponent = 1d)Parameters
c0ReadOnlySpan<double>- The outputs at 0.
c1ReadOnlySpan<double>- The outputs at 1; the same number of values as
c0. exponentdouble- The interpolation exponent
N; 1 for a linear interpolation.
Returns
PdfFunction The function.
Gradient(ReadOnlySpan<(double Position, PdfColor Color)>)
PdfFunction.csCreates a stitching function of linear interpolations between colors at positions from 0 to 1: the stops of a gradient.
public static PdfFunction Gradient(params scoped ReadOnlySpan<(double Position, PdfColor Color)> stops)Parameters
stopsReadOnlySpan<(double Position, PdfColor Color)>- The positions, in increasing order from 0 to 1, and the colors, all in the same color space.
Returns
PdfFunction The function.
PostScript(string, ReadOnlySpan<double>, ReadOnlySpan<double>)
PdfFunction.csCreates a PostScript calculator function (type 4, 7.10.5): a program of the operators of 7.10.5 between braces, such as { dup 0.5 mul exch }.
public static PdfFunction PostScript(string program, ReadOnlySpan<double> domain, ReadOnlySpan<double> range)Parameters
programstring- The program.
domainReadOnlySpan<double>- Two values per input.
rangeReadOnlySpan<double>- Two values per output.
Returns
PdfFunction The function.
Sampled(ReadOnlySpan<int>, int, ReadOnlySpan<double>, ReadOnlySpan<double>, ReadOnlySpan<byte>)
PdfFunction.csCreates a sampled function (type 0, 7.10.2): a table of samples, interpolated linearly between them.
public static PdfFunction Sampled(ReadOnlySpan<int> size, int bitsPerSample, ReadOnlySpan<double> domain, ReadOnlySpan<double> range, ReadOnlySpan<byte> samples)Parameters
sizeReadOnlySpan<int>- The number of samples in each input dimension, at least 1.
bitsPerSampleint- The bits of each sample: 1, 2, 4, 8, 12, 16, 24 or 32.
domainReadOnlySpan<double>- Two values per input.
rangeReadOnlySpan<double>- Two values per output: a sample of 0 is the first value, the largest sample the second.
samplesReadOnlySpan<byte>- The samples, the first dimension varying fastest, the outputs of a sample together, packed in big-endian bits.
Returns
PdfFunction The function.
Stitching(IReadOnlyList<PdfFunction>, ReadOnlySpan<double>, ReadOnlySpan<double>, double, double)
PdfFunction.csCreates a stitching function (type 3, 7.10.4): the domain is split by the bounds into intervals, each mapped to one of the functions.
public static PdfFunction Stitching(IReadOnlyList<PdfFunction> functions, ReadOnlySpan<double> bounds, ReadOnlySpan<double> encode = default, double domainStart = 0d, double domainEnd = 1d)Parameters
functionsIReadOnlyList<PdfFunction>- The functions of the intervals: one input each, the same number of outputs.
boundsReadOnlySpan<double>- The values that split the domain, in increasing order: one less than the functions.
encodeReadOnlySpan<double>- The interval of the input of each function the interval of the domain is mapped to: two values per function;
nullfor[0 1]each. domainStartdouble- The start of the domain.
domainEnddouble- The end of the domain.
Returns
PdfFunction The function.