Package-level declarations
Types
How every zone of a clip is shaded, by zone: zones index i shades the zone labelled i + 1.
The colours a clip's draft is shaded and finished in, as palette labels — palette index plus one, so 0 stays background, as in zone maps, and can be the transparent entry of an indexed .ase. zones holds each zone's ramp, darkest first; outline the project's outline colour, or null to outline each zone in its ramp's darkest.
The draft shading stage: each key frame, sampled onto the canvas at FACTOR times its size and shaded by RampShader, as palette labels. The draft is drawn large and reduced afterwards, so the reduction can vote on what every final pixel shows.
Shades a frame: each pixel of a zone takes the ramp step its OKLab lightness falls in under the clip's shading, and so the palette label zoneColours gives that step. Works at whatever size it is given, the frame and its zone map sampled alike.
How a clip's zones are shaded; stored per clip in profile.json. Each zone's lightness range runs from its lowPercentile to its highPercentile over every frame of the clip, and is split evenly into the steps of its ramp. Trimming the extremes keeps a few specular highlights or deep creases from stretching the range and flattening everything else into the middle steps.
The shading stage: a clip's ClipShading by ShadingFit, over every frame, cached under the frames, the zone maps, the number of steps in each zone's ramp and the ShadeSettings. Moving a key-frame marker does not refit it: the thresholds belong to the whole clip.
Fits a clip's ClipShading: for each zone, the ShadeSettings percentiles of the OKLab lightness of all its pixels across every frame. Percentiles are nearest-rank on the sorted lightnesses, so the fit is exact and the same on every machine.
How one zone is shaded: lightness low to high split evenly into steps steps, step 0 the darkest. Fixed for the whole clip, so one pixel colour takes one step in every frame.