Package-level declarations
Types
Parsed Extended Graphics State (ISO 32000-1 §8.4.5).
Parallel offset/colour arrays describing a sampled gradient.
Mutable stack façade. Holds the current state plus a save stack for q/Q.
Graphics state (ISO 32000-1 §8.4).
The part of an ICC profile a document reader actually needs: the matrix/TRC shape that RGB and grey profiles use.
Platform bitmaps that a canvas built from images, so that an image drawn many times on a page, such as a tiled background or a row of icons, converts once (#117). A canvas keeps one cache for as long as it draws.
PDF blend modes (ISO 32000-1 §11.3.5).
High-level drawing target. Implement this to add a new render backend; use PdfPage.renderTo to drive an existing one.
Colour-space resolution + sample-to-RGB conversion (ISO 32000-1 §8.6).
A PDF function (ISO 32000-1 §7.10). Functions map an n-component input to an m-component output, used by shadings, transparency groups, tint transforms and halftone calculations.
How a gradient continues past its ends: the spreadMethod of an SVG gradient (SVG 1.1, 13.2.2 and 13.2.3) and the SpreadMethod of an XPS gradient brush. A PDF shading has no such attribute: its /Extend flags can only pad.
One image a document handler produced, ready for a KiteCanvas: the samples plus everything needed to read them (colour space, bit depth, /Decode, masks). PDF fills it from a /XObject /Image resource entry (ISO 32000-1 §8.9.5); EPUB fills it from a decoded PNG, JPEG or GIF.
How a canvas samples an image that it draws. ISO 32000-1, 8.9.5.3 leaves image interpolation to the reader, so every canvas follows imageSampling and draws the same pixels (#122, #123).
The transfer function of a soft mask as a table of 256 levels (ISO 32000-1, 11.6.5.2, Table 144, /TR). The table maps each value of the mask group, its alpha or its luminosity, to the mask value that gates the content. Both run from 0 to 255.
A geometric path accumulated by m/l/c/v/y/h/re operators before being painted by S/f/B/n.
Parsed /Pattern resource entry (ISO 32000-1 §8.7).
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.
How a canvas strokes a path under a matrix. ISO 32000-1, 8.4.3.2 measures the line width and the dash lengths in user space, so the pen is a circle there. A matrix that scales x and y differently, or skews, turns the circle into an ellipse on the device, and one device width cannot draw it (#108). strokePen picks the space to stroke in.
Backend that ignores everything, useful for benchmarks and content-stream sanity tests.
A reading theme: a page background plus a mapColor transform applied to every text / vector / border / CSS-background colour a page paints. Images and gradients pass through untouched, so photos never invert.
Records every device call, useful for tests + verifying operator dispatch.
Per-BT/ET block text state, reset at BT and mutated by text operators.
Properties
Default allocation ceiling shared by every rasterizing surface in KitePDF: 40 MP already expands to 160 MiB of RGBA, so refuse more before allocating.
The most periods that spreadOver builds. Canvases sample a gradient at 256 stops, 8 per period.
Functions
Merge the non-null fields of ext into this state. Spec semantics for gs <name>: only entries present in the ExtGState override; everything else passes through.
Renders the complex shading types, so every backend supports them identically with no code of its own:
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. The default of 256 matches MuPDF, so a function with many narrow bands keeps them all (#153).
A bitmap of width by height straight (not premultiplied) ARGB pixels, averaged down like shrinkRgba into straight RGBA bytes. readRows fills its array with the rows rows that start at row y, shrinkY rows at a time, so a large decoded bitmap is never copied whole.
rgba, straight RGBA of width by height pixels, averaged down by shrinkX columns and shrinkY rows into each output pixel. A block at the right or bottom edge averages the pixels it has. Colours are weighted by their alpha, so a transparent pixel does not darken its neighbours. The result is ceil(width / shrinkX) by ceil(height / shrinkY) pixels.
This axial or radial shading continued past its ends by spread, over a region whose bounds in shading space are region. The result is an ordinary shading that every canvas paints: its geometry grows to cover the region, and a stitching function (ISO 32000-1, 7.10.4) repeats or mirrors the colours once per period.
The area that stroking this path paints, as a path to fill with the nonzero rule. The pen is round in path space, so the outline filled under a non-uniform matrix gives the elliptical pen that ISO 32000-1, 8.5.3.2 describes.
Assemble a Kind.RAW image's already-decoded samples into a flat RGBA8888 buffer (R,G,B,A per pixel, row-major, no padding) that a platform backend can wrap in a bitmap.