KiteShading

sealed class KiteShading

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 renders:

  • Type 1 function-based: a colour function over a 2D domain, rasterized as a grid of cells (T-40)

  • Type 2 axial: a linear gradient between two points

  • Type 3 radial: a radial gradient between two circles

  • Types 4/5 Gouraud triangle meshes: smoothed by recursive subdivision with vertex-colour interpolation (T-40)

  • Types 6/7 Coons / tensor patches: tessellated into flat-coloured quads via Coons boundary evaluation + bilinear corner colours; the tensor type's four interior points are read but ignored, the documented MuPDF-level approximation (T-40)

Types 1/4/5/6/7 render through paintComplexShading, shared by every backend (pure fillPath emission); 2/3 keep the backends' native gradient brushes. Unparseable shadings become Unsupported and paint nothing.

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: KiteFunction, val extendStart: Boolean, val extendEnd: Boolean) : KiteShading

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
class FlatQuad(val xs: DoubleArray, val ys: DoubleArray, val color: RgbColor)

A flat-coloured tessellation quad from a Coons/tensor patch.

Link copied to clipboard
class FunctionBased(val colorSpace: ColorSpace, val background: RgbColor?, val bbox: Rectangle?, val domain: DoubleArray, val matrix: Matrix, function: KiteFunction) : KiteShading

Type 1: colour as a function of (x, y) over domain (x0 x1 y0 y1), mapped into user space by matrix. Rendered as a grid of coloured cells by paintComplexShading.

Link copied to clipboard
class MeshTriangle(val x: DoubleArray, val y: DoubleArray, val colors: Array<RgbColor>)

One Gouraud triangle: three shading-space vertices with colours.

Link copied to clipboard
class PatchMesh(val colorSpace: ColorSpace, val background: RgbColor?, val bbox: Rectangle?, val quads: List<KiteShading.FlatQuad>) : KiteShading

Types 6/7, pre-tessellated at parse time.

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

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

Link copied to clipboard
class TriangleMesh(val colorSpace: ColorSpace, val background: RgbColor?, val bbox: Rectangle?, val triangles: List<KiteShading.MeshTriangle>) : KiteShading

Types 4/5: a triangle mesh with per-vertex colours.

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

Shading type we don't render; sampleStops returns null, so nothing paints.

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 KiteShading.Axial or KiteShading.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.