Package-level declarations
Types
A draft frame at canvas size: colours holds palette labels (palette index + 1, 0 background), zones the zone each pixel belongs to (0 background). The two always agree on where the figure is; the zone tells the outline and the dither which ramp a pixel's colour comes from.
Finishes one key frame's draft, shaded at factor times the canvas: MajorityReduce to the canvas, OrphanCleanup, RampDither when the clip asks for it, and the Outline last, so neither cleanup nor dither ever touches it. The hold compares a key frame's reduction with the previous key frame's reduction, before cleanup, dither and outline: holding to the finished draft would carry the outline's colour into the next frame's interior.
The draft stage: each key frame's shaded draft finished at canvas size by the DraftFinisher, as palette labels — what the handoff's draft layer shows. Cached under the shaded drafts, the zone maps, the boxes, the key frames, the DraftColours and the DraftSettings.
How a clip's draft is finished; stored per clip in profile.json. dither softens the edges between neighbouring ramp steps with a checkerboard. Off by default: a clean edge is easier to polish by hand than a dithered one is to undo. hold is how many extra frames a key frame's draft is kept for by hand-polish aids; 0 adds none.
Reduces a draft shaded at factor times the canvas to the canvas, one block of factor × factor pixels per final pixel, by vote. A block is figure when at least half of it is; it then takes the zone most of its figure pixels have, and the colour most of that zone's pixels in the block have, so zone and colour always agree. Ties go to the lowest label, the same way every time.
Removes orphans: single pixels — figure or background — that match none of their eight neighbours in both zone and colour. Each takes the zone and colour most of its neighbours share, the lowest on a tie. A pixel along a one-pixel line keeps its place, since the line's next pixel matches it. Every decision reads the draft as it was, so the result does not depend on scan order.
Draws a one-pixel outline inside the silhouette: every figure pixel with background, or the edge of the canvas, beside one of its edges takes the project's outline colour when there is one, or else the darkest colour of its own ramp. Inside, so the figure keeps the size it was drawn at.
Softens the edge between two neighbouring steps of one ramp with a checkerboard: on the darker side of the edge, every pixel at an even place of the 2×2 Bayer matrix takes the lighter step. Only within a zone and only between adjacent steps, so an outline or a change of material is never dithered. Off unless the clip asks for it.