PdfShading

sealed class PdfShading

A PDF shading (ISO 32000-1 §8.7.4). Shadings define smooth color transitions used as fills via the sh content-stream operator or via a shading pattern referenced by SCN/scn.

KitePDF v0.0.x renders:

  • Type 2 axial — a linear gradient between two points

  • Type 3 radial — a radial gradient between two circles

Types 1 (function-based), 4 (free-form Gouraud), 5 (lattice-form Gouraud), 6 (Coons patch), and 7 (tensor-product patch) parse to Unsupported and render as the background color (or transparent if none); they're called out in the README as future work.

Inheritors

Types

Link copied to clipboard
data class Axial(val colorSpace: ColorSpace, val background: RgbColor?, val bbox: Rectangle?, val coords: DoubleArray, val domain: DoubleArray, val function: PdfFunction, val extendStart: Boolean, val extendEnd: Boolean) : PdfShading

Type 2 axial shading. Linear gradient between (x0, y0) and (x1, y1) with t running across domain. function supplies a colour per t value; we sample it at a fixed number of stops and hand those to the backend.

Link copied to clipboard
object Companion
Link copied to clipboard
data class Radial(val colorSpace: ColorSpace, val background: RgbColor?, val bbox: Rectangle?, val coords: DoubleArray, val domain: DoubleArray, val function: PdfFunction, val extendStart: Boolean, val extendEnd: Boolean) : PdfShading

Type 3 radial shading. Gradient between two circles: (x0, y0, r0) and (x1, y1, r1) with t running across domain.

Link copied to clipboard
data class Unsupported(val type: Int, val colorSpace: ColorSpace, val background: RgbColor?, val bbox: Rectangle?) : PdfShading

Shading type we don't render; falls back to background (or transparent).

Properties

Link copied to clipboard
abstract val background: RgbColor?

Optional /Background colour — used for regions outside the shading domain when Extend is false on the relevant side. Per spec the background is in colorSpace; we eager-convert to RGB.

Link copied to clipboard
abstract val bbox: Rectangle?

Optional clipping rectangle (/BBox) in shading-space.

Link copied to clipboard
abstract val colorSpace: ColorSpace

The shading's colour space (DeviceGray / DeviceRGB / DeviceCMYK / Indexed).

Functions

Link copied to clipboard

Sample a PdfShading.Axial or PdfShading.Radial at evenly-spaced stops between domain[0] and domain[1]. Returns parallel t and RGB arrays the backend uses to build a gradient brush.