PdfFunction

sealed class PdfFunction

A PDF function (ISO 32000-1 §7.10). Functions map an n-component input to an m-component output, typically used by shadings, transparency groups, tint transforms, and halftone phase calculations.

KitePDF v0.0.x supports:

  • Type 2 (exponential interpolation, §7.10.3) — the most common case; used heavily by axial/radial shadings.

  • Type 3 (stitching, §7.10.4) — a piecewise combinator that glues subordinate functions back-to-back.

Type 0 (sampled) and Type 4 (PostScript calculator) parse but evaluate to zeros; they're called out in the README as future work.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class Type2(val domain: DoubleArray, val range: DoubleArray?, val c0: DoubleArray, val c1: DoubleArray, val n: Double) : PdfFunction

Exponential interpolation. Maps a single-component input x in [domain[0], domain[1]] to c0 + x^N * (c1 - c0) per output channel. The N ("exponent") of 1 yields linear interpolation; >1 biases toward c0; <1 toward c1.

Link copied to clipboard
data class Type3(val domain: DoubleArray, val range: DoubleArray?, val functions: List<PdfFunction>, val bounds: DoubleArray, val encode: DoubleArray) : PdfFunction

Stitching function. A piecewise function that delegates to one of functions based on x's position relative to bounds, remapping x into the corresponding subfunction's domain via encode.

Link copied to clipboard
data class Unsupported(val type: Int, val domain: DoubleArray, val range: DoubleArray?, val outputCount: Int) : PdfFunction

Placeholder for function types we don't fully evaluate (Type 0 sampled, Type 4 PostScript calculator). Returns an all-zero output of the right length so callers don't crash; shadings using these degrade to flat black (or to the background color, if any).

Properties

Link copied to clipboard
abstract val domain: DoubleArray

Input bounds — paired [min0, max0, min1, max1, …].

Link copied to clipboard
abstract val outputCount: Int

Number of output components.

Link copied to clipboard
abstract val range: DoubleArray?

Optional output bounds; null = unclipped.

Functions

Link copied to clipboard

Evaluate f(input) → output. The output length is outputCount.