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 PdfFunction

Properties

NameDescription
InputCountGets the number of inputs.
OutputCountGets the number of outputs.

InputCount

PdfFunction.cs

Gets the number of inputs.

public int InputCount { get; }

Property value

int

OutputCount

Gets the number of outputs.

public abstract int OutputCount { get; }

Property value

int

Methods

NameDescription
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.cs

Creates an exponential interpolation function between two colors of the same color space.

public static PdfFunction Exponential(PdfColor start, PdfColor end)
Parameters
start PdfColor
The color at 0.
end PdfColor
The color at 1.
Returns

PdfFunction The function.

Exponential(ReadOnlySpan<double>, ReadOnlySpan<double>, double)

PdfFunction.cs

Creates 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
c0 ReadOnlySpan<double>
The outputs at 0.
c1 ReadOnlySpan<double>
The outputs at 1; the same number of values as c0.
exponent double
The interpolation exponent N; 1 for a linear interpolation.
Returns

PdfFunction The function.

Gradient(ReadOnlySpan<(double Position, PdfColor Color)>)

PdfFunction.cs

Creates 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

stops ReadOnlySpan<(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.cs

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 }.

public static PdfFunction PostScript(string program, ReadOnlySpan<double> domain, ReadOnlySpan<double> range)

Parameters

program string
The program.
domain ReadOnlySpan<double>
Two values per input.
range ReadOnlySpan<double>
Two values per output.

Returns

PdfFunction The function.

Sampled(ReadOnlySpan<int>, int, ReadOnlySpan<double>, ReadOnlySpan<double>, ReadOnlySpan<byte>)

PdfFunction.cs

Creates 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

size ReadOnlySpan<int>
The number of samples in each input dimension, at least 1.
bitsPerSample int
The bits of each sample: 1, 2, 4, 8, 12, 16, 24 or 32.
domain ReadOnlySpan<double>
Two values per input.
range ReadOnlySpan<double>
Two values per output: a sample of 0 is the first value, the largest sample the second.
samples ReadOnlySpan<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.cs

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.

public static PdfFunction Stitching(IReadOnlyList<PdfFunction> functions, ReadOnlySpan<double> bounds, ReadOnlySpan<double> encode = default, double domainStart = 0d, double domainEnd = 1d)

Parameters

functions IReadOnlyList<PdfFunction>
The functions of the intervals: one input each, the same number of outputs.
bounds ReadOnlySpan<double>
The values that split the domain, in increasing order: one less than the functions.
encode ReadOnlySpan<double>
The interval of the input of each function the interval of the domain is mapped to: two values per function; null for [0 1] each.
domainStart double
The start of the domain.
domainEnd double
The end of the domain.

Returns

PdfFunction The function.